Codes
Codes
Codes
Listbox1.items.Add(txtname.text)
End if
Remove
2-Cbx1.items.addrange()
2-cbx1.items.removeAt(cbx1.selectedindex)
Remove
If index=0 then
………………………..>
ListView
Form_Load
Lstv1.Gridlines=True
Lstv1.checkboxes=True
Lstv1.columns.Add("name",250)
Lstv1.columns.Add("job",400)
………………………..>
Lv1.subitems.Add("ahmed")
Lv1.subitems.Add("chemist")
Lv1.subitems.Add("ali")
Lv1.subitems.Add("che2t")
………………………..>
1 - Lstv1.items.Add(lv1)
Lstv1.items.Add(lv2)
2 - Lstv1.items.AddRange(New ListViewItem(){lv1,lv2,lv3,……})
3- Lstv1.items.Add("0004",1pic)
Lstv1.items(3).subitems.Add("magdy")
Lstv1.items(3).subitems.Add("engineer")
FOR CHECKEDBOXES
For Each item AS ListViewItem In Lstv1.checkeditems
Msgbox(Item.subitems(0))
Next
OR
Lstv1.items.removeAt(item.index)
Next
Lstv1.Gridlines=True
Lstv1.groups.Add("Group1","Customers Gr")
Lstv1.groups.Add("Group2","Supp Gr")
………….>
Lstv1.items(0).group=lstv1.groups(0)
Lstv1.items(1).group=lstv1.groups(1)
Lstv1.items(2).group=lstv1.groups(0)
………….>
Reading Data from SQL tables in listview
After setting connection
Lstv1.columns.Add("name",250)
Lstv1.columns.Add("job",400)
………………………..>
Lstv1.columns(0).width = 100
Lstv1.columns(1).width = 300
………………………..>
WHILE reader.read
Item.subitems.Add(reader("name"))
Item.subitems.Add(reader("job"))
Item.subitems.Add(reader("notes"))
Lstv1.items.Add(item)
END WHILE
Reader.close()
ADDING (INSERTING) Data to SQL tables from input form
After connection
TRY
Conn.open()
Cmd.executenonquery()
Msgbox("SUCCESS",msgboxstyle.information,"Adding Data")
CATCH ex AS EXCEPTION
Msgbox(ex.message)
FINALLY
Conn.close()
END TRY
Conn.open()
dr.read()
if dr.HasRows THEN
txt2.text=dr(1)
txt3.text=dr(2)
………………………..>
IF Msgbox("Are You Sure DELETE??? ",msgboxstyle.YesNo,"deleting")=dialogResult.Yes THEN
Dr.close()
Cmd=new sqlcommand(delete,conn)
Cmd.executenonquery
ELSE
Msgbox("CANCELED ",msgboxstyle.information,"CANCEL")
ELSE
CATCH ex AS EXCEPTION
Msgbox(ex.message)
FINALLY
Conn.close()
END TRY
TRY
Conn.open()
dr.read()
IF dr.HasRows THEN
txt2.text=dr(1)
txt3.text=dr(2)
FOR Date….> txt4.value=dr(4)
………………………..>
Btnadd.enabled=false
ELSE
Btnadd.enabled=True
All txt134.clear()
forDATE..>txt4.resettext()
END IF
Dim EDIT as string="UPDATE tblname SET name='" & txt2.text &"',job='"& txt2.text&"',………,
'"& txt4.value.tostring("yyyy-MM-dd") &"' WHERE ID=" & txt1,text "
conn.open()
Cmd=new sqlcommand(EDIT,conn)
Cmd.executenonquery
ELSE
Msgbox("CANCELED ",msgboxstyle.information,"CANCEL")
END IF
CATCH ex AS EXCEPTION
Msgbox(ex.message)
FINALLY
Conn.close()
END TRY
DATA GRID View
الوضع المنفصل عبارة عن
داتا ادابتر جلب بيانات بواسطة -1
تخزينها في الذاكرة في صورة -2
عبارة عن جدول واحد فقط... تحتوي علي مجموعة جداول === او داتا تيبل... داتا سيت
After connection
FORM_LOAD
Adapter=new sqldataadapter(qry,conn)
Adapter.fill(ds,"fake tblname")
2 - DGV1.Datasource=ds.tables(0) لوجود جدول واحد فقط نستخدم الرتبة بدل االسم اللي هي صفر
Adapter.fill(dt)
DGV1.Datasource=dt
After connection
BtnAdd_CLICK
Dim row as datarow = dt.newrowثم اعطاء تفاصيله باالسفل .... انشاء سطر فارغ............
Row(0) = txt1.text
Row(1) = txt2.text
……………….>>
Dt.rows.Add(row)
Adapter.update(dt)
After connection
FORM_LOAD
Adapter=new sqldataadapter(qry,conn)
Adapter.fill(dt)
DGV1.Datasource=dt
لتعريف الحقل الرئيسي البرايمري كي
Dt.constraints.Add("Primary",dt.columns(0), true) OR
Dt.constraints.Add("Primary",dt.columns(")"المعرف, true)
btnDELETE_CLICK
ELSE
Row.delete()
Adapter.update(dt)
END IF
OLDID = row(0)
Txt2.text = row(1)
Txt3.text = row(2)
………………………>>
END IF
btnUPDATE_CLICK
Dim row as datarow = dt.rows.find(OLDID)
Row(0) = txt1.text
Row(1) = txt2.text
………………………>>
Adapter.update(dt)
Btn_search_CLICK
Sorting
Dv.sort = " ID desc"
Filtering
Dv.rowfilter = " ID > 2"
Dv.rowfilter = " name like '%" & txtsearch.text & "%' OR job like '%" & txtsearch.text & "%'"
Dv.rowfilter = " ID+name+job……….>> like '%" & txtsearch.text & "%' "
DGV1.datasource = dv
Combo BOX-again
SELECTED INDEX CHANGED
2-Cbx1.items.addrange()
2-cbx1.items.removeAt(cbx1.selectedindex)
Remove
If index=0 then
………………………..>
MAIN CLASS
After connection
FORM_LOAD
Adapter.fill(dt)
Cbx1.datasource = dt
Cbx1.displaymember = "name"
Cbx1.valuemember = "ID"
TRY
تم عمل نسخة اخري من الداتا تيبل.. لحدوث تعارض بين البيانات في الكومبو وااللليبل
lblname.text = dv.item(0)(1)
lbljob.text = dv.item(0)(2)
…………………….>> OR
lblname.text = row(0)(1)
lbljob.text = row(0)(2)
…………………….>>
CATCH ex AS EXCEPTION
EXIT sub
END TRY
Adding items to combobox according to ANOTHER COMBOBOX
End If
End Sub
Key preview=true
VR_ItemsMovement
SELECT dbo.buy_d.item_detail_code, dbo.buy.buy_date AS DDatee, dbo.buy_d.qty AS
QQty, dbo.supplier.supplier_name AS PersonName, 1 AS A_TypeID, ' 'مشترياتAS
A_TypeName
UNION ALL
dbo.sales_return_d ON dbo.sales_return.sales_return_code =
dbo.sales_return_d.sales_return_code INNER JOIN
dbo.customer ON dbo.sales_return.customer_code =
dbo.customer.customer_code
UNION ALL
UNION ALL
dbo.buy_return_d ON dbo.buy_return.buy_return_code =
dbo.buy_return_d.buy_return_code INNER JOIN
UNION ALL
SELECT dbo.mortal_d.item_detail_code, dbo.mortal.mortal_date, dbo.mortal_d.qty,
dbo.mortal.mortal_name, 5 AS Expr1, ' 'هالكAS Expr2
UNION ALL