Ejemplo n.º 1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            LOAIGIAY LG = new LOAIGIAY();
            int      b  = 0;

            for (int i = 1; i <= dataGridView1.RowCount; i++)
            {
                b += i;
            }
            txt_ml.Text = "L0" + (b + 1).ToString();
            LG.MALOAI   = "L0" + (b + 1).ToString();
            LG.TENLOAI  = txt_tenloai.Text.ToString();
            if (g.ktkc_lg(LG) == true)
            {
                if (g.themlg(LG) == true)
                {
                    MessageBox.Show("thêm thành công");
                    dataGridView1.DataSource = g.loadbang_loaigiay();
                }
                else
                {
                    MessageBox.Show("thất bại");
                }
            }
            else
            {
                MessageBox.Show("trùng mã");
            }
        }
Ejemplo n.º 2
0
        public ActionResult EditLOAI(int id)
        {
            LOAIGIAY loai = db.LOAIGIAYs.SingleOrDefault(n => n.MaLoaiGiay == id);

            if (loai == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(loai));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteLOAI(int id)
        {
            //Lay ra doi tuong sach can xoa theo ma
            LOAIGIAY loai = db.LOAIGIAYs.SingleOrDefault(n => n.MaLoaiGiay == id);

            ViewBag.MaLoaiGiay = loai.MaLoaiGiay;
            if (loai == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(loai));
        }
Ejemplo n.º 4
0
 public bool them(LOAIGIAY pmh)
 {
     try
     {
         da.LOAIGIAYs.InsertOnSubmit(pmh);
         da.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
        public bool ktkc(LOAIGIAY ma)
        {
            var kt = (from k in da.LOAIGIAYs where k.MALOAI == ma.MALOAI select k).Count();

            if (kt == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
 public bool sua(LOAIGIAY pmh)
 {
     try
     {
         LOAIGIAY thanhvien = da.LOAIGIAYs.Where(t => t.MALOAI == pmh.MALOAI.ToString()).FirstOrDefault();
         thanhvien.TENLOAI = pmh.TENLOAI;
         da.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 7
0
 public ActionResult EditLOAI(int id, LOAIGIAY collection)
 {
     try
     {
         LOAIGIAY loai = db.LOAIGIAYs.SingleOrDefault(n => n.MaLoaiGiay == id);
         loai.TenLoaiGiay = collection.TenLoaiGiay;
         UpdateModel(loai);
         db.SubmitChanges();
     }
     catch
     {
         return(View());
     }
     return(RedirectToAction("ShoeCatogery"));
 }
Ejemplo n.º 8
0
        public ActionResult ConfirmDeleteLOAI(int id)
        {
            //Lay ra doi tuong sach can xoa theo ma
            LOAIGIAY loai = db.LOAIGIAYs.SingleOrDefault(n => n.MaLoaiGiay == id);

            ViewBag.MaLoaiGiay = loai.MaLoaiGiay;
            if (loai == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            db.LOAIGIAYs.DeleteOnSubmit(loai);
            db.SubmitChanges();
            return(RedirectToAction("ShoeCatogery"));
        }
Ejemplo n.º 9
0
        private void btnsua_Click(object sender, EventArgs e)
        {
            LOAIGIAY LG = new LOAIGIAY();

            LG.MALOAI  = txt_ml.Text.ToString();
            LG.TENLOAI = txt_tenloai.Text.ToString();
            if (g.ktkc_lg(LG) == false)
            {
                if (g.sualg(LG) == true)
                {
                    MessageBox.Show("sửa thành công");
                    dataGridView1.DataSource = g.loadbang_loaigiay();
                }
                else
                {
                    MessageBox.Show("thất bại");
                }
            }
            else
            {
                MessageBox.Show("không tôn tại");
            }
        }
Ejemplo n.º 10
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (txt_Maloai.Text == "" || txt_tenloai.Text == "")
            {
                MessageBox.Show("không được để trống");
                return;
            }
            var f = (from d in db.LOAIGIAYs where d.MALOAI == txt_Maloai.Text.ToString()
                     select d.MALOAI);

            if (f.Count() == 0)
            {
                LOAIGIAY lg = new LOAIGIAY();
                lg.MALOAI  = txt_Maloai.Text.ToString();
                lg.TENLOAI = txt_tenloai.Text.ToString();
                db.LOAIGIAYs.InsertOnSubmit(lg);
                db.SubmitChanges();
                insert();
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 11
0
 public bool sualg(LOAIGIAY n)
 {
     return(dl.sua(n));
 }
Ejemplo n.º 12
0
 public bool themlg(LOAIGIAY n)
 {
     return(dl.them(n));
 }
Ejemplo n.º 13
0
 public bool ktkc_lg(LOAIGIAY n)
 {
     return(dl.ktkc(n));
 }