private void btnSubmit_Click(object sender, EventArgs e) { String name = txtName.Text.Trim(); String image = txtImage.Text.Trim(); if (name == "" || image == "") { MessageBox.Show("Please input textfield"); } else { if (isIsert) { db.Brands.Add(new Brand(name, "..\\SaleLaptopSystem\\SaleLaptopSystem\\SaleLaptopSystem\\img\\Brands_img\\" + image, cbbActive.Checked == true?true:false)); db.SaveChanges(); } else { int id = Convert.ToInt32(this.brand.ID); Brand EBrand = db.Brands.FirstOrDefault(b => b.ID == id); EBrand.Name = name; EBrand.Image = "..\\SaleLaptopSystem\\SaleLaptopSystem\\SaleLaptopSystem\\img\\Brands_img\\" + image; EBrand.Active = cbbActive.Checked == true ? true : false; db.SaveChanges(); } BrandLoad form = new BrandLoad(); form.Show(); form.load(); this.Hide(); } }
private void btnSubmit_Click(object sender, EventArgs e) { String name = txtName.Text.Trim(); if (name == "") { MessageBox.Show("Please input textfield"); } else { if (isIsert) { db.Categories.Add(new Category(name, cbbActive.Checked == true ? true : false)); db.SaveChanges(); } else { int id = Convert.ToInt32(this.category.ID); Category ECate = db.Categories.FirstOrDefault(c => c.ID == id); ECate.Name = txtName.Text;//update them thang moi ECate.Active = cbbActive.Checked == true ? true : false; db.SaveChanges(); } BrandLoad form = new BrandLoad(); form.Visible = true; form.load(); this.Visible = false; } }
private void btnAdd_Click(object sender, EventArgs e) { String name = txtName.Text.Trim(); String description = txtDescription.Text.Trim(); String features = txtFeatures.Text.Trim(); String price = txtPrice.Text.Trim(); String discount = txtDiscount.Text.Trim(); if (name == "" || description == "" || features == "" || txtPrice.Text == "" || txtDiscount.Text == "") { MessageBox.Show("Please input textfield"); } else { int brandid = Convert.ToInt32(cbbBrand.SelectedValue); int cateId = Convert.ToInt32(cbbCategory.SelectedValue); if (isClick == false) { MessageBox.Show("Please add product detail"); } else { if (isIsert) { db.Products.Add(new Product(name, Convert.ToDouble(price), Convert.ToDouble(discount), description, features, cbActive.Checked == true ? true : false, brandid, cateId, idDetail)); db.SaveChanges(); } else { int id = Convert.ToInt32(this.product.ID); Product EProduct = db.Products.FirstOrDefault(c => c.ID == id); EProduct.Name = txtName.Text; EProduct.Price = Convert.ToDouble(txtPrice.Text); EProduct.Discount = Convert.ToDouble(txtDiscount.Text); EProduct.Description = txtDescription.Text; EProduct.Features = txtFeatures.Text; EProduct.Active = cbActive.Checked == true ? true : false; EProduct.BrandID = Convert.ToInt32(cbbBrand.SelectedValue); EProduct.CategoryID = Convert.ToInt32(cbbCategory.SelectedValue); EProduct.ProductDetailID = product.ProductDetailID; db.SaveChanges(); } ProductView form = new ProductView(); form.Show(); form.load(); this.Hide(); } } }
private void btnAdd_Click(object sender, EventArgs e) { String processor = txtProcess.Text.Trim(); String RAM = txtRAM.Text.Trim(); String screen = txtScreen.Text.Trim(); String storage = txtStorage.Text.Trim(); String graphic = txtGraphic.Text.Trim(); String size = txtSize.Text.Trim(); String os = txtOS.Text.Trim(); String video = txtVideo.Text.Trim(); String connection = txtConnection.Text.Trim(); String battery = txtBattery.Text.Trim(); String keyboard = txtKeyboard.Text.Trim(); if (processor == "" || RAM == "" || screen == "" || storage == "" || graphic == "" || size == "" || os == "" || video == "" || connection == "" || battery == "" || keyboard == "") { MessageBox.Show("Please input textfield"); } else { ProductDetail detail = null; if (isIsert) { detail = new ProductDetail(processor, RAM, screen, storage, graphic, size, os, video, connection, keyboard, battery); db.ProductDetails.Add(detail); db.SaveChanges(); form.Show(); form.setisClick(true); form.setIdDetail(detail.ID); this.Hide(); } else { int id = Convert.ToInt32(this.detail.ID); ProductDetail productDetail = db.ProductDetails.FirstOrDefault(b => b.ID == id); productDetail.Processor = processor; productDetail.RAM = RAM; productDetail.Screen = screen; productDetail.Storage = storage; productDetail.Graphic = graphic; productDetail.Size = size; productDetail.OS = os; productDetail.Video = video; productDetail.Connection = connection; productDetail.Keyboard = keyboard; productDetail.Battery = battery; db.SaveChanges(); form.Show(); this.Hide(); } } }
private void btnUpdate_Click(object sender, EventArgs e) { if (this.id < 0) { MessageBox.Show("Please select user to update"); } else { User userU = db.Users.FirstOrDefault(x => x.ID == this.id); userU.Active = user.Active == true ? false : true; db.SaveChanges(); load(); } }
private void btnDelete_Click(object sender, EventArgs e) { if (this.id < 0) { MessageBox.Show("Please choice brand to delete"); } else { db.Brands.Remove(this.brand); db.SaveChanges(); load(); } }
public Boolean registration(String fullname, String password, String email, String phone, String address, String img, String role) { try { User user = new User { Fullname = fullname, Password = MD5Hash(password), Email = email, Phone = phone, Address = address, Image = img, Role = role, Active = true }; db.Users.Add(user); db.SaveChanges(); return(true); }catch (Exception e) { return(false); } }