private bool ADD_Row() { try { for (int i = 0; i < dataGridView1.Rows.Count; i++) { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "INSERT INTO " + D.DataPharmacy + " Entry_Bond (IDOrder, MYear, Date, IDSupplier, NameSupplier, Note, TotalOrder, R_Barcode, R_ItemName, R_PriceParchase, R_PriceSales, R_Tax, R_Qty, R_DateItem, R_TotalRow, ID_User) VALUES (@IDOrder, @MYear, @Date, @IDSupplier, @NameSupplier, @Note, @TotalOrder, @R_Barcode, @R_ItemName, @R_PriceParchase, @R_PriceSales, @R_Tax, @R_Qty, @R_DateItem, @R_TotalRow, @ID_User)"; cmd.Parameters.AddWithValue("@IDOrder", textBox_Bond_No.Text); cmd.Parameters.AddWithValue("@MYear", textBox_Year.Text); cmd.Parameters.AddWithValue("@Date", dateTime_Bond_Date.Value); if (textBox_Supplier_No.Text == string.Empty) { cmd.Parameters.AddWithValue("@IDSupplier", "0"); } else { cmd.Parameters.AddWithValue("@IDSupplier", textBox_Supplier_No.Text); } cmd.Parameters.AddWithValue("@NameSupplier", textBox_Supplier_Name.Text); cmd.Parameters.AddWithValue("@Note", textBox_Note.Text); cmd.Parameters.AddWithValue("@TotalOrder", textBox_Total2_groupBox2.Text); cmd.Parameters.AddWithValue("@R_Barcode", dataGridView1.Rows[i].Cells[Clm_R_Barcode.Name].Value); cmd.Parameters.AddWithValue("@R_ItemName", dataGridView1.Rows[i].Cells[Clm_R_ItemName.Name].Value); cmd.Parameters.AddWithValue("@R_PriceParchase", dataGridView1.Rows[i].Cells[Clm_R_PriceParchase.Name].Value); cmd.Parameters.AddWithValue("@R_PriceSales", dataGridView1.Rows[i].Cells[Clm_R_PriceSales.Name].Value); cmd.Parameters.AddWithValue("@R_Tax", dataGridView1.Rows[i].Cells[Clm_R_Tax.Name].Value); cmd.Parameters.AddWithValue("@R_Qty", dataGridView1.Rows[i].Cells[Clm_R_Qty.Name].Value); cmd.Parameters.AddWithValue("@R_DateItem", convertDate.TODate(dataGridView1.Rows[i].Cells[Clm_R_DateItem.Name].Value.ToString())); cmd.Parameters.AddWithValue("@R_TotalRow", dataGridView1.Rows[i].Cells[Clm_R_TotalRow.Name].Value); cmd.Parameters.AddWithValue("@ID_User", Program.user_ID); cmd.ExecuteNonQuery(); con.Close(); } return(true); } catch (Exception ee) { MessageBox.Show("يرجى تصوير الخطأ ومراجعة مدير النظام ، شكرا" + ee.Message, "ERROR 1026 Entry_Bond", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
private void button1_Click(object sender, EventArgs e) { try { Select(); con.Open(); SqlCommand cmd = new SqlCommand(sqlSelect, con); if (checkBox1.Checked == false) { cmd.Parameters.AddWithValue("@UserID", textBox_Emp_No.Text); } if (checkBox2.Checked == false) { cmd.Parameters.AddWithValue("@Odate1", convertDate.TODate(dateTime_From_Date.Text)); cmd.Parameters.AddWithValue("@Odate2", convertDate.TODate(dateTime_To_Date.Text)); } SqlDataReader dr; dr = cmd.ExecuteReader(); if (dr.Read()) { textBox_Cash.Text = dr["cash"].ToString(); textBox_AP.Text = dr["AP"].ToString(); textBox_Credit.Text = dr["Credit"].ToString(); textBox_IN_Inc.Text = dr["IN_INC"].ToString(); textBox_Out_Inc.Text = dr["Out_INC"].ToString(); } dr.Close(); } catch (Exception ex) { } finally { con.Close(); } }
private void dataGridView1_DoubleClick(object sender, EventArgs e) { try { if (dataGridView1.Rows.Count > 0) { R_Barcode = dataGridView1.CurrentRow.Cells[clmR_Barcode.Name].Value.ToString(); R_ItemName = dataGridView1.CurrentRow.Cells[clmR_ItemName.Name].Value.ToString(); R_Qty = dataGridView1.CurrentRow.Cells[clm_R_Qty.Name].Value.ToString(); R_Tax = dataGridView1.CurrentRow.Cells[clmR_Tax.Name].Value.ToString(); R_PriceSales = dataGridView1.CurrentRow.Cells[clmR_PriceSales.Name].Value.ToString(); R_DateItem = dataGridView1.CurrentRow.Cells[clmR_DateItem.Name].Value.ToString(); R_PriceParchase = dataGridView1.CurrentRow.Cells[clm_R_PriceParchase.Name].Value.ToString(); if (SCR_POS == true) { d2 = Convert.ToDateTime(convertDate.TODate(R_DateItem)); TimeSpan t = d1 - d2; NrOfDays = t.TotalDays; if (NrOfDays > 0) { msg.Alert("عذرا المادة منتهية الصلاحية ، لا يمكنك بيع مادة منتهية الصلاحية", Form_Alert.enumType.Warning); return; } else { POS.pOS.dataGridView1.Rows.Add(POS.pOS.dataGridView1.Rows.Count + 1, R_Barcode, R_ItemName, 1, R_PriceSales, string.Empty, string.Empty, R_Tax, string.Empty, R_DateItem, R_PriceParchase); POS.pOS.ALLEventSum(); POS.pOS.TotalAmount(); if (POS.pOS.ItemMax(R_Barcode) >= Convert.ToDouble(R_Qty)) { msg.Alert("تنبيه : المادة وصلت حد الطلب" + " | الكمية المتبقية " + R_Qty, Form_Alert.enumType.Info); } if (NrOfDays > -31) { msg.Alert("تنبيه : المادة بالقرب من إنتهاء الصلاحية " + " | صالحه لتاريخ " + R_DateItem, Form_Alert.enumType.Info); } } SCR_POS = false; } } this.Close(); } catch (Exception ee) { MessageBox.Show("يرجى تصوير الخطأ ومراجعة مدير النظام ، شكرا" + ee.Message, "ERROR 1004 Grid_QauntityPOS", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void dataGridView1_Click(object sender, EventArgs e) { try { if (dataGridView1.Rows.Count > 0) { R_Barcode = dataGridView1.CurrentRow.Cells[Clm_R_Barcode.Name].Value.ToString(); R_ItemName = dataGridView1.CurrentRow.Cells[Clm_R_ItemName.Name].Value.ToString(); R_Qty = dataGridView1.CurrentRow.Cells[Clm_R_Qty.Name].Value.ToString(); R_Tax = dataGridView1.CurrentRow.Cells[Clm_R_Tax.Name].Value.ToString(); R_PriceSales = dataGridView1.CurrentRow.Cells[Clm_R_PriceSales.Name].Value.ToString(); R_DateItem = dataGridView1.CurrentRow.Cells[Clm_R_DateItem.Name].Value.ToString(); R_PriceParchase = dataGridView1.CurrentRow.Cells[clm_R_PriceParchase.Name].Value.ToString(); d2 = Convert.ToDateTime(convertDate.TODate(R_DateItem)); TimeSpan t = d1 - d2; NrOfDays = t.TotalDays; if (NrOfDays > 0) { msg.Alert("عذرا المادة منتهية الصلاحية ، لا يمكنك بيع مادة منتهية الصلاحية", Form_Alert.enumType.Warning); return; } else { POS.pOS.dataGridView1.Rows.Add(POS.pOS.dataGridView1.Rows.Count + 1, R_Barcode, R_ItemName, 1, R_PriceSales, string.Empty, string.Empty, R_Tax, string.Empty, R_DateItem, R_PriceParchase); if (POS.pOS.ItemMax(R_Barcode) >= Convert.ToDouble(R_Qty)) { msg.Alert("تنبيه : المادة وصلت حد الطلب" + " | الكمية المتبقية " + R_Qty, Form_Alert.enumType.Info); } if (NrOfDays > -31) { msg.Alert("تنبيه : المادة بالقرب من إنتهاء الصلاحية " + " | صالحه لتاريخ " + R_DateItem, Form_Alert.enumType.Info); } } } this.Close(); } catch { msg.Alert("يرجى تصوير الخطأ ومراجعة المبرمج ، شكرا" + "ERORR count2 1", Form_Alert.enumType.Error); } }
private bool ADD_Row_Trans() { try { for (int i = 0; i < dataGridView1.Rows.Count; i++) { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "INSERT INTO " + D.DataPharmacy + " i2_Trans (Order_No, Myear, Kind, Doc_Type, Screen_Code, Odate, status_Order, S_No, S_Name, TotalOrder, TotalDiscount, FlagDiscount, TotalAfterDiscount, R_Barcode, R_ItemName, R_PriceParchase, R_PriceSales, R_Tax, R_Qty, R_Bouns, R_DateItem, R_Discount, R_DiscountPresnt, R_TotalRow, Note, ID_User) VALUES (@Order_No, @Myear, @Kind, @Doc_Type, @Screen_Code, @Odate, @status_Order, @S_No, @S_Name, @TotalOrder, @TotalDiscount, @FlagDiscount, @TotalAfterDiscount, @R_Barcode, @R_ItemName, @R_PriceParchase, @R_PriceSales, @R_Tax, @R_Qty, @R_Bouns, @R_DateItem, @R_Discount, @R_DiscountPresnt, @R_TotalRow, @Note, @ID_User)"; cmd.Parameters.AddWithValue("@Order_No", textBox_Bond_No.Text); cmd.Parameters.AddWithValue("@Myear", textBox_Year.Text); cmd.Parameters.AddWithValue("@Kind", docType.Output); cmd.Parameters.AddWithValue("@Doc_Type", docType.Out_Bond); cmd.Parameters.AddWithValue("@Screen_Code", docType.Out_Bond); cmd.Parameters.AddWithValue("@Odate", dateTime_Bond_Date.Value); cmd.Parameters.AddWithValue("@status_Order", "0"); if (textBox_Supplier_No.Text == string.Empty) { cmd.Parameters.AddWithValue("@S_No", "0"); } else { cmd.Parameters.AddWithValue("@S_No", textBox_Supplier_No.Text); } cmd.Parameters.AddWithValue("@S_Name", textBox_Supplier_Name.Text); if (textBox_Total2_groupBox2.Text == string.Empty) { cmd.Parameters.AddWithValue("@TotalOrder", "0"); } else { cmd.Parameters.AddWithValue("@TotalOrder", textBox_Total2_groupBox2.Text); } cmd.Parameters.AddWithValue("@TotalDiscount", "0"); cmd.Parameters.AddWithValue("@FlagDiscount", "0"); if (textBox_Total2_groupBox2.Text == string.Empty) { cmd.Parameters.AddWithValue("@TotalAfterDiscount", "0"); } else { cmd.Parameters.AddWithValue("@TotalAfterDiscount", textBox_Total2_groupBox2.Text); } cmd.Parameters.AddWithValue("@R_Barcode", dataGridView1.Rows[i].Cells[Clm_R_Barcode.Name].Value); cmd.Parameters.AddWithValue("@R_ItemName", dataGridView1.Rows[i].Cells[Clm_R_ItemName.Name].Value); cmd.Parameters.AddWithValue("@R_PriceParchase", dataGridView1.Rows[i].Cells[Clm_R_PriceParchase.Name].Value); cmd.Parameters.AddWithValue("@R_PriceSales", dataGridView1.Rows[i].Cells[Clm_R_PriceSales.Name].Value); cmd.Parameters.AddWithValue("@R_Tax", dataGridView1.Rows[i].Cells[Clm_R_Tax.Name].Value); cmd.Parameters.AddWithValue("@R_Qty", dataGridView1.Rows[i].Cells[Clm_R_Qty.Name].Value); cmd.Parameters.AddWithValue("@R_Bouns", "0"); cmd.Parameters.AddWithValue("@R_DateItem", convertDate.TODate(dataGridView1.Rows[i].Cells[Clm_R_DateItem.Name].Value.ToString())); cmd.Parameters.AddWithValue("@R_Discount", "0"); cmd.Parameters.AddWithValue("@R_DiscountPresnt", "0"); cmd.Parameters.AddWithValue("@R_TotalRow", dataGridView1.Rows[i].Cells[Clm_R_TotalRow.Name].Value); cmd.Parameters.AddWithValue("@Note", textBox_Note.Text); cmd.Parameters.AddWithValue("@ID_User", Program.user_ID); cmd.ExecuteNonQuery(); con.Close(); } return(true); } catch (Exception ee) { MessageBox.Show("يرجى تصوير الخطأ ومراجعة مدير النظام ، شكرا" + ee.Message, "ERROR 1026 Out_Bond", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }