private void comboBox2_DropDown(object sender, EventArgs e) { dtp = new DataTable(); if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Main.Properties.Settings.Default.Amdtbse_4ConnectionString); string SQL = ""; if (dgv.CurrentCell.ColumnIndex == 1) { SQL = "SELECT * FROM Prod_mgmt"; } SqlCeCommand cmd = new SqlCeCommand(SQL, conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); dtp.Load(dr); conn.Close(); } else { dtp = basql.Execute(Main.Amatrix.mgt, "SELECT * FROM Prod_mgmt", "Prod_mgmt", dtp); } comboBox2.Items.Clear(); foreach (DataRow dri in dtp.Rows) { try { comboBox2.Items.Add(dri.ItemArray[1].ToString()); } catch (Exception erty) { } } }
private void ok() { if (old == false) { try { loaddb(); if (lnktpe == 0 && dgv.RowCount == 0) { if (Main.Amatrix.acc == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Misc_DBConnectionString); SqlCeCommand cmd = new SqlCeCommand("INSERT INTO acc_linking VALUES('" + "KEY-" + DateTime.Now.ToString() + DateTime.Now.Ticks.ToString() + "','" + frbkk + "','" + lnktpe_str + "','" + dgvr.Cells[0].Value.ToString() + "','" + cbx.SelectedItem.ToString() + "')", conn); conn.Open(); cmd.ExecuteScalar(); conn.Close(); SqlCeConnection conn2 = new SqlCeConnection(Properties.Settings.Default.AmdtbseConnectionString); SqlCeCommand cmd2 = new SqlCeCommand("UPDATE invoice SET [Binded to Journal Entry] = '" + cbx.Text + "', [Binded to Journal] = '" + frbkk + "' WHERE [Invoice Reference Number (ID)] = '" + cbx.Text + "'", conn2); conn2.Open(); cmd2.ExecuteScalar(); conn2.Close(); } else { basql.Execute(Main.Amatrix.acc, "INSERT INTO acc_linking VALUES('" + "KEY-" + DateTime.Now.ToString() + DateTime.Now.Ticks.ToString() + "','" + frbkk + "','" + lnktpe_str + "','" + dgvr.Cells[0].Value.ToString() + "','" + cbx.SelectedItem.ToString() + "')", "acc_linking", dtp2); basql.Execute(Main.Amatrix.acc, "UPDATE invoice SET [Binded to Journal Entry] = '" + cbx.Text + "', [Binded to Journal] = '" + frbkk + "' WHERE [Invoice Reference Number (ID)] = '" + cbx.Text + "'", "invoice", dtp2); } loaddb(); if (lnktpe == 0) { if (frbkk == "salesbook") { acjrn.set_linked(0, "salesbook", dgv[4, 0].Value.ToString()); } else if (frbkk == "purchasebook") { acjrn.set_linked(0, "purchasebook", dgv[4, 0].Value.ToString()); } this.Close(); } } else { Am_err ner = new Am_err(); ner.tx("Cannot Enter More than One Invoice Entry per Journal Entry."); } } catch (Exception erty) { Am_err ner = new Am_err(); ner.tx("Amatrix was Unable to add the Specified Key"); } } else { this.Close(); } }
private void Init() { if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Amdtbse_3ConnectionString); SqlCeCommand cmd = new SqlCeCommand("SELECT [Employee First Name], [Employee Last Name] FROM Employ_payrll", conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); dt.Load(dr); dataGridView1.DataSource = dt; conn.Close(); } else { dt = basql.Execute(Main.Amatrix.mgt, "SELECT [Employee First Name], [Employee Last Name] FROM Employ_payrll", "Employ_payrll", dt); dataGridView1.DataSource = dt; } }
private void First_use_FormClosing(object sender, FormClosingEventArgs e) { try { scsql.Execute_Insert_Update(Properties.Settings.Default.Misc_DBConnectionString, "DELETE FROM co_nfo"); scsql.Execute_Insert_Update(Properties.Settings.Default.Misc_DBConnectionString, "INSERT INTO co_nfo VALUES('" + textBox2.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + textBox5.Text + "','" + textBox7.Text + "','" + textBox1.Text + "','" + textBox3.Text + "')"); if (Main.Amatrix.doc != "") { Base_ASQL.BASQL b = new Base_ASQL.BASQL(); DataTable dtpy = new DataTable(); b.Execute(Main.Amatrix.doc, "DELETE FROM co_nfo", "", dtpy); b.Execute(Main.Amatrix.doc, "INSERT INTO co_nfo VALUES('" + textBox2.Text + "', '" + textBox4.Text + "', '" + textBox6.Text + "','', '" + textBox5.Text + "','','','', '" + textBox7.Text + "','','" + "INF-" + DateTime.Now.ToString() + DateTime.Now.Ticks.ToString() + "')", "", dtpy); dtpy.Clear(); dtpy.Dispose(); } } catch (Exception erty) { Am_err ner = new Am_err(); ner.tx("Unable to Save Company Information Data. (" + erty.Message + ")"); e.Cancel = true; } }
private void get_IP_table() { try { DataTable dtp = new DataTable(); dtp = basql.Execute(Main.Amatrix.AMs, "SELECT * FROM AMS", "AMS", dtp); foreach (DataRow dr in dtp.Rows) { try { al_ips.Add(dr.ItemArray[0].ToString()); } catch (Exception errty) { } } //set my IP basql.Execute(Main.Amatrix.AMs, "INSERT INTO AMS values('" + Properties.Settings.Default.IP + "','')", "AMS", dtp); } catch (Exception erty) { MessageBox.Show(erty.StackTrace); } }
private void button2_Click(object sender, EventArgs e) { dtp1.Clear(); dtp3.Clear(); String SQL_String = "SELECT * FROM prod_bulk WHERE [Reference Number] = '" + textBox1.Text + "' OR [Bar Code Extension] = '" + textBox1.Text + "'"; if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Amdtbse_4ConnectionString); SqlCeCommand cmd = new SqlCeCommand(SQL_String, conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); dtp1.Load(dr); conn.Close(); } else { dtp1 = asql.Execute(Main.Amatrix.mgt, SQL_String, "prod_bulk", dtp1); } //Customers String SQL_String2 = "SELECT [Sold To], [Bar Code Extension], [Reference Number] FROM prod_bulk WHERE [Sold To] <> NULL AND [Bar Code Extension] = '" + textBox1.Text + "' OR [Reference Number] = '" + textBox1.Text + "'"; if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Amdtbse_4ConnectionString); SqlCeCommand cmd = new SqlCeCommand(SQL_String2, conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); dtp2.Load(dr); conn.Close(); } else { dtp2 = asql.Execute(Main.Amatrix.mgt, SQL_String2, "prod_bulk", dtp2); } dataGridView1.DataSource = dtp1; dataGridView3.DataSource = dtp2; }
private void init_db() { dtp.Clear(); string SQL = "SELECT * FROM prod_warranties WHERE [For Product] = '" + Main_ + "' AND [For Bulk] = '" + Sub + "'"; if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Amdtbse_4ConnectionString); SqlCeCommand cmd = new SqlCeCommand(SQL, conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); dtp.Load(dr); conn.Close(); } else { dtp = basql.Execute(Main.Amatrix.mgt, SQL, "prod_warranties", dtp); } dgv.DataSource = dtp; dgv.Columns[0].ReadOnly = true; dgv.Columns[4].ReadOnly = true; dgv.Columns[5].ReadOnly = true; }
private void button2_Click(object sender, EventArgs e) { if (Main.Amatrix.mgt == "") { SqlCeDataReader dr = scsql.Execute_DataReader(Properties.Settings.Default.Amdtbse_6ConnectionString, "DELETE FROM Product_Types WHERE [Type] = '" + dgv.CurrentCell.Value.ToString() + "'"); prod_typ_dtst.Product_Types.Rows.RemoveAt(dgv.CurrentRow.Index); } else { basql.Execute(Main.Amatrix.mgt, "DELETE FROM Product_Types WHERE [Type] = '" + dgv.CurrentCell.Value.ToString() + "'", "", prod_typ_dtst.Product_Types); prod_typ_dtst.Product_Types.Rows.RemoveAt(dgv.CurrentRow.Index); } dgv.CommitEdit(DataGridViewDataErrorContexts.Commit); }
private void init_db() { DataTable dtp = new DataTable(); if (Amatrix.mgt == "") { dtp = scsql.Execute(Properties.Settings.Default.Amdtbse_6ConnectionString, "SELECT * FROM Product_Units WHERE [Product ID] = '" + ID + "'"); } else { dtp = basql.Execute(Amatrix.mgt, "SELECT * FROM Product_Units WHERE [Product ID] = '" + ID + "'", "", dtp); } //load to GUI try { //cn.Text = dtp.Rows[0].ItemArray[1].ToString(); comboBox3.Text = dtp.Rows[0].ItemArray[2].ToString(); textBox1.Text = dtp.Rows[0].ItemArray[3].ToString(); exists = true; } catch (Exception erty) { } }
private void toolStripButton2_Click(object sender, EventArgs e) { if (radioButton2.Checked == false) { files_dtst.Clear(); SqlCeConnection conn = new SqlCeConnection(filesTableAdapter.Connection.ConnectionString); SqlCeCommand cmd = new SqlCeCommand("DELETE FROM Files WHERE [Serial] = " + dataGridView1[7, dataGridView1.CurrentRow.Index].Value, conn); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } else { basql.Execute(Main.Amatrix.doc, "DELETE FROM Files WHERE [Serial] = " + dataGridView1[7, dataGridView1.CurrentRow.Index].Value, "Files", files_dtst.Files); } }
private void bkk_DoWork(object sender, DoWorkEventArgs e) { dtp.Clear(); if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Amdtbse_3ConnectionString); SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Employ_payrll", conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); dtp.Load(dr); conn.Close(); } else { dtp = basql.Execute(Main.Amatrix.mgt, "SELECT * FROM Employ_payrll", "Employ_payrll", dtp); } }
private void button2_Click(object sender, EventArgs e) { foreach (DataGridViewRow dgvr in dgv.SelectedRows) { try { if (Amatrix.mgt == "") { scsql.Execute_Insert_Update(Properties.Settings.Default.Amdtbse_6ConnectionString, "DELETE FROM Suppliers WHERE [Supplier Name] = '" + dgvr.Cells[0].Value.ToString() + "'"); } else { basql.Execute(Amatrix.mgt, "DELETE FROM Suppliers WHERE [Supplier Name] = '" + dgvr.Cells[0].Value.ToString() + "'", "", amdtbse_6DataSet1.Suppliers); } dgv.Rows.Remove(dgvr); dgvr.Dispose(); } catch (Exception erty) { MessageBox.Show(erty.Message); } } }
private void init_db() { try { dtp.Clear(); string SQL = "SELECT * FROM prod_resent WHERE [For Product] = '" + mainprod + "' AND [For Bulk] = '" + subprod + "'"; if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Amdtbse_4ConnectionString); SqlCeCommand cmd = new SqlCeCommand(SQL, conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); dtp.Load(dr); conn.Close(); } else { dtp = basql.Execute(Main.Amatrix.mgt, SQL, "prod_resent", dtp); } dataGridView1.DataSource = dtp; } catch (Exception erty) { } }
private void button1_Click(object sender, EventArgs e) { int maxm = 0; double cst = 0; double tax = 0; string invce = ""; if (FROM == "customer managment" || FROM == "product managment" || FROM == "managment hr" || FROM == "logistical managment" || FROM == "project managment") { //insertintojournal if (checkBox2.Checked == true) { try { if (Main.Amatrix.acc == "") { SqlCeConnection mySqlConnection3 = new SqlCeConnection(Properties.Settings.Default.AmdtbseConnectionString); SqlCeCommand mySqlCommand3 = new SqlCeCommand("SELECT MAX([Serial Number]) FROM " + FORBOOK, mySqlConnection3); //mySqlCommand3.CommandText = "SELECT MAX([Serial Number]) FROM SalesBook"; mySqlConnection3.Open(); DataTable dtpy = new DataTable(); SqlCeDataReader dr = mySqlCommand3.ExecuteReader(); dtpy.Load(dr); maxm = Convert.ToInt32(dtpy.Rows[0].ItemArray[0]); maxm = maxm + 1; mySqlConnection3.Close(); mySqlCommand3.Dispose(); mySqlConnection3.Dispose(); dtpy.Clear(); dtpy.Dispose(); } else { DataTable dtpy = new DataTable(); basql.Execute(Main.Amatrix.acc, "SELECT MAX([Serial Number]) FROM " + FORBOOK, FORBOOK, dtpy); maxm = Convert.ToInt32(dtpy.Rows[0].ItemArray[0]); maxm = maxm + 1; dtpy.Clear(); dtpy.Dispose(); } } catch (Exception ery) { maxm = 1; } //SELECT product cost if (FROM != "managment hr" && FROM != "logistical managment" && FROM != "project managment") { if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Amdtbse_4ConnectionString); SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Prod_mgmt WHERE [Product ID Number] = '" + MAINPROD + "'", conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); dtp_prod_cost.Load(dr); conn.Close(); try { cst = Convert.ToDouble(dtp_prod_cost.Rows[0].ItemArray[5]); } catch (Exception erty) { } try { tax = Convert.ToDouble(dtp_prod_cost.Rows[0].ItemArray[6]); } catch (Exception ertty) { } } else { dtp_prod_cost = basql.Execute(Main.Amatrix.mgt, "SELECT * FROM Prod_mgmt WHERE [Product ID Number] = '" + MAINPROD + "'", "Prod_mgmt", dtp_prod_cost); try { cst = Convert.ToDouble(dtp_prod_cost.Rows[0].ItemArray[5]); } catch (Exception erty) { } try { tax = Convert.ToDouble(dtp_prod_cost.Rows[0].ItemArray[6]); } catch (Exception ertty) { } } } //insert String SQL = ""; if (comboBox1.Text.ToLower() == "general journal entry") { string s = "'Salary Payment'"; string i = "0"; if (FROM == "logistical managment") { cst = cost_; s = "'Logistics Expenditure'"; } if (FROM == "project managment") { i = revenue_.ToString(); s = "'Project dr. cr.'"; } SQL = "INSERT INTO journal VALUES('" + maxm.ToString() + "',getdate(), '" + MAINPROD + "', " + s + ",'','','False','" + cost_.ToString() + "','','"+ i +"','')"; } if (comboBox1.Text.ToLower() == "sales journal entry") { SQL = "INSERT INTO SalesBook VALUES('" + maxm.ToString() + "', '" + ID + "',getdate(), NULL, '', 'Sale of Product[" + MAINPROD + "\\" + PROD + "]', '0', '"+tax.ToString()+"', '" + cst.ToString() + "', '', '', '" + (cst+tax).ToString() + "', '')"; } if (comboBox1.Text.ToLower() == "purchase book entry") { SQL = "INSERT INTO PurchaseBook VALUES('" + maxm.ToString() + "', '',getdate(), '', 'Purchase of Product[" + MAINPROD + "\\" + PROD + "]', '0', '" + tax.ToString() + "', '0', '" + cst.ToString() + "', '" + (cst + tax).ToString() + "', '', '" + (cst + tax).ToString() + "', '')"; } //insert do... if (Main.Amatrix.acc == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.AmdtbseConnectionString); SqlCeCommand cmd = new SqlCeCommand(SQL, conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); conn.Close(); } else { DataTable dtpy = new DataTable(); basql.Execute(Main.Amatrix.acc, SQL, "", dtpy); dtpy.Clear(); dtpy.Dispose(); } } //invoices int maxm2 = 0; if (checkBox1.Checked == true) { if (Main.Amatrix.acc == "") { SqlCeConnection mySqlConnection3 = new SqlCeConnection(Properties.Settings.Default.AmdtbseConnectionString); SqlCeCommand mySqlCommand3 = new SqlCeCommand("SELECT MAX([Serial Number]) FROM invoice", mySqlConnection3); mySqlConnection3.Open(); DataTable dtpy = new DataTable(); SqlCeDataReader dr = mySqlCommand3.ExecuteReader(); dtpy.Load(dr); try { maxm2 = Convert.ToInt32(dtpy.Rows[0].ItemArray[0]); maxm2 = maxm2 + 1; } catch (Exception erty) { maxm2 = 1; } mySqlConnection3.Close(); mySqlCommand3.Dispose(); mySqlConnection3.Dispose(); dtpy.Clear(); dtpy.Dispose(); } else { DataTable dtpy = new DataTable(); dtpy = basql.Execute(Main.Amatrix.acc, "SELECT max([Serial Number]) FROM invoice", "invoice", dtpy); try { maxm2 = Convert.ToInt32(dtpy.Rows[0].ItemArray[0]); maxm2 = maxm2 + 1; } catch (Exception erty) { maxm2 = 1; } dtpy.Clear(); dtpy.Dispose(); } invce = "INVCE-" + DateTime.Now.ToString() + DateTime.Now.Ticks.ToString(); string sql = "INSERT INTO invoice VALUES('" + maxm2.ToString() + "', '" + invce + "',getdate(), '', '', '', '', '', '', '', '', '', '', '', '" + PROD + "', '" + MAINPROD + "\\" + PROD + "', '', " + cst.ToString() + ", '1', '1', '0', '" + cst.ToString() + "', '0', '0', '', '', '', '', '', '" + tax.ToString() + "', '" + (cst + tax).ToString() + "', '" + (cst +tax).ToString() + "', '','', '')"; if (Main.Amatrix.acc == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.AmdtbseConnectionString); SqlCeCommand cmd = new SqlCeCommand(sql, conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); conn.Close(); } else { DataTable dtpy = new DataTable(); basql.Execute(Main.Amatrix.acc, sql, "invoice", dtpy); dtpy.Clear(); dtpy.Dispose(); } } if (checkBox1.Checked == true && checkBox2.Checked == true) { if (comboBox1.Text == "General Journal Entry") { Am_err ner = new Am_err(); ner.tx("You Cannot Link General Journal Entries With Invoices"); } else { string s = ""; if (FORBOOK == "PurchaseBook") { s = "Purchase of Product[" + MAINPROD + "\\" + PROD + "]"; } else if (FORBOOK == "SalesBook") { s = "Sale of Product[" + MAINPROD + "\\" + PROD + "]"; } if (Main.Amatrix.acc == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.AmdtbseConnectionString); SqlCeCommand cmd = new SqlCeCommand("UPDATE " + FORBOOK + " SET [Invoice Number] = '" + invce + "' WHERE [Particulars] = '"+s+"'", conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); SqlCeCommand cmd2 = new SqlCeCommand("UPDATE invoice SET [Binded to Journal] = '" + FORBOOK.ToLower() + "' WHERE [Serial Number] = '" + maxm2.ToString() + "'", conn); dr = cmd2.ExecuteReader(); conn.Close(); SqlCeConnection conn3 = new SqlCeConnection(Properties.Settings.Default.Misc_DBConnectionString); SqlCeCommand cmd3 = new SqlCeCommand("INSERT INTO acc_linking VALUES('KEY-" + DateTime.Now.ToString() + DateTime.Now.Ticks.ToString() + "', '" + FORBOOK.ToLower() + "','invoice', '" + maxm + "', '" + invce + "')", conn3); conn3.Open(); dr = cmd3.ExecuteReader(); conn3.Close(); } else { DataTable dtpy = new DataTable(); basql.Execute(Main.Amatrix.acc, "UPDATE " + FORBOOK + " SET [Invoice Number] = '" + invce + "' WHERE [Particulars] = '"+s+"'", FORBOOK, dtpy); basql.Execute(Main.Amatrix.acc, "UPDATE invoice SET [Binded to Journal] = '" + FORBOOK.ToLower() + "' WHERE [Serial Number] = '" + maxm2.ToString() + "'", "invoice", dtpy); basql.Execute(Main.Amatrix.acc, "INSERT INTO acc_linking VALUES('KEY-" + DateTime.Now.ToString() + DateTime.Now.Ticks.ToString() + "', '" + FORBOOK.ToLower() + "','invoice', '" + maxm + "', '" + invce + "')", "acc_linking", dtpy); dtpy.Clear(); dtpy.Dispose(); } } } } this.Close(); }
private void bkk_work_DoWork(object sender, DoWorkEventArgs e) { string ConnString = Properties.Settings.Default.AmdtbseConnectionString; if (Main.Amatrix.acc == "") { dtst.Clear(); string SqlString = "Select * From journal ORDER BY [Serial Number] ASC"; using (SqlCeConnection conn = new SqlCeConnection(ConnString)) { using (SqlCeCommand cmd = new SqlCeCommand(SqlString, conn)) { cmd.CommandType = CommandType.Text; conn.Open(); SqlCeDataReader reader = cmd.ExecuteReader(); using (reader) { try { dtst.Load(reader, LoadOption.PreserveChanges, "journal"); dgv.DataSource = dtst.Tables[0]; } catch (Exception erty) { } } } } } else { dtst.Clear(); DataTable dtp = new DataTable(); dtp = basql.Execute(Main.Amatrix.acc, "Select * From journal ORDER BY [Serial Number] ASC", "journal", dtp); dtst.Tables.Add(dtp); dgv.DataSource = dtp; } if (Main.Amatrix.acc == "") { dtst2.Clear(); string SqlString2 = "Select * From invoice ORDER BY [Serial Number] ASC"; using (SqlCeConnection conn = new SqlCeConnection(ConnString)) { using (SqlCeCommand cmd = new SqlCeCommand(SqlString2, conn)) { cmd.CommandType = CommandType.Text; conn.Open(); SqlCeDataReader reader = cmd.ExecuteReader(); using (reader) { try { dtst2.Load(reader, LoadOption.PreserveChanges, "invoice"); dgv2.DataSource = dtst2.Tables[0]; } catch (Exception erty) { } } } } } else { dtst2.Clear(); DataTable dtp = new DataTable(); dtp = basql.Execute(Main.Amatrix.acc, "Select * From invoice ORDER BY [Serial Number] ASC", "invoice", dtp); dtst2.Tables.Add(dtp); dgv2.DataSource = dtp; } if (Main.Amatrix.acc == "") { dtst3.Clear(); string SqlString3 = "Select * From CashBook ORDER BY [Serial Number] ASC"; using (SqlCeConnection conn = new SqlCeConnection(ConnString)) { using (SqlCeCommand cmd = new SqlCeCommand(SqlString3, conn)) { cmd.CommandType = CommandType.Text; conn.Open(); SqlCeDataReader reader = cmd.ExecuteReader(); using (reader) { try { dtst3.Load(reader, LoadOption.PreserveChanges, "CashBook"); dgv3.DataSource = dtst3.Tables[0]; } catch (Exception erty) { } } } } } else { dtst3.Clear(); DataTable dtp = new DataTable(); dtp = basql.Execute(Main.Amatrix.acc, "Select * From CashBook ORDER BY [Serial Number] ASC", "CashBook", dtp); dtst3.Tables.Add(dtp); dgv3.DataSource = dtp; } if (Main.Amatrix.acc == "") { dtst4.Clear(); string SqlString4 = "Select * From SalesBook ORDER BY [Serial Number] ASC"; using (SqlCeConnection conn = new SqlCeConnection(ConnString)) { using (SqlCeCommand cmd = new SqlCeCommand(SqlString4, conn)) { cmd.CommandType = CommandType.Text; conn.Open(); SqlCeDataReader reader = cmd.ExecuteReader(); using (reader) { try { dtst4.Load(reader, LoadOption.PreserveChanges, "SalesBook"); dgv4.DataSource = dtst4.Tables[0]; } catch (Exception erty) { } } } } } else { dtst4.Clear(); DataTable dtp = new DataTable(); dtp = basql.Execute(Main.Amatrix.acc, "Select * From SalesBook ORDER BY [Serial Number] ASC", "SalesBook", dtp); dtst4.Tables.Add(dtp); dgv4.DataSource = dtp; } if (Main.Amatrix.acc == "") { dtst5.Clear(); string SqlString5 = "Select * From PurchaseBook ORDER BY [Serial Number] ASC"; using (SqlCeConnection conn = new SqlCeConnection(ConnString)) { using (SqlCeCommand cmd = new SqlCeCommand(SqlString5, conn)) { cmd.CommandType = CommandType.Text; conn.Open(); SqlCeDataReader reader = cmd.ExecuteReader(); using (reader) { try { dtst5.Load(reader, LoadOption.PreserveChanges, "PurchaseBook"); dgv5.DataSource = dtst5.Tables[0]; } catch (Exception erty) { } } } } } else { dtst5.Clear(); DataTable dtp = new DataTable(); dtp = basql.Execute(Main.Amatrix.acc, "Select * From PurchaseBook ORDER BY [Serial Number] ASC", "PurchaseBook", dtp); dtst5.Tables.Add(dtp); dgv5.DataSource = dtp; } }
public void tx(string for_hr, string FullName, string payment, string benefits, string bonuses, string overhrs, string tax, string payment_type, string payperday, string basis, string payno) { try { for_hr_ = for_hr; Fulln = FullName; overhours = overhrs; tax_ = tax; } catch (Exception erty) { } try { payment_ = Convert.ToDouble(payment); } catch (Exception erty) { } try { benefits_ = Convert.ToDouble(benefits); } catch (Exception erty) { } try { bonuses_ = Convert.ToDouble(bonuses); } catch (Exception erty) { } try { paypd = Convert.ToDouble(payperday); } catch (Exception erty) { } try { TOTAL = (payment_ + benefits_ + bonuses_) - Convert.ToDouble(tax_); } catch (Exception erty) { TOTAL = (payment_ + benefits_ + bonuses_) - 0; } //Evaluate Sick Days if (basis == "Daily Basis" || basis == "Monthly Basis") { if (DialogResult.Yes == MessageBox.Show("Automate Payrolls to Comply with Attendances (Attendance Managment)? ACTION REQUIRES AN ENTERED VALUE FOR 'Basic Employee Salary [Per Day]', IF NOT ENTERED WE ENCOURAGE YOU TO CLICK ON No.", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { try { int count = 0; DataTable tp = new DataTable(); string SQL1 = "SELECT * FROM Signs WHERE datepart(MM,[Employee Time In]) = datepart(MM, getdate()) AND datepart(YYYY, [Employee Time In]) = datepart(YYYY, getdate())"; if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.BSAMConnectionString); SqlCeCommand cmd = new SqlCeCommand(SQL1, conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); tp.Load(dr); count = tp.Rows.Count; conn.Close(); } else { tp = basql.Execute(Main.Amatrix.mgt, SQL1, "Signs", tp); count = tp.Rows.Count; } tp.Clear(); tp.Dispose(); if (count != 0 && paypd != 0) { double d1 = count * paypd; payment_ = d1; TOTAL = (payment_ + benefits_ + bonuses_) - Convert.ToDouble(tax_); } else { MessageBox.Show("Unable to Complete the Operation as one of the Following Conditions was Raised: the Field 'Basic Employee Salary [Per Day]' was Valued at 0 or, no Employee Time In/Out's were Recorded.", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error); } } catch (Exception erty) { } } } //Evaluate Sick Days END string SQL = "INSERT INTO Payrolls VALUES('PAYR-" + DateTime.Now.ToString() + DateTime.Now.Ticks.ToString() + "', '" + for_hr_ + "', '" + Fulln + "', '" + payment_.ToString() + "','','','" + tax + "','" + benefits_ + "','" + bonuses + "','" + payment_type + "','','" + DateTime.Now.ToString() + "','" + TOTAL.ToString() + "')"; if (Main.Amatrix.mgt == "") { SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Amdtbse_3ConnectionString); SqlCeCommand cmd = new SqlCeCommand(SQL, conn); conn.Open(); SqlCeDataReader dr = cmd.ExecuteReader(); conn.Close(); } else { DataTable dtpy = new DataTable(); basql.Execute(Main.Amatrix.mgt, SQL, "Payrolls", dtpy); dtpy.Clear(); dtpy.Dispose(); } tx(for_hr_); if (DialogResult.Yes == MessageBox.Show("Insert a Journal Value For the Salary Payment?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { mgmt_Linkto_acc loacc = new mgmt_Linkto_acc(); loacc.tx("Salary Payment For(" + FullName + " [" + for_hr + "]" + ")[Pay." + payno + "]", "", FullName + "[" + for_hr + "]", "managment hr", TOTAL, 0); } }