private void insertButton_Click(object sender, EventArgs e) { if (productNameTextBox.Text == "" || productdesTextbox.Text == "" || productPriceTextBox.Text == "" || stockTextBox.Text == "" || categoryComboBox.Text == "") { MessageBox.Show("please fill up all information except PRODUCT ID"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Product p = new Product(); Category cat = new Category(); p.P_Name = productNameTextBox.Text; p.P_Price = Convert.ToDouble(productPriceTextBox.Text); p.P_Stock = Convert.ToInt32(stockTextBox.Text); p.P_Des = productdesTextbox.Text; p.Cat_ID = int.Parse(categoryComboBox.Text); /*if (categoryComboBox.Text == cat.Cat_Name) * { * p.Cat_ID = cat.Cat_ID; * }*/ scdc.Products.InsertOnSubmit(p); scdc.SubmitChanges(); productListGridViewUpdate(); productNameTextBox.Text = productidTextBox.Text = productPriceTextBox.Text = productdesTextbox.Text = stockTextBox.Text = categoryComboBox.Text = string.Empty; MessageBox.Show("PRODUCT ADDED SUCCESSFULLY"); } }
private void aEditButton_Click(object sender, EventArgs e) { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Customer u2 = scdc.Customers.SingleOrDefault(x => x.C_ID == pp.id); u2.C_Firstname = cFirstnameTextBox.Text; u2.C_Lastname = cLastnameTextBox.Text; u2.C_ID = int.Parse(cUserIDTextBox.Text); u2.C_Password = int.Parse(cPasswordTextBox.Text); u2.C_Email = cEmailTextBox.Text; u2.C_Phone = cPhoneTextBox.Text; u2.C_Address = cAddressTextBox.Text; scdc.SubmitChanges(); fnameLabel.Text = u2.C_Firstname; lanameLabel.Text = u2.C_Lastname; emailLabel.Text = u2.C_Email; phoneLabel.Text = u2.C_Phone; addressLabel.Text = u2.C_Address; idLabel.Text = Convert.ToString(u2.C_ID); passwordLabel.Text = Convert.ToString(u2.C_Password); }
private void uUpdateButton_Click(object sender, EventArgs e) { if (uFirstnameTextBox.Text == "" || uUserIDTextBox.Text == "" || uLastNameTextBox.Text == "" || uEmailTextBox.Text == "" || uPhoneTextBox.Text == "" || uPasswordTextBox.Text == "" || uAddressTextBox.Text == "") { MessageBox.Show("please fill up all info"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Customer c = scdc.Customers.SingleOrDefault(x => x.C_ID == int.Parse(uUserIDTextBox.Text)); c.C_Firstname = uFirstnameTextBox.Text; c.C_Lastname = uLastNameTextBox.Text; c.C_Email = uEmailTextBox.Text; c.C_Password = Convert.ToInt32(uPasswordTextBox.Text); c.C_Phone = uPhoneTextBox.Text; c.C_Address = uAddressTextBox.Text; scdc.SubmitChanges(); UserlistGridViewUpdate(); uUserIDTextBox.Text = string.Empty; } }
private void uAddButton_Click(object sender, EventArgs e) { if (uFirstnameTextBox.Text == "" || uLastNameTextBox.Text == "" || uEmailTextBox.Text == "" || uPhoneTextBox.Text == "" || uPasswordTextBox.Text == "" || uAddressTextBox.Text == "") { MessageBox.Show("please fill up all info except User ID"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Customer c = new Customer() { C_Firstname = uFirstnameTextBox.Text, C_Lastname = uLastNameTextBox.Text, //C_ID =Convert.ToInt32(uUserIDTextBox.Text), C_Password = Convert.ToInt32(uPasswordTextBox.Text), C_Email = uEmailTextBox.Text, C_Phone = uPhoneTextBox.Text, C_Address = aAddressTextBox.Text }; scdc.Customers.InsertOnSubmit(c); scdc.SubmitChanges(); UserlistGridViewUpdate(); uFirstnameTextBox.Text = uLastNameTextBox.Text = uPasswordTextBox.Text = uEmailTextBox.Text = uPhoneTextBox.Text = uAddressTextBox.Text = string.Empty; } }
private void Shopping_List_FormClosing(object sender, FormClosingEventArgs e) { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Transaction t = new Transaction(); var s = from a in scdc.Transactions select a; scdc.Transactions.DeleteAllOnSubmit(s); scdc.SubmitChanges(); Application.Exit(); }
private void PrintButton_Click(object sender, EventArgs e) { MessageBox.Show("Your list is now printing \n Thankyou for shopping with us"); this.Close(); ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Transaction t = new Transaction(); var s = from a in scdc.Transactions select a; scdc.Transactions.DeleteAllOnSubmit(s); scdc.SubmitChanges(); }
private void DeleteFromList_Click(object sender, EventArgs e) { if (productIDTextBox.Text == "") { MessageBox.Show("enter a valid PRODUCT ID"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Transaction p = scdc.Transactions.SingleOrDefault(x => x.P_ID == int.Parse(productIDTextBox.Text)); scdc.Transactions.DeleteOnSubmit(p); scdc.SubmitChanges(); LoadShoppinList(); productNameTextBox.Text = productIDTextBox.Text = priceTextBox.Text = quantityTextBox.Text = string.Empty; } }
private void uRemoveButton_Click(object sender, EventArgs e) { if (uUserIDTextBox.Text == "") { MessageBox.Show("please enter User ID"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Customer c = scdc.Customers.SingleOrDefault(x => x.C_ID == int.Parse(uUserIDTextBox.Text)); scdc.Customers.DeleteOnSubmit(c); scdc.SubmitChanges(); UserlistGridViewUpdate(); uUserIDTextBox.Text = string.Empty; } }
private void deleteProduct_Click(object sender, EventArgs e) { if (productidTextBox.Text == "") { MessageBox.Show("Please Insert Valid PRODUCT ID"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Product p = scdc.Products.SingleOrDefault(x => x.P_ID == int.Parse(productidTextBox.Text)); scdc.Products.DeleteOnSubmit(p); scdc.SubmitChanges(); productListGridViewUpdate(); productidTextBox.Text = string.Empty; MessageBox.Show("PRODUCT HAS BEEN DELETED"); } }
private void deleteCatButton_Click(object sender, EventArgs e) { if (catDesTextBox.Text == "") { MessageBox.Show("Please enter valid CATEGORY ID"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Category cat = scdc.Categories.SingleOrDefault(x => x.Cat_ID == int.Parse(catIDTextBox.Text)); scdc.Categories.DeleteOnSubmit(cat); scdc.SubmitChanges(); categorylistGridViewUpdate(); catIDTextBox.Text = string.Empty; } }
private void updateCatButton_Click(object sender, EventArgs e) { if (catDesTextBox.Text == "" || catNameTextBox.Text == "" || catDesTextBox.Text == "") { MessageBox.Show("please fill up all the informations"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Category cat = scdc.Categories.SingleOrDefault(x => x.Cat_ID == int.Parse(catIDTextBox.Text)); cat.Cat_Name = catNameTextBox.Text; cat.Cat_Des = catDesTextBox.Text; scdc.SubmitChanges(); catNameTextBox.Text = catIDTextBox.Text = catDesTextBox.Text = string.Empty; categorylistGridViewUpdate(); } }
private void insertCatButton_Click(object sender, EventArgs e) { if (catNameTextBox.Text == "" || catDesTextBox.Text == "") { MessageBox.Show("Fill up all the textbox except Category ID"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Category cat = new Category { //Cat_ID = Convert.ToInt32(catIDTextBox.Text), Cat_Name = catNameTextBox.Text, Cat_Des = catDesTextBox.Text }; scdc.Categories.InsertOnSubmit(cat); scdc.SubmitChanges(); categorylistGridViewUpdate(); catIDTextBox.Text = catNameTextBox.Text = catDesTextBox.Text = string.Empty; } }
private void InsertToList_Click(object sender, EventArgs e) { if (productIDTextBox.Text == "" || productNameTextBox.Text == "" || priceTextBox.Text == "" || quantityTextBox.Text == "") { MessageBox.Show("Please add quantity to product"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Transaction t = new Transaction(); t.P_ID = Convert.ToInt32(productIDTextBox.Text); t.P_Name = productNameTextBox.Text; t.Price = int.Parse(priceTextBox.Text); t.Quantity = int.Parse(quantityTextBox.Text); t.Total = (int.Parse(quantityTextBox.Text)) * (int.Parse(priceTextBox.Text)); scdc.Transactions.InsertOnSubmit(t); scdc.SubmitChanges(); LoadShoppinList(); productIDTextBox.Text = productNameTextBox.Text = priceTextBox.Text = quantityTextBox.Text = string.Empty; } }
private void updateButton_Click(object sender, EventArgs e) { if (productNameTextBox.Text == "" || productdesTextbox.Text == "" || productPriceTextBox.Text == "" || stockTextBox.Text == "" || categoryComboBox.Text == "" || productidTextBox.Text == "") { MessageBox.Show("please fill up all information Correctly"); } else { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Product p = scdc.Products.SingleOrDefault(x => x.P_ID == int.Parse(productidTextBox.Text)); p.P_Name = productNameTextBox.Text; p.P_Price = Convert.ToDouble(productPriceTextBox.Text); p.P_Stock = int.Parse(stockTextBox.Text); p.P_Des = productdesTextbox.Text; p.Cat_ID = int.Parse(categoryComboBox.Text); scdc.SubmitChanges(); productListGridViewUpdate(); productNameTextBox.Text = productidTextBox.Text = productPriceTextBox.Text = productdesTextbox.Text = stockTextBox.Text = categoryComboBox.Text = string.Empty; MessageBox.Show("PRODUCT UPDATED SUCCESSFULLY"); } }
private void aEditButton_Click(object sender, EventArgs e) { ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30"); Admin c = scdc.Admins.SingleOrDefault(x => x.A_ID == int.Parse(aUserIDTextBox.Text)); c.A_Firstname = aFirstnameTextBox.Text; c.A_Lastname = aLastnameTextBox.Text; c.A_Email = aEmailTextBox.Text; c.A_Password = Convert.ToInt32(aPasswordTextBox.Text); c.A_Phone = aPhoneTextBox.Text; c.A_Address = aAddressTextBox.Text; scdc.SubmitChanges(); fnameLabel.Text = c.A_Firstname; lnamelabel.Text = c.A_Lastname; emaillabel.Text = c.A_Email; phonelabel.Text = c.A_Phone; addresslabel.Text = c.A_Address; idlabel.Text = Convert.ToString(c.A_ID); passwordlabel.Text = Convert.ToString(c.A_Password); }