private void btnNewOrder_Click(object sender, EventArgs e) { txtOrderID.Text = cls1.last_orderID().Rows[0][0].ToString(); //تفريغ الصناديق Clear_TextBoxes(); txtCstomerID.Clear(); txtFname.Clear(); txtLname.Clear(); txtEmail.Clear(); txtMob.Clear(); txtDesc.Clear(); dt.Clear(); DGridProducts.Refresh(); txtSum_Totals.Clear(); btnNewOrder.Enabled = false; btnSaveOrder.Enabled = true; button1.Enabled = false; }
private void btnSaveOrder_Click(object sender, EventArgs e) { if (txtCstomerID.Text == string.Empty) { MessageBox.Show("!اختر عميل ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtDesc.Text == string.Empty) { MessageBox.Show("!ضع وصفاً للفاتورة ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtOrderID.Text == string.Empty) { MessageBox.Show("!لم تقم بإضافة فاتورة جديدة ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (DGridProducts.Rows.Count <= 1) { MessageBox.Show("!لم تقم بإضافة منتجات للفاتورة ", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } cls1.Add_Order(Convert.ToInt32(txtOrderID.Text), dateTimePicker1.Value, Convert.ToInt32(txtCstomerID.Text), txtDesc.Text, txtSalesman.Text); // اضافة منتجات الفاتورة for (int i = 0; i < DGridProducts.Rows.Count - 1; i++) { string x_idProduct = DGridProducts.Rows[i].Cells[0].Value.ToString(); int x_idOrder = Convert.ToInt32(txtOrderID.Text); int x_qte = Convert.ToInt32(DGridProducts.Rows[i].Cells[3].Value); string x_price = DGridProducts.Rows[i].Cells[2].Value.ToString(); double x_discount = Convert.ToDouble(DGridProducts.Rows[i].Cells[5].Value); string x_amount = DGridProducts.Rows[i].Cells[4].Value.ToString(); string x_Total_Amount = DGridProducts.Rows[i].Cells[6].Value.ToString(); cls1.Add_Orders_Details(x_idProduct, x_idOrder, x_qte, x_price, x_discount, x_amount, x_Total_Amount); } Clear_TextBoxes(); txtOrderID.Clear(); txtCstomerID.Clear(); txtFname.Clear(); txtLname.Clear(); txtEmail.Clear(); txtMob.Clear(); txtDesc.Clear(); txtSum_Totals.Clear(); dt.Clear(); DGridProducts.Refresh(); MessageBox.Show("Added Successfully !", "Add Order", MessageBoxButtons.OK, MessageBoxIcon.Information); btnNewOrder.Enabled = true; button1.Enabled = true; btnSaveOrder.Enabled = false; btnOrderPrint.Enabled = true; }
private void deleteRowToolStrip_Click(object sender, EventArgs e) { // الشرط حتى لاتتم محاولة حذف السطر الفاضي الموجود دائماً في الداتاجريد if (DGridProducts.CurrentRow.Cells[0].Value.ToString() == string.Empty) { return; } else { double x = Convert.ToDouble(DGridProducts.CurrentRow.Cells[6].Value.ToString()); /* من أجل تنقيصها من المجموع النهائي * .لأنه جحّش مايفعل يقبل مثل التعديل اللي بحدّث السعر النهائي لحالو */ DGridProducts.Rows.RemoveAt(DGridProducts.CurrentRow.Index); DGridProducts.Refresh(); txtSum_Totals.Text = (Convert.ToDouble(txtSum_Totals.Text) - x).ToString(); btnChoose.Focus(); //Calc_Sum_Totals(); } }
private void editToolStrip_Click(object sender, EventArgs e) { // هذا لأجل ألا يظهر خطأ عند محاولة تعديل السطر الفاضي if (DGridProducts.CurrentRow.Cells[0].Value.ToString() == string.Empty || txtTotalAmount.Text != string.Empty) { return; } else { txtPrductID.Text = DGridProducts.CurrentRow.Cells[0].Value.ToString(); txtProdName.Text = DGridProducts.CurrentRow.Cells[1].Value.ToString(); txtPrice.Text = DGridProducts.CurrentRow.Cells[2].Value.ToString(); txtQty.Text = DGridProducts.CurrentRow.Cells[3].Value.ToString(); txtAmount.Text = DGridProducts.CurrentRow.Cells[4].Value.ToString(); txtDiscount.Text = DGridProducts.CurrentRow.Cells[5].Value.ToString(); txtTotalAmount.Text = DGridProducts.CurrentRow.Cells[6].Value.ToString(); DGridProducts.Rows.RemoveAt(DGridProducts.CurrentRow.Index); DGridProducts.Refresh(); Calc_Sum_Totals(); txtQty.Focus(); } }
private void deleteAllToolStrip_Click(object sender, EventArgs e) { dt.Clear(); DGridProducts.Refresh(); btnChoose.Focus(); }