08-11-22, 07:47 PM
السلام عليكم لدي داتا غريد فيو اريد عندما احدد عدد اسطر عن طريق شيك بوكس واضغط علي زر حدف تحدف اسطر محددة
هدا كود اضافة شيك بوكس لعمود اخير
وهدا كود حدف
هادي محاولتي في الحل يظهر لي اسم صنف موجود مسبقا ياريت مساعده من اعضاء منتدي
هدا كود اضافة شيك بوكس لعمود اخير
وهدا كود حدف
كود :
Dim chk As New DataGridViewCheckBoxColumn
chk.HeaderText = "اختيار"
DataGridView1.Columns.Add(chk)كود :
If MessageBox.Show("هل ترغب في حدف بيانات الصنف", "رسالة تنبيه", MessageBoxButtons.YesNo) = DialogResult.No Then Exit Sub
Dim DT As New DataTable
Dim DA As New SqlDataAdapter("select *from products where label= '" & labell.Text & "'", Module1.con)
DA.Fill(DT)
If DT.Rows.Count = 0 Then
MessageBox.Show("الصنف موجود مسبقا يرجي التاكد", "رساله تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
Dim DR = DT.Rows(0)
DR.Delete()
Dim SAVE As New SqlCommandBuilder(DA)
DA.Update(DT)
MessageBox.Show("تم عملية حدف الصنف بنجاح", "رساله تاكيد", MessageBoxButtons.OK, MessageBoxIcon.Information)
fill_DGV()
Button3_Click(sender, e)
End If(08-11-22, 07:47 PM)ali_ahmed12 كتب : [ -> ]السلام عليكم لدي داتا غريد فيو اريد عندما احدد عدد اسطر عن طريق شيك بوكس واضغط علي زر حدف تحدف اسطر محددة
هدا كود اضافة شيك بوكس لعمود اخير
وهدا كود حدف
كود :
Dim chk As New DataGridViewCheckBoxColumn
chk.HeaderText = "اختيار"
DataGridView1.Columns.Add(chk)كود :
If MessageBox.Show("هل ترغب في حدف بيانات الصنف", "رسالة تنبيه", MessageBoxButtons.YesNo) = DialogResult.No Then Exit Sub
Dim DT As New DataTable
Dim DA As New SqlDataAdapter("select *from products where label= '" & labell.Text & "'", Module1.con)
DA.Fill(DT)
If DT.Rows.Count = 0 Then
MessageBox.Show("الصنف موجود مسبقا يرجي التاكد", "رساله تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
Dim DR = DT.Rows(0)
DR.Delete()
Dim SAVE As New SqlCommandBuilder(DA)
DA.Update(DT)
MessageBox.Show("تم عملية حدف الصنف بنجاح", "رساله تاكيد", MessageBoxButtons.OK, MessageBoxIcon.Information)
fill_DGV()
Button3_Click(sender, e)
End If
(08-11-22, 07:47 PM)ali_ahmed12 كتب : [ -> ]السلام عليكم لدي داتا غريد فيو اريد عندما احدد عدد اسطر عن طريق شيك بوكس واضغط علي زر حدف تحدف اسطر محددة
هدا كود اضافة شيك بوكس لعمود اخير
وهدا كود حدف
كود :
Dim chk As New DataGridViewCheckBoxColumn
chk.HeaderText = "اختيار"
DataGridView1.Columns.Add(chk)كود :
If MessageBox.Show("هل ترغب في حدف بيانات الصنف", "رسالة تنبيه", MessageBoxButtons.YesNo) = DialogResult.No Then Exit Sub
Dim DT As New DataTable
Dim DA As New SqlDataAdapter("select *from products where label= '" & labell.Text & "'", Module1.con)
DA.Fill(DT)
If DT.Rows.Count = 0 Then
MessageBox.Show("الصنف موجود مسبقا يرجي التاكد", "رساله تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
Dim DR = DT.Rows(0)
DR.Delete()
Dim SAVE As New SqlCommandBuilder(DA)
DA.Update(DT)
MessageBox.Show("تم عملية حدف الصنف بنجاح", "رساله تاكيد", MessageBoxButtons.OK, MessageBoxIcon.Information)
fill_DGV()
Button3_Click(sender, e)
End If
(08-11-22, 07:47 PM)ali_ahmed12 كتب : [ -> ]السلام عليكم لدي داتا غريد فيو اريد عندما احدد عدد اسطر عن طريق شيك بوكس واضغط علي زر حدف تحدف اسطر محددة
هدا كود اضافة شيك بوكس لعمود اخير
وهدا كود حدف
كود :
Dim chk As New DataGridViewCheckBoxColumn
chk.HeaderText = "اختيار"
DataGridView1.Columns.Add(chk)كود :
If MessageBox.Show("هل ترغب في حدف بيانات الصنف", "رسالة تنبيه", MessageBoxButtons.YesNo) = DialogResult.No Then Exit Sub
Dim DT As New DataTable
Dim DA As New SqlDataAdapter("select *from products where label= '" & labell.Text & "'", Module1.con)
DA.Fill(DT)
If DT.Rows.Count = 0 Then
MessageBox.Show("الصنف موجود مسبقا يرجي التاكد", "رساله تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
Dim DR = DT.Rows(0)
DR.Delete()
Dim SAVE As New SqlCommandBuilder(DA)
DA.Update(DT)
MessageBox.Show("تم عملية حدف الصنف بنجاح", "رساله تاكيد", MessageBoxButtons.OK, MessageBoxIcon.Information)
fill_DGV()
Button3_Click(sender, e)
End If
هادي محاولتي في الحل يظهر لي اسم صنف موجود مسبقا ياريت مساعده من اعضاء منتدي
كود :
If MessageBox.Show("هل ترغب في حدف بيانات الصنف", "رسالة تنبيه", MessageBoxButtons.YesNo) = DialogResult.No Then Exit Sub
Dim DT As New DataTable
Dim DA As New SqlDataAdapter("select *from products where label= '" & labell.Text & "'", Module1.con)
DA.Fill(DT)
If DT.Rows.Count = 0 Then
MessageBox.Show("الصنف موجود مسبقا يرجي التاكد", "رساله تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
Dim DR = DT.Rows(0)
For x As Integer = DataGridView1.Rows.Count - 1 To 0 Step -1
If DataGridView1.Rows(x).Cells(10).Value Then
DataGridView1.Rows.Remove(DataGridView1.Rows(x))
End If
Next
DR.Delete()
Dim SAVE As New SqlCommandBuilder(DA)
DA.Update(DT)
MessageBox.Show("تم عملية حدف الصنف بنجاح", "رساله تاكيد", MessageBoxButtons.OK, MessageBoxIcon.Information)
fill_DGV()
Button3_Click(sender, e)
End If