private void button9_Click(object sender, EventArgs e)//BILL Button (BILL SECTION) { ProductTableDataContext p = new ProductTableDataContext(strCon); try { for (int i = 0; i < dataGridView_Bill.Rows.Count; i++) { total += Double.Parse(dataGridView_Bill.Rows[i].Cells["PrdAmount"].Value.ToString()); } labelAmnt.Text = total.ToString(); MessageBox.Show("Your Bill : " + total + "TK"); var x = from a in p.Products where a.Id == int.Parse(text_pID.Text) select a; { x.First().Quantity -= Double.Parse(text_Quantity.Text); p.SubmitChanges(); dataGrid_Purchase.DataSource = x.ToList(); } } catch { MessageBox.Show("Unsuccessful!"); } }
private void button6_Click(object sender, EventArgs e)//ADD PRODUCT Button { ProductTableDataContext p = new ProductTableDataContext(strCon); try { Product pd = new Product { Id = int.Parse(textBox_Pd_Id.Text), Name = text_Pd_Name.Text, Quantity = Double.Parse(text_Pd_Quantity.Text), Price = Double.Parse(text_Pd_Price.Text) }; p.Products.InsertOnSubmit(pd); p.SubmitChanges(); dataGrid_Purchase.DataSource = p.Products.ToList(); MessageBox.Show("Success!"); } catch { MessageBox.Show("Error!"); } }
private void text_Quantity_TextChanged(object sender, EventArgs e)//QUANTITY Textbox (BILL SECTION) { if (text_Quantity.Equals(null) || text_Quantity.Text.Any()) { try { ProductTableDataContext p = new ProductTableDataContext(strCon); quantity = int.Parse(text_Quantity.Text); var x = from a in p.Products where a.Id == int.Parse(text_pID.Text) select a; textBox_Rate.Text = x.First().Price.ToString(); labelAmount.Text = ((x.First().Price) * quantity).ToString(); p.SubmitChanges(); } catch { MessageBox.Show("Invalid Entry!"); } } }
private void button8_Click(object sender, EventArgs e)//UPDATE PRODUCT Button { ProductTableDataContext p = new ProductTableDataContext(strCon); if (textBox_Pd_Id.Text != "") { try { var x = from a in p.Products where a.Id == int.Parse(textBox_Pd_Id.Text) select a; x.First().Id = int.Parse(textBox_Pd_Id.Text); x.First().Name = text_Pd_Name.Text; x.First().Quantity = Double.Parse(text_Pd_Quantity.Text); x.First().Price = Double.Parse(text_Pd_Price.Text); p.SubmitChanges(); dataGrid_Purchase.DataSource = x.ToList(); MessageBox.Show("Update Successful!"); } catch { MessageBox.Show("Invalid Entry!"); } } else { MessageBox.Show("Input ID First!"); } }
private void button9_Click(object sender, EventArgs e)//BILL Button (BILL SECTION) { ProductTableDataContext p = new ProductTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30"); try { for (int i = 0; i < dataGridView_Bill.Rows.Count; i++) { total += Double.Parse(dataGridView_Bill.Rows[i].Cells["PrdAmount"].Value.ToString()); } labelAmnt.Text = total.ToString(); MessageBox.Show("Your Bill : " + total + "TK"); var x = from a in p.Products where a.Id == int.Parse(text_pID.Text) select a; { x.First().Quantity -= Double.Parse(text_Quantity.Text); p.SubmitChanges(); dataGrid_Purchase.DataSource = x.ToList(); } } catch { MessageBox.Show("Unsuccessful!"); } }
private void text_Quantity_TextChanged(object sender, EventArgs e)//QUANTITY Textbox (BILL SECTION) { if (text_Quantity.Equals(null) || text_Quantity.Text.Any()) { try { ProductTableDataContext p = new ProductTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30"); quantity = int.Parse(text_Quantity.Text); var x = from a in p.Products where a.Id == int.Parse(text_pID.Text) select a; textBox_Rate.Text = x.First().Price.ToString(); labelAmount.Text = ((x.First().Price) * quantity).ToString(); p.SubmitChanges(); } catch { MessageBox.Show("Invalid Entry!"); } } }
private void button6_Click(object sender, EventArgs e)//ADD PRODUCT Button { ProductTableDataContext p = new ProductTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30"); try { Product pd = new Product { Id = int.Parse(textBox_Pd_Id.Text), Name = text_Pd_Name.Text, Quantity = Double.Parse(text_Pd_Quantity.Text), Price = Double.Parse(text_Pd_Price.Text) }; p.Products.InsertOnSubmit(pd); p.SubmitChanges(); dataGrid_Purchase.DataSource = p.Products.ToList(); MessageBox.Show("Success!"); } catch { MessageBox.Show("Error!"); } }
private void button8_Click(object sender, EventArgs e)//UPDATE PRODUCT Button { ProductTableDataContext p = new ProductTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30"); if (textBox_Pd_Id.Text != "") { try { var x = from a in p.Products where a.Id == int.Parse(textBox_Pd_Id.Text) select a; x.First().Id = int.Parse(textBox_Pd_Id.Text); x.First().Name = text_Pd_Name.Text; x.First().Quantity = Double.Parse(text_Pd_Quantity.Text); x.First().Price = Double.Parse(text_Pd_Price.Text); p.SubmitChanges(); dataGrid_Purchase.DataSource = x.ToList(); MessageBox.Show("Update Successful!"); } catch { MessageBox.Show("Invalid Entry!"); } } else { MessageBox.Show("Input ID First!"); } }