private void clnt_delete_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("This option can remove a some rows from another table. Are you sure?", "caption", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { int clnt_id1 = Int32.Parse(client_id.Text); Client clnt_del = sdb.Clients.Single(x => x.client_id == clnt_id1); while (sdb.Projects.SingleOrDefault(x => x.client == clnt_id1) != null) { Project prjct = sdb.Projects.Single(x => x.client == clnt_id1); sdb.Projects.DeleteOnSubmit(prjct); sdb.SubmitChanges(); this.projectTableAdapter.Fill(this.accountingDBDataSet.Project); } sdb.Clients.DeleteOnSubmit(clnt_del); sdb.SubmitChanges(); this.clientTableAdapter2.Fill(this.accountingDBDataSet5.Client); } } else if (result == DialogResult.No) { } }
private void emp_delete_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { int emp_id1 = Int32.Parse(emp_id.Text); Employee emp_del = sdb.Employees.Single(x => x.emp_id == emp_id1); sdb.Employees.DeleteOnSubmit(emp_del); sdb.SubmitChanges(); this.employeeTableAdapter3.Fill(this.accountingDBDataSet5.Employee); } }
private void accnt_delete_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { int accnt_id1 = Int32.Parse(acc_id.Text); Account accnt_del = sdb.Accounts.Single(x => x.acc_id == accnt_id1); sdb.Accounts.DeleteOnSubmit(accnt_del); sdb.SubmitChanges(); this.accountsTableAdapter.Fill(this.accountingDBDataSet.Accounts); } }
private void trans_update_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { int id = Int32.Parse(trans_id.Text); Transaction trans = sdb.Transactions.SingleOrDefault(x => x.trans_id == id); trans.trans_id = Int32.Parse(trans_id.Text); trans.trans_date = DateTime.Parse(trans_date.Text); trans.donor_id = Int32.Parse(donor_id.Text); trans.rcvr_id = Int32.Parse(rcvr_id.Text); trans.amount = Int32.Parse(amount.Text); sdb.SubmitChanges(); this.transactionsTableAdapter.Fill(this.accountingDBDataSet.Transactions); } }
private void accnt_update_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { int id = Int32.Parse(acc_id.Text); Account accnt = sdb.Accounts.SingleOrDefault(x => x.acc_id == id); accnt.acc_id = Int32.Parse(acc_id.Text); accnt.acc_hd = acc_hd.Text; accnt.rept_hd = rept_hd.Text; accnt.vchr_hd = vchr_hd.Text; accnt.bill_amnt = float.Parse(bill_amnt.Text); sdb.SubmitChanges(); this.accountsTableAdapter.Fill(this.accountingDBDataSet.Accounts); } }
private void trans_save_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { Transaction trans = new Transaction(); trans.trans_id = Int32.Parse(trans_id.Text); trans.trans_date = DateTime.Parse(trans_date.Text); trans.donor_id = Int32.Parse(donor_id.Text); trans.rcvr_id = Int32.Parse(rcvr_id.Text); trans.amount = float.Parse(amount.Text); sdb.Transactions.InsertOnSubmit(trans); sdb.SubmitChanges(); this.transactionsTableAdapter.Fill(this.accountingDBDataSet.Transactions); MessageBox.Show("Data Inserted!"); } }
private void accnt_save_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { Account accnt = new Account(); accnt.acc_id = Int32.Parse(acc_id.Text); accnt.acc_hd = acc_hd.Text; accnt.rept_hd = rept_hd.Text; accnt.vchr_hd = vchr_hd.Text; accnt.bill_amnt = float.Parse(bill_amnt.Text); sdb.Accounts.InsertOnSubmit(accnt); sdb.SubmitChanges(); this.accountsTableAdapter.Fill(this.accountingDBDataSet.Accounts); MessageBox.Show("Data Inserted!"); } }
private void clnt_update_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { int id = Int32.Parse(client_id.Text); Client clnt = sdb.Clients.SingleOrDefault(x => x.client_id == id);; clnt.client_id = Int32.Parse(client_id.Text); clnt.clent_name = clent_name.Text; clnt.client_address = client_address.Text; clnt.phone_no = phn_no.Text; clnt.mail = emp_mail.Text; clnt.client_picture = client_pictureBox.ImageLocation; sdb.SubmitChanges(); this.clientTableAdapter2.Fill(this.accountingDBDataSet5.Client); } }
private void prjct_delete_Click(object sender, EventArgs e) { try { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { int prjct_id1 = Int32.Parse(prjct_id.Text); Project prjct_del = sdb.Projects.Single(x => x.prjct_id == prjct_id1); sdb.Projects.DeleteOnSubmit(prjct_del); sdb.SubmitChanges(); this.projectTableAdapter.Fill(this.accountingDBDataSet.Project); } } catch (SqlException) { MessageBox.Show("SQL Exception. Maybe you are trying to delete a primary key value that references another tables foreign key!!!"); } }
private void emp_save_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { Employee emp = new Employee(); emp.emp_id = Int32.Parse(emp_id.Text); emp.emp_name = emp_name.Text; emp.designation = design.Text; emp.joindate = DateTime.Parse(joindate.Text); emp.basic_sal = float.Parse(basic.Text); emp.receivable = float.Parse(rcvbl.Text); emp.address = address.Text; emp.phone_no = phn_no.Text; emp.mail = emp_mail.Text; emp.emp_picture = emp_pictureBox.ImageLocation; emp.dept_name = dept_name.Text; sdb.Employees.InsertOnSubmit(emp); sdb.SubmitChanges(); this.employeeTableAdapter3.Fill(this.accountingDBDataSet5.Employee); MessageBox.Show("Data Inserted!"); } }
private void clnt_save_Click(object sender, EventArgs e) { try { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { Client clnt = new Client(); clnt.client_id = Int32.Parse(client_id.Text); clnt.clent_name = clent_name.Text; clnt.client_address = client_address.Text; clnt.phone_no = phone_no.Text; clnt.mail = cl_mail.Text; clnt.client_picture = client_pictureBox.ImageLocation; sdb.Clients.InsertOnSubmit(clnt); sdb.SubmitChanges(); this.clientTableAdapter2.Fill(this.accountingDBDataSet5.Client); MessageBox.Show("Data Inserted!"); } }catch (SqlException) { MessageBox.Show("SQL Exception"); } }
private void prjct_save_Click(object sender, EventArgs e) { try{ using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { Project prjct = new Project(); prjct.prjct_id = Int32.Parse(prjct_id.Text); prjct.prjct_name = prjct_name.Text; prjct.prjct_status = prjct_status.Text; prjct.curr_amount = float.Parse(curr_amount.Text); prjct.prjct_exp = float.Parse(prjct_exp1.Text); prjct.rc_able = float.Parse(rc_able.Text); prjct.client = Int32.Parse(client.Text); sdb.Projects.InsertOnSubmit(prjct); sdb.SubmitChanges(); this.projectTableAdapter.Fill(this.accountingDBDataSet.Project); MessageBox.Show("Data Inserted!"); } } catch (SqlException) { MessageBox.Show("Client ID Not present!"); } }
private void prjct_update_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { try { int id = Int32.Parse(prjct_id.Text); Project prjct = sdb.Projects.SingleOrDefault(x => x.prjct_id == id); prjct.prjct_id = Int32.Parse(prjct_id.Text); prjct.prjct_name = prjct_name.Text; prjct.prjct_status = prjct_status.Text; prjct.curr_amount = float.Parse(curr_amount.Text); prjct.prjct_exp = float.Parse(prjct_exp1.Text); prjct.rc_able = float.Parse(rc_able.Text); prjct.client = Int32.Parse(client.Text); sdb.SubmitChanges(); this.projectTableAdapter.Fill(this.accountingDBDataSet.Project); } catch (SqlException) { MessageBox.Show("Client ID not present!"); } } }
private void emp_update_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { int id = Int32.Parse(emp_id.Text); Employee emp = sdb.Employees.SingleOrDefault(x => x.emp_id == id); int emp_id1, basic_sal1; Int32.TryParse(emp_id.Text, out emp_id1); emp.emp_id = emp_id1; emp.emp_name = emp_name.Text; emp.designation = design.Text; emp.joindate = DateTime.Parse(joindate.Text); Int32.TryParse(basic.Text, out basic_sal1); emp.basic_sal = basic_sal1; emp.receivable = float.Parse(rcvbl.Text); emp.address = address.Text; emp.phone_no = phn_no.Text; emp.mail = emp_mail.Text; emp.emp_picture = emp_pictureBox.ImageLocation; emp.dept_name = dept_name.Text; sdb.SubmitChanges(); this.employeeTableAdapter3.Fill(this.accountingDBDataSet5.Employee); } }
private void search_Click(object sender, EventArgs e) { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { string nameString = search_combo.GetItemText(this.search_combo.SelectedItem); if (!string.IsNullOrEmpty(nameString)) { if (search_by.GetItemText(this.search_by.SelectedItem) == "ID") { int searchedId; Int32.TryParse(searchBox.Text, out searchedId); if (nameString == "Accounts") { if (!string.IsNullOrWhiteSpace(searchBox.Text)) { if (sdb.Accounts.SingleOrDefault(x => x.acc_id == searchedId) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Account a = sdb.Accounts.SingleOrDefault(x => x.acc_id == searchedId); bs.DataSource = a; search_grid.DataSource = bs; } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } } else if (nameString == "Client") { if (sdb.Clients.SingleOrDefault(x => x.client_id == searchedId) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Client a = sdb.Clients.SingleOrDefault(x => x.client_id == searchedId); bs.DataSource = a; search_grid.DataSource = bs; search_pictureBox.Image = Image.FromFile(search_grid.Rows[0].Cells[5].Value.ToString()); } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } else if (nameString == "Employee") { if (sdb.Employees.SingleOrDefault(x => x.emp_id == searchedId) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Employee a = sdb.Employees.SingleOrDefault(x => x.emp_id == searchedId); bs.DataSource = a; search_grid.DataSource = bs; search_pictureBox.Image = Image.FromFile(search_grid.Rows[0].Cells[9].Value.ToString()); } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } else if (nameString == "Project") { if (sdb.Projects.SingleOrDefault(x => x.prjct_id == searchedId) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Project a = sdb.Projects.SingleOrDefault(x => x.prjct_id == searchedId); bs.DataSource = a; search_grid.DataSource = bs; } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } else if (nameString == "Transactions") { if (sdb.Transactions.SingleOrDefault(x => x.trans_id == searchedId) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Transaction a = sdb.Transactions.SingleOrDefault(x => x.trans_id == searchedId); bs.DataSource = a; search_grid.DataSource = bs; } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } } else if (search_by.GetItemText(this.search_by.SelectedItem) == "Name") { string searchedName = searchBox.Text; if (nameString == "Accounts") { if (!string.IsNullOrWhiteSpace(searchBox.Text)) { if (sdb.Accounts.SingleOrDefault(x => x.acc_hd == searchedName) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Account a = sdb.Accounts.SingleOrDefault(x => x.acc_hd == searchedName); bs.DataSource = a; search_grid.DataSource = bs; } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } } else if (nameString == "Client") { if (sdb.Clients.SingleOrDefault(x => x.clent_name == searchedName) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Client a = sdb.Clients.SingleOrDefault(x => x.clent_name == searchedName); bs.DataSource = a; search_grid.DataSource = bs; search_pictureBox.Image = Image.FromFile(search_grid.Rows[0].Cells[5].Value.ToString()); } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } else if (nameString == "Employee") { if (sdb.Employees.SingleOrDefault(x => x.emp_name == searchedName) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Employee a = sdb.Employees.SingleOrDefault(x => x.emp_name == searchedName); bs.DataSource = a; search_grid.DataSource = bs; search_pictureBox.Image = Image.FromFile(search_grid.Rows[0].Cells[9].Value.ToString()); } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } else if (nameString == "Project") { if (sdb.Projects.SingleOrDefault(x => x.prjct_name == searchedName) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Project a = sdb.Projects.SingleOrDefault(x => x.prjct_name == searchedName); bs.DataSource = a; search_grid.DataSource = bs; } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } else if (nameString == "Transactions") { if (sdb.Transactions.SingleOrDefault(x => x.trans_date == DateTime.Parse(searchedName)) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Transaction a = sdb.Transactions.SingleOrDefault(x => x.trans_date == DateTime.Parse(searchedName)); bs.DataSource = a; search_grid.DataSource = bs; } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } } else { searchresult.Text = "Lack of Information!!!"; searchresult.Show(); } } } }
private void search_combo_name_SelectedIndexChanged(object sender, EventArgs e) { string select = category_combo.GetItemText(this.category_combo.SelectedItem); string nameString = search_combo_name.GetItemText(this.search_combo_name.SelectedItem); if (select == "Client") { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { if (sdb.Clients.SingleOrDefault(x => x.clent_name == nameString) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Client a = sdb.Clients.SingleOrDefault(x => x.clent_name == nameString); bs.DataSource = a; search_grid.DataSource = bs; search_pictureBox.Image = Image.FromFile(search_grid.Rows[0].Cells[5].Value.ToString()); } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } } else if (select == "Employee") { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { if (sdb.Employees.SingleOrDefault(x => x.emp_name == nameString) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Employee a = sdb.Employees.SingleOrDefault(x => x.emp_name == nameString); bs.DataSource = a; search_grid.DataSource = bs; search_pictureBox.Image = Image.FromFile(search_grid.Rows[0].Cells[9].Value.ToString()); } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } } else if (select == "Project") { using (AccountingDataClassesDataContext sdb = new AccountingDataClassesDataContext()) { if (sdb.Projects.SingleOrDefault(x => x.prjct_name == nameString) != null) { searchresult.Text = "Found!!!"; searchresult.Show(); search_grid.Show(); Project a = sdb.Projects.SingleOrDefault(x => x.prjct_name == nameString); bs.DataSource = a; search_grid.DataSource = bs; } else { searchresult.Text = "Not Found!!!!"; searchresult.Show(); search_grid.Hide(); } } } else { MessageBox.Show("Hello"); } }