Exemple #1
0
 private void them_Click(object sender, EventArgs e)
 {
     if (txtmaloai == null || txttenloai == null)
     {
         MessageBox.Show("Tên hoặc Mã Loại không được để trống");
     }
     else
     {
         try
         {
             eLoaiSanPham newl = new eLoaiSanPham();
             newl.MaLoaiSP  = txtmaloai.Text;
             newl.TenLoaiSP = txttenloai.Text;
             newl.Style     = txtstyle.Text;
             newl.MoTa      = txtmota.Text;
             if (sp.ThemLoaiSpMoi(newl))
             {
                 MessageBox.Show("Insert Succcesfully");
                 this.Close();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex.Message.ToString());
         }
     }
 }
Exemple #2
0
        public List <eLoaiSanPham> GetalloaiSp()
        {
            var c = from i in db.LoaiSanPhams
                    select i;
            List <eLoaiSanPham> ls = new List <eLoaiSanPham>();

            foreach (LoaiSanPham e in c.ToList())
            {
                eLoaiSanPham newe = new eLoaiSanPham();
                newe.MaLoaiSP  = e.MaLoaiSanPham;
                newe.TenLoaiSP = e.TenLoaiSanPham;
                newe.Style     = e.Style;
                newe.MoTa      = e.Mota;
                ls.Add(newe);
            }
            return(ls);
        }
Exemple #3
0
        public bool themLoaisp(eLoaiSanPham loai)
        {
            var c = from i in db.LoaiSanPhams
                    where i.MaLoaiSanPham == loai.MaLoaiSP
                    select i;

            if (c.Any())
            {
                throw new Exception("There Already Have");
            }
            else
            {
                LoaiSanPham l = new LoaiSanPham();
                l.MaLoaiSanPham  = loai.MaLoaiSP;
                l.TenLoaiSanPham = loai.TenLoaiSP;
                l.Style          = loai.Style;
                l.Mota           = loai.MoTa;
                db.LoaiSanPhams.InsertOnSubmit(l);
                db.SubmitChanges();
                return(true);
            }
        }
 public bool ThemLoaiSpMoi(eLoaiSanPham loai)
 {
     return(z.themLoaisp(loai));
 }