private void fillProdTypes() { try { Varibles.setConnection(); cmd = Varibles.getCommand(); String sqlCommand = "SELECT PRDTYP_ID, PRDTYP_NAME FROM merp.prod_types"; cmd.CommandText = sqlCommand; MySqlDataAdapter da = new MySqlDataAdapter(sqlCommand, Varibles.getConnection()); DataSet ds = new DataSet(); da.Fill(ds); cmd.ExecuteNonQuery(); cmbbx_ProdType.DisplayMember = "PRDTYP_NAME"; cmbbx_ProdType.ValueMember = "PRDTYP_ID"; cmbbx_ProdType.DataSource = ds.Tables[0]; cmbbx_ProdType.AutoCompleteMode = AutoCompleteMode.Suggest; cmbbx_ProdType.AutoCompleteSource = AutoCompleteSource.ListItems; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Varibles.closeConnection(); } }
private Double getSuppBalance(int SuppID) { Double blnce = -1; try { Varibles.setConnection(); cmd = Varibles.getCommand(); String query = "SELECT SPLR_BLNCE FROM merp.suppliers WHERE SPLR_NAME = " + SuppID; cmd.CommandText = query; reader = cmd.ExecuteReader(); while (reader.Read()) { blnce = reader.GetDouble("SPLR_BLNCE"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { reader.Close(); Varibles.closeConnection(); } return(blnce); }
private int getProdCount(int prdID) { int count = -1; try { Varibles.setConnection(); cmd = Varibles.getCommand(); String query = "SELECT PRD_BALANCE FROM merp.products WHERE PRD_ID = " + prdID; cmd.CommandText = query; reader = cmd.ExecuteReader(); count = -1; while (reader.Read()) { count = reader.GetInt32("PRD_BALANCE"); } return(count); } catch (Exception ex) { MessageBox.Show(ex.Message); return(count); } finally { reader.Close(); Varibles.closeConnection(); } }
private int countInStock(int prdId, double prdBuyPrice) { Varibles.setConnection(); cmd = Varibles.getCommand(); int count = 0; try { String query = "SELECT stock.count AS count FROM stock where stock.prod_id = '" + prdId + "' AND stock.buy_price = '" + prdBuyPrice + "'"; cmd.CommandText = query; reader = cmd.ExecuteReader(); while (reader.Read()) { count = reader.GetInt32("count"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { reader.Close(); Varibles.closeConnection(); } return(count); }
private void updateProdBlnc(int prodID, int Count, int opType) { try { Varibles.setConnection(); cmd = Varibles.getCommand(); String query; if (opType == 1) { query = "UPDATE `merp`.`products` SET `PRD_BALANCE`= PRD_BALANCE + '" + Count + "' WHERE `PRD_ID`='" + prodID + "'"; } else { query = "UPDATE `merp`.`products` SET `PRD_BALANCE`= PRD_BALANCE - '" + Count + "' WHERE `PRD_ID`='" + prodID + "'"; } cmd.CommandText = query; cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Varibles.closeConnection(); } }
public void resetClientNameComboBox() { try { Varibles.setConnection(); cmd = Varibles.getCommand(); String sqlCommand = "Select CLT_NAME FROM merp.clients"; cmd.CommandText = sqlCommand; MySqlDataAdapter da = new MySqlDataAdapter(sqlCommand, Varibles.getConnection()); DataSet ds = new DataSet(); da.Fill(ds); cmd.ExecuteNonQuery(); Varibles.closeConnection(); clientNameComboBox.DisplayMember = "CLT_NAME"; clientNameComboBox.ValueMember = "CLT_NAME"; clientNameComboBox.DataSource = ds.Tables[0]; clientNameComboBox.AutoCompleteMode = AutoCompleteMode.Suggest; clientNameComboBox.AutoCompleteSource = AutoCompleteSource.ListItems; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void deleteBtn_Click(object sender, EventArgs e) { try { Varibles.setConnection(); cmd = Varibles.getCommand(); String clientName = clientNameComboBox.Text; String condition = " CLT_NAME LIKE '" + clientName + "'"; cmd.CommandText = "DELETE FROM merp.clients" + " WHERE ( " + condition + " )"; cmd.ExecuteReader().Close(); Varibles.closeConnection(); MessageBox.Show("تم حذف العميل بنجاح"); resetClientNameComboBox(); clientNameComboBox.SelectedIndex = -1; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void editBtn_Click(object sender, EventArgs e) { try { Varibles.setConnection(); cmd = Varibles.getCommand(); String clientName = clientNameComboBox.Text; String condition = " CLT_NAME LIKE '" + clientName + "'"; String respName = clientRespTB.Text; String email = emailTB.Text; String tele = PhoneTB.Text; String mob = mobileTB.Text; String address = addressTB.Text; cmd.CommandText = "UPDATE merp.clients" + " SET CLT_RespName = '" + respName + "' , CLT_EMAIL = '" + email + "' , CLT_TELE = '" + tele + "' , CLT_MOB = '" + mob + "' , CLT_ADRS = '" + address + "' " + " WHERE ( " + condition + " )"; cmd.ExecuteReader().Close(); Varibles.closeConnection(); MessageBox.Show("تم اجراء التعديل بنجاح"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void FilterByInvTypeAllAndReturnSaleOnly() { DateTime date1 = new DateTime(dtp_from.Value.Year, dtp_from.Value.Month, dtp_from.Value.Day, 0, 0, 0); DateTime date2 = new DateTime(dtp_to.Value.Year, dtp_to.Value.Month, dtp_to.Value.Day, 23, 59, 59); try { String query = "SELECT INVLOG_PROD_ID, PRD_NAME, PRDTYP_NAME, PRD_WHLSALEPRICE, " + "PRD_SCTRPRICE, PRD_BUYPRICE, INVLOG_DATE, INVLOG_DESC, " + "INVLOG_OUTCOUNT, INVLOG_INCOUNT, INVLOG_INV_ID , current_buy_price , current_sell_price " + " FROM merp.inventory_log, merp.products, merp.prod_types , merp.invoices " + "WHERE INVLOG_PROD_ID = PRD_ID AND PRD_TYPE_ID = PRDTYP_ID AND inventory_log.INVLOG_INV_ID = invoices.INV_ID AND inventory_log.invoice_type = invoices.INV_TYPE_ID AND inventory_log.invoice_type = '" + SellReturnType + "'AND INVLOG_DATE >= '" + date1.ToString("yyyy-MM-dd HH:mm:ss") + "' AND INVLOG_DATE <= '" + date2.ToString("yyyy-MM-dd HH:mm:ss") + "' ORDER BY INVLOG_DATE ASC "; cmd.CommandText = query; MySqlDataAdapter da = new MySqlDataAdapter(query, Varibles.getConnection()); DataSet ds = new DataSet(); da.Fill(ds); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public SalesReportForm() { InitializeComponent(); this.BackgroundImageLayout = ImageLayout.Stretch; this.Icon = Properties.Resources.merp1_ExR_icon; Varibles.setConnection(); cmd = Varibles.getCommand(); }
private void login() { try { Varibles.setConnection(); cmd = Varibles.getCommand(); String username = userNametextBox.Text; String pass = PasstextBox.Text; if (username == "MMM" && pass == "M123M123M") { DBConfiguration form = new DBConfiguration(); this.Hide(); form.ShowDialog(); this.Close(); } else { String condition = "USR_NAME LIKE '" + username + "' AND " + "USR_PASS LIKE '" + pass + "' "; cmd.CommandText = "SELECT USR_NAME , USR_ID" + " FROM merp.users" + " WHERE ( " + condition + " )"; reader = cmd.ExecuteReader(); int usr_id = 0; while (reader.Read()) { usr_id = reader.GetInt32("USR_ID"); break; } Varibles.setUserId(usr_id); if (reader.HasRows) { MainForm form = new MainForm(); this.Hide(); form.ShowDialog(); this.Close(); } else { MessageBox.Show("اسم المستخدم او كلمة المرور خاطئة"); } reader.Close(); Varibles.closeConnection(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void populateGrid() { try { Varibles.setConnection(); cmd = Varibles.getCommand(); DateTime date1 = new DateTime(dtp_from.Value.Year, dtp_from.Value.Month, dtp_from.Value.Day, 0, 0, 0); DateTime date2 = new DateTime(dtp_to.Value.Year, dtp_to.Value.Month, dtp_to.Value.Day, 23, 59, 59); String query = "SELECT PYMNTP_SPPLRID, PYMNTP_ID, SPLR_NAME, PYMNT_BANKNAME, PYMNT_BANKBRNCH, PYMNT_ACCNO, PYMNT_PPRNO, " + "PYMNT_RLSEDATE, PYMNT_ENDDATE, PYMNT_PPRTYPE, PYMNT_AMNT FROM merp.payment_papers, " + "merp.suppliers WHERE PYMNTP_SPPLRID = SPLR_ID AND PYMNT_STATE = '" + state + "' AND " + "PYMNT_RLSEDATE <= '" + date2.ToString("yyyy-MM-dd HH:mm:ss") + "' AND PYMNT_RLSEDATE >= '" + date1.ToString("yyyy-MM-dd HH:mm:ss") + "' ;"; cmd.CommandText = query; reader = cmd.ExecuteReader(); String bankName, bankbranch, accNo, pprNo, pprType, SpplrName; int paymentID, suppId; Double Amount; DateTime releaseDate, EndDate; dGridV_InvenLog.Rows.Clear(); while (reader.Read()) { suppId = reader.GetInt32("PYMNTP_SPPLRID"); bankName = reader.GetString("PYMNT_BANKNAME"); bankbranch = reader.GetString("PYMNT_BANKBRNCH"); accNo = reader.GetString("PYMNT_ACCNO"); pprNo = reader.GetString("PYMNT_PPRNO"); pprType = reader.GetString("PYMNT_PPRTYPE"); SpplrName = reader.GetString("SPLR_NAME"); Amount = reader.GetDouble("PYMNT_AMNT"); releaseDate = reader.GetDateTime("PYMNT_RLSEDATE"); EndDate = reader.GetDateTime("PYMNT_ENDDATE"); paymentID = reader.GetInt32("PYMNTP_ID"); dGridV_InvenLog.Rows.Add(suppId, SpplrName, bankName, bankbranch, accNo, pprNo, releaseDate, EndDate, pprType, Amount, paymentID); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { reader.Close(); Varibles.closeConnection(); } calcTotal(); }
private void Activation_Load(object sender, EventArgs e) { // MessageBox.Show(Varibles.getDBServerName() + " " + Varibles.getDBUserID() + " " + Varibles.getDBPassword() + " " + Varibles.getDBPort()); serverTextBox.Text = Varibles.getDBServerName(); useridTextBox.Text = Varibles.getDBUserID(); passwordTextBox.Text = Varibles.getDBPassword(); portTextBox.Text = Varibles.getDBPort(); }
private void btn_save_Click(object sender, EventArgs e) { String bankName, bankbranch, accNo, pprNo, pprType; Int32 SpplrID; Double Amount; DateTime releaseDate, EndDate; try { foreach (DataGridViewRow i in dGridV_InvenLog.Rows) { try { Varibles.setConnection(); cmd = Varibles.getCommand(); bankName = Convert.ToString(i.Cells["clmn_BNKName"].Value); bankbranch = Convert.ToString(i.Cells["clmn_BNKBranch"].Value); accNo = Convert.ToString(i.Cells["clmn_AccNo"].Value); pprNo = Convert.ToString(i.Cells["clmn_PprNo"].Value); pprType = Convert.ToString(i.Cells["clmn_pprType"].Value); SpplrID = Convert.ToInt32(i.Cells["spplrID"].Value); Amount = Convert.ToDouble(i.Cells["clmn_Amnt"].Value); releaseDate = Convert.ToDateTime(i.Cells["clmn_ReleaseDate"].Value);; EndDate = Convert.ToDateTime(i.Cells["clmn_endDate"].Value); String query = "INSERT INTO `merp`.`payment_papers` (`PYMNTP_SPPLRID`, `PYMNT_BANKNAME`, `PYMNT_BANKBRNCH`, " + "`PYMNT_ACCNO`, `PYMNT_PPRNO`, `PYMNT_RLSEDATE`, " + "`PYMNT_ENDDATE`, `PYMNT_PPRTYPE`, `PYMNT_AMNT`) " + "VALUES ('" + SpplrID + "', '" + bankName + "', '" + bankbranch + "', '" + accNo + "', '" + pprNo + "', '" + releaseDate.ToString("yyyy-MM-dd HH:mm:ss") + "', " + "'" + EndDate.ToString("yyyy-MM-dd HH:mm:ss") + "', '" + pprType + "', '" + Amount + "')"; cmd.CommandText = query; cmd.ExecuteNonQuery(); Varibles.closeConnection(); DecSupplier(SpplrID, Amount); } catch (Exception ex) { MessageBox.Show(ex.Message); Varibles.closeConnection(); } finally { } } MessageBox.Show("العملية تمت بنجاح"); dGridV_InvenLog.Rows.Clear(); } catch (SystemException ex) { MessageBox.Show("Error " + ex.Message); } }
public RecordTreasury() { InitializeComponent(); this.BackgroundImageLayout = ImageLayout.Stretch; this.Icon = Properties.Resources.merp1_ExR_icon; Varibles.setConnection(); cmd = Varibles.getCommand(); te = new TreasuryEntry(); fillTreasuryEntryTypes(); }
private void usersComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (usersComboBox.Text != "") { try { string usrPassword = ""; int usrID = Convert.ToInt32(usersComboBox.SelectedValue); Varibles.setConnection(); cmd = Varibles.getCommand(); String query = "SELECT USR_PASS FROM merp.users WHERE USR_ID = '" + usrID + "' ;"; cmd.CommandText = query; reader = cmd.ExecuteReader(); while (reader.Read()) { try { usrPassword = reader.GetString("USR_PASS"); } catch (Exception ex) { usrPassword = ""; } } passTextBox.Text = usrPassword; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Varibles.closeConnection(); } try { setPermissionsFalse(); setPermissions(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("برجاء إدحال اسم الستخدم"); } }
private void populateGrid() { try { Varibles.setConnection(); cmd = Varibles.getCommand(); DateTime date1 = new DateTime(dtp_from.Value.Year, dtp_from.Value.Month, dtp_from.Value.Day, 0, 0, 0); DateTime date2 = new DateTime(dtp_to.Value.Year, dtp_to.Value.Month, dtp_to.Value.Day, 23, 59, 59); String query = "SELECT RCVP_CLNT_ID, RCVP_ID, CLT_NAME, RCVP_BANKNAME, RCVP_BANKBRNCH, RCVP_ACCNO, RCVP_PPRNO, RCVP_RELDATE, RCVP_ENDDATE, RCVP_PPRTYPE, RCVP_AMNT" + " FROM merp.receivable_papers, merp.clients WHERE RCVP_CLNT_ID = CLT_ID AND RCVP_STATE = " + state + " AND " + " RCVP_RELDATE >= '" + date1.ToString("yyyy-MM-dd HH:mm:ss") + "' AND RCVP_RELDATE <= '" + date2.ToString("yyyy-MM-dd HH:mm:ss") + "' ;"; cmd.CommandText = query; reader = cmd.ExecuteReader(); String bankName, bankbranch, accNo, pprNo, pprType, SpplrName; Int32 pprID, clntID; Double Amount; DateTime releaseDate, EndDate; dGridV_InvenLog.Rows.Clear(); while (reader.Read()) { bankName = reader.GetString("RCVP_BANKNAME"); bankbranch = reader.GetString("RCVP_BANKBRNCH"); accNo = reader.GetString("RCVP_ACCNO"); pprNo = reader.GetString("RCVP_PPRNO"); pprType = reader.GetString("RCVP_PPRTYPE"); SpplrName = reader.GetString("CLT_NAME"); Amount = reader.GetDouble("RCVP_AMNT"); releaseDate = reader.GetDateTime("RCVP_RELDATE"); EndDate = reader.GetDateTime("RCVP_ENDDATE"); pprID = reader.GetInt32("RCVP_ID"); clntID = reader.GetInt32("RCVP_CLNT_ID"); dGridV_InvenLog.Rows.Add(clntID, SpplrName, bankName, bankbranch, accNo, pprNo, releaseDate, EndDate, pprType, Amount, pprID); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { reader.Close(); Varibles.closeConnection(); } calcTotal(); }
private void updateStock(int prdId, int prdBalance, double prdBuyPrice) { Varibles.setConnection(); cmd = Varibles.getCommand(); String query = "Update stock set stock.count = '" + prdBalance + "' where stock.prod_id = '" + prdId + "' AND stock.buy_price = '" + prdBuyPrice + "'"; cmd.CommandText = query; cmd.ExecuteNonQuery(); Varibles.closeConnection(); }
private void deleteFromStock(int prdId, double prdBuyPrice) { Varibles.setConnection(); cmd = Varibles.getCommand(); String query = "Delete From stock where stock.prod_id = '" + prdId + "' AND stock.buy_price = '" + prdBuyPrice + "'"; cmd.CommandText = query; cmd.ExecuteNonQuery(); Varibles.closeConnection(); }
private void setPermissions() { try { int usrID = Convert.ToInt32(usersComboBox.SelectedValue); Varibles.setConnection(); cmd = Varibles.getCommand(); String query = "SELECT * FROM merp.usr_prm WHERE PRMUSR_USR_ID = '" + usrID + "' ;"; cmd.CommandText = query; reader = cmd.ExecuteReader(); while (reader.Read()) { int prm_ID = 0; try { prm_ID = reader.GetInt32("PRMUSR_PRM_ID"); int counter = 0; for (int i = 0; i < userPermTreeView.Nodes.Count; i++) { for (int j = 0; j < userPermTreeView.Nodes[i].Nodes.Count; j++) { if (counter == prm_ID) { userPermTreeView.Nodes[i].Nodes[j].Checked = true; userPermTreeView.Nodes[i].Checked = true; userPermTreeView.Nodes[i].Expand(); } counter++; } } } catch (Exception ex) { prm_ID = 0; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Varibles.closeConnection(); } }
private void confirmOldPassBtn_Click(object sender, EventArgs e) { if (usernameTB.Text == "") { usernameTB.Focus(); MessageBox.Show("من فضلك إستكمل البيانات المطلوبة"); return; } ; if (passTB.Text == "") { passTB.Focus(); MessageBox.Show("من فضلك إستكمل البيانات المطلوبة"); return; } ; try { Varibles.setConnection(); cmd = Varibles.getCommand(); String username = usernameTB.Text; String pass = passTB.Text; String condition = "USR_NAME LIKE '" + username + "' AND " + "USR_PASS LIKE '" + pass + "' AND USR_ID = " + "1"; cmd.CommandText = "SELECT USR_NAME" + " FROM merp.users" + " WHERE ( " + condition + " )"; reader = cmd.ExecuteReader(); if (reader.HasRows) { this.groupBox2.Visible = true; this.Height = 424; } else { MessageBox.Show("اسم المستخدم او كلمة المرور خاطئة"); this.groupBox2.Visible = false; this.Height = 234; } reader.Close(); Varibles.closeConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public InventoryLog() { InitializeComponent(); this.BackgroundImageLayout = ImageLayout.Stretch; this.Icon = Properties.Resources.merp1_ExR_icon; Varibles.setConnection(); cmd = Varibles.getCommand(); fillProdTypes(); cmbbx_ProdType.SelectedIndex = -1; }
private void insertInStock(int prdId, int prdBalance, double prdBuyPrice) { Varibles.setConnection(); cmd = Varibles.getCommand(); String query = "Insert Into stock (stock.prod_id, stock.count , stock.buy_price ) " + "VALUES ( " + prdId + " , " + prdBalance + " , " + prdBuyPrice + " )"; cmd.CommandText = query; cmd.ExecuteNonQuery(); Varibles.closeConnection(); }
private void fillProdTypes() { /* * cmbbx_ProdType.Items.Clear(); * * String query = "SELECT PRDTYP_ID, PRDTYP_NAME FROM merp.prod_types"; * cmd.CommandText = query; * * reader = cmd.ExecuteReader(); * * * * * while (reader.Read()) * { * * * prodTypes.Add(new ComboboxItem(reader.GetString(1), reader.GetInt32(0))); * * //cmbbx_NewProdType.Items.Add(item); * } * reader.Close(); * */ try { String sqlCommand = "SELECT PRDTYP_ID, PRDTYP_NAME FROM merp.prod_types"; cmd.CommandText = sqlCommand; MySqlDataAdapter da = new MySqlDataAdapter(sqlCommand, Varibles.getConnection()); DataSet ds = new DataSet(); da.Fill(ds); cmd.ExecuteNonQuery(); cmbbx_ProdType.DisplayMember = "PRDTYP_NAME"; cmbbx_ProdType.ValueMember = "PRDTYP_ID"; cmbbx_ProdType.DataSource = ds.Tables[0]; cmbbx_ProdType.AutoCompleteMode = AutoCompleteMode.Suggest; cmbbx_ProdType.AutoCompleteSource = AutoCompleteSource.ListItems; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void activateBtn_Click(object sender, EventArgs e) { if (Varibles.MD5(macAddress) == activateCodeTB.Text) { Varibles.setActivated(); this.Hide(); this.Close(); MessageBox.Show("لقد تم تفعيل البرنامج بنجاح"); } else { MessageBox.Show("كود التفعيل غير صحيح"); activateCodeTB.Focus(); } }
private void IncSupplier(int SuppID, Double amount) { try { Varibles.setConnection(); cmd = Varibles.getCommand(); String query = "UPDATE `merp`.`suppliers` SET `SPLR_BLNCE`= SPLR_BLNCE + " + amount + " WHERE `SPLR_ID`='" + SuppID + "'"; cmd.CommandText = query; cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); }finally{ Varibles.closeConnection(); } }
private void LoginForm_Load(object sender, EventArgs e) { if (!Varibles.getValidConnection()) { try { DBConfiguration form = new DBConfiguration(); this.Hide(); form.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public ProductAdditionForm() { InitializeComponent(); this.BackgroundImageLayout = ImageLayout.Stretch; this.Icon = Properties.Resources.merp1_ExR_icon; this.MaximizeBox = false; Varibles.setConnection(); cmd = Varibles.getCommand(); fillProdTypes(); cmbbx_NewProdType.SelectedIndex = -1; showAll(false); loadCode(); }
private void fillAllPayables() { try { Varibles.setConnection(); cmd = Varibles.getCommand(); DateTime date1 = new DateTime(dtp_from.Value.Year, dtp_from.Value.Month, dtp_from.Value.Day, 0, 0, 0); DateTime date2 = new DateTime(dtp_to.Value.Year, dtp_to.Value.Month, dtp_to.Value.Day, 23, 59, 59); String query = "SELECT CLT_NAME , TE_BLNCE, TE_IN, TE_OUT, TE_CMMTS, TE_DATE FROM merp.treasuryentries , merp.clients " + " WHERE TE_CLNT_ID = CLT_ID AND TE_CLNT_ID is not NULL AND TE_DATE <= '" + date2.ToString("yyyy-MM-dd HH:mm:ss") + "' AND TE_DATE >= '" + date1.ToString("yyyy-MM-dd HH:mm:ss") + "' ;"; cmd.CommandText = query; reader = cmd.ExecuteReader(); Double PaidHim, PaidME, Balance; DateTime InvDate; String Comments, clientName; while (reader.Read()) { clientName = reader.GetString("CLT_NAME"); PaidME = reader.GetDouble("TE_IN");; PaidHim = reader.GetDouble("TE_OUT"); Balance = reader.GetDouble("TE_BLNCE"); InvDate = reader.GetDateTime("TE_DATE"); Comments = reader.GetString("TE_CMMTS"); dGridV_InvenLog.Rows.Add(Balance, clientName, PaidME, PaidHim, "اذن دفع", InvDate, Comments); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { reader.Close(); Varibles.closeConnection(); } }
private void fillAllInvoices() { try { Varibles.setConnection(); cmd = Varibles.getCommand(); DateTime date1 = new DateTime(dtp_from.Value.Year, dtp_from.Value.Month, dtp_from.Value.Day, 0, 0, 0); DateTime date2 = new DateTime(dtp_to.Value.Year, dtp_to.Value.Month, dtp_to.Value.Day, 23, 59, 59); String query = "SELECT CLT_NAME , INV_CRNTBLNCE, INV_TOTAL, INV_DATE FROM merp.invoices , merp.clients WHERE" + " CLT_ID = INV_CLNT AND INV_DATE <= '" + date2.ToString("yyyy-MM-dd HH:mm:ss") + "' AND INV_DATE >= '" + date1.ToString("yyyy-MM-dd HH:mm:ss") + "' AND INV_CLNT is not NULL ;"; cmd.CommandText = query; reader = cmd.ExecuteReader(); Double For, Against, Balance; DateTime InvDate; String clientName; while (reader.Read()) { clientName = reader.GetString("CLT_NAME"); Against = reader.GetDouble("INV_TOTAL"); For = 0; Balance = reader.GetDouble("INV_CRNTBLNCE"); InvDate = reader.GetDateTime("INV_DATE"); dGridV_InvenLog.Rows.Add(Balance, clientName, For, Against, "فاتوره", InvDate, ""); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { reader.Close(); Varibles.closeConnection(); } }