Esempio n. 1
0
        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 ControlBrand_Click(object sender, EventArgs e)
        {
            BrandLoad viewBrand = new BrandLoad();

            pnlView.Controls.Add(viewBrand);
            viewBrand.BringToFront();
        }
        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;
            }
        }