مشكور جزاكم الله خير اخوتي
تم حل المشكلة وهي خطأ مني
انا قمت بتحديد رسالة خطأ
تشتت الافكار
الكود يعمل بشكل جيد
وهذا هو للحاجة
تم حل المشكلة وهي خطأ مني
انا قمت بتحديد رسالة خطأ
تشتت الافكار
الكود يعمل بشكل جيد
وهذا هو للحاجة
كود :
Public Sub MoveToDOne()
Try
con = New SqlConnection(cs)
Dim CmdInsert As New SqlCommand
Dim RowsAffected As Integer = 0
If con.State = 1 Then con.Close()
con.Open()
'################################################################
For i As Integer = 0 To DataGridView2.Rows.Count - 1
cmd = New SqlCommand
With cmd
.Connection = con
.CommandType = CommandType.Text
.CommandText = "Insert Into DeviceDone(device_code,cus_name,device_name,cus_phone,cus_address,Brand,model,Place_reform,serial_device,problem,Customer_Complaint,Maximum_cost,received_date,delivery_date)values(@device_code,@cus_name,@device_name,@cus_phone,@cus_address,@Brand,@model,@Place_reform,@serial_device,@problem,@Customer_Complaint,@Maximum_cost,@received_date,@delivery_date)"
.Parameters.Clear()
.Parameters.AddWithValue("@device_code", SqlDbType.Int).Value = Get_Order_No()
.Parameters.AddWithValue("@cus_name", SqlDbType.VarChar).Value = DataGridView2.SelectedRows(i).Cells(1).Value
.Parameters.AddWithValue("@device_name", SqlDbType.VarChar).Value = DataGridView2.SelectedRows(i).Cells(3).Value
.Parameters.AddWithValue("@cus_phone", SqlDbType.VarChar).Value = DataGridView2.SelectedRows(i).Cells(2).Value
.Parameters.AddWithValue("@cus_address", SqlDbType.VarChar).Value = "0"
.Parameters.AddWithValue("@Brand", SqlDbType.VarChar).Value = "0"
.Parameters.AddWithValue("@model", SqlDbType.VarChar).Value = "0"
.Parameters.AddWithValue("@Place_reform", SqlDbType.VarChar).Value = "0"
.Parameters.AddWithValue("@serial_device", SqlDbType.VarChar).Value = "0"
.Parameters.AddWithValue("@problem", SqlDbType.VarChar).Value = DataGridView2.SelectedRows(i).Cells(4).Value
.Parameters.AddWithValue("@Customer_Complaint", SqlDbType.VarChar).Value = "0"
.Parameters.AddWithValue("@Maximum_cost", SqlDbType.VarChar).Value = DataGridView2.SelectedRows(i).Cells(5).Value
.Parameters.AddWithValue("@received_date", SqlDbType.Date).Value = DataGridView2.SelectedRows(i).Cells(6).Value
.Parameters.AddWithValue("@delivery_date", SqlDbType.Date).Value = DataGridView2.SelectedRows(i).Cells(7).Value
'.Parameters.AddWithValue("@device_code", SqlDbType.Int).Value = DataGridView2.Rows(i).Cells(0).Value
'.Parameters.AddWithValue("@cus_name", SqlDbType.VarChar).Value = DataGridView2.Rows(i).Cells(1).Value
'.Parameters.AddWithValue("@cus_phone", SqlDbType.VarChar).Value = DataGridView2.Rows(i).Cells(2).Value
'.Parameters.AddWithValue("@problem", SqlDbType.VarChar).Value = DataGridView2.Rows(i).Cells(3).Value
'.Parameters.AddWithValue("@Maximum_cost", SqlDbType.Date).Value = DataGridView2.Rows(i).Cells(4).Value
'.Parameters.AddWithValue("@received_date", SqlDbType.Date).Value = DataGridView2.Rows(i).Cells(5).Value
'.Parameters.AddWithValue("@delivery_date", SqlDbType.Date).Value = DataGridView2.Rows(i).Cells(6).Value
con.Open()
.ExecuteNonQuery()
End With
Next
'################################################################
con.Close()
Catch ex As Exception
MsgBox(" تمت عملية الحفظ بنجاح", MessageBoxIcon.Information)
'MessageBox.Show(" عفواً ، هناك خطأ بعملية الحفظ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)
'Exit Sub
End Try
delete()
End Subكود :
Private Sub delete()
If MessageBox.Show("هل أنت متأكد تم استلام الجهاز من قبل العميل؟", "تنبيه", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.No Then
Exit Sub
Else
con = New SqlConnection(cs)
If con.State = 1 Then con.Close()
con.Open()
cmd = New SqlCommand
For i As Integer = 0 To DataGridView2.SelectedRows.Count - 1
With cmd
.CommandType = CommandType.Text
Dim comd As New SqlCommand("Delete from DeviceAdd Where device_code=@device_code", con)
comd.Parameters.Add("@device_code", SqlDbType.Int).Value = DataGridView2.SelectedRows(i).Cells(0).Value
comd.ExecuteNonQuery()
End With
Next
con.Close()
LoadAllQuick_Sale()
Count.Text = DataGridView2.Rows.Count
End If
End Sub