private void btnSaveOrder_Click(object sender, EventArgs e) { //check values if (txtOrderID.Text == string.Empty || txtCustID.Text == string.Empty || DGVNEWOrders.Rows.Count < 1 || txtOrderDescription.Text == string.Empty) { MessageBox.Show("ادخل البيانات الناقصه ف الفاتوره", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //ADD ORDER INFORMATION order.ADD_Orders(Convert.ToInt32(txtOrderID.Text), Convert.ToDateTime(datOrderData.Value), Convert.ToInt32(txtCustID.Text), txtOrderDescription.Text, txtOrderSeller.Text); //ADD ORDER PRODUCTS for (int i = 0; i < DGVNEWOrders.Rows.Count - 1; i++) { order.ADD_Order_Details(DGVNEWOrders.Rows[i].Cells[0].Value.ToString() , Convert.ToInt32(txtOrderID.Text) , Convert.ToInt32(DGVNEWOrders.Rows[i].Cells[3].Value) , DGVNEWOrders.Rows[i].Cells[2].Value.ToString() , Convert.ToInt32(DGVNEWOrders.Rows[i].Cells[5].Value) , DGVNEWOrders.Rows[i].Cells[4].Value.ToString() , DGVNEWOrders.Rows[i].Cells[6].Value.ToString()); } MessageBox.Show("تمت الاضافه بنجاح", "اضافه الفاتوره", MessageBoxButtons.OK, MessageBoxIcon.Information); // for empty all data to add new data ClearPrimaryBoxes(); }