Esempio n. 1
0
        public ActionResult createNSX(FormCollection frmCreate, NHA_SAN_XUAT a)
        {
            a.TenNSX = frmCreate["ten"];
            a.DiaChi = frmCreate["diachi"];

            db.NHA_SAN_XUAT.Add(a);
            db.SaveChanges();
            return(RedirectToAction("NSX", "Quanly"));
        }
Esempio n. 2
0
 public bool ThemNSX(NHA_SAN_XUAT nsx)
 {
     try
     {
         qlkho.NHA_SAN_XUATs.InsertOnSubmit(nsx);
         qlkho.SubmitChanges();
         return(true);
     }
     catch { return(false); }
 }
Esempio n. 3
0
 public bool SuaTTNhaSanXuat(NHA_SAN_XUAT p)
 {
     try
     {
         NHA_SAN_XUAT k = qlkho.NHA_SAN_XUATs.Where(t => t.MANSX == p.MANSX).FirstOrDefault();
         k = p;
         qlkho.SubmitChanges();
         return(true);
     }
     catch { return(false); }
 }
Esempio n. 4
0
 public bool XoaNhaSX(string ma)
 {
     try
     {
         NHA_SAN_XUAT p = qlkho.NHA_SAN_XUATs.Where(t => t.MANSX == ma).FirstOrDefault();
         qlkho.NHA_SAN_XUATs.DeleteOnSubmit(p);
         qlkho.SubmitChanges();
         return(true);
     }
     catch { return(false); }
 }
Esempio n. 5
0
        public bool KiemTraTrung(string ma)
        {
            NHA_SAN_XUAT nsx = qlkho.NHA_SAN_XUATs.Where(t => t.MANSX == ma).FirstOrDefault();

            if (nsx == null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 6
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            NHA_SAN_XUAT p     = new NHA_SAN_XUAT();
            int          index = dataGridViewNSX.CurrentCell.RowIndex;

            if (nsx.SuaTTNhaSanXuat(p))
            {
                MessageBox.Show("Cập nhật thông tin thành công");
            }
            else
            {
                MessageBox.Show("Cập nhật thông tin thất bại");
            }
            dataGridViewNSX.DataSource = nsx.LoadDLNSX();
        }
Esempio n. 7
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMa.Text == "")
            {
                txtMa.Focus();
                MessageBox.Show("Bạn chưa nhập mã");
                return;
            }
            if (txtTen.Text == "")
            {
                txtTen.Focus();
                MessageBox.Show("Bạn chưa nhập tên nhà sản xuất");
                return;
            }

            if (nsx.KiemTraTrung(txtMa.Text.Trim()))
            {
                NHA_SAN_XUAT p = new NHA_SAN_XUAT();
                p.MANSX      = txtMa.Text.Trim();
                p.TENNSX     = txtTen.Text.Trim();
                p.EMAILNSX   = txtEmail.Text;
                p.WEBSITENSX = txtWebsite.Text;
                p.MOTANSX    = txtMoTa.Text;
                if (nsx.ThemNSX(p))
                {
                    dataGridViewNSX.DataSource = nsx.LoadDLNSX();
                    panelNhaSanXuat.Enabled    = false;
                    btnLuu.Enabled             = false;
                    MessageBox.Show("Thêm thành công");
                }
                else
                {
                    MessageBox.Show("Thêm thất bại");
                }
            }
            else
            {
                MessageBox.Show("Mã đã tồn tại");
                txtMa.Text = nsx.MaNSX();
                return;
            }
        }
Esempio n. 8
0
        public ActionResult Edit(int id)
        {
            if (id <= 0)
            {
                ViewBag.Message = "Không tìm thấy hãng sản xuất tương ứng.";
                return(View("../Home/Error"));;
            }
            var          ctx    = new SmsContext();
            NHA_SAN_XUAT khuVuc = ctx.NHA_SAN_XUAT.Find(id);

            if (khuVuc.ACTIVE.Equals("A"))
            {
                ctx.Dispose();
                return(View(khuVuc));
            }
            else
            {
                ctx.Dispose();
                ViewBag.Message = "Không tìm thấy hãng sản xuất tương ứng.";
                return(View("../Home/Error"));;
            }
        }