Пример #1
0
        private void btnSAVE_Click(object sender, EventArgs e)
        {
            SALEMANAGEMENT_DB DB       = new SALEMANAGEMENT_DB();
            tblNhaCungCap     SUPPLIER = new tblNhaCungCap();

            if (string.IsNullOrEmpty(txtID_SUPPLIER.Text) || string.IsNullOrEmpty(txtNAME_SUPPLIER.Text) || string.IsNullOrEmpty(txtADDRESS.Text) ||
                string.IsNullOrEmpty(txtPHONE.Text) || string.IsNullOrEmpty(txtEMAIL.Text) || string.IsNullOrEmpty(txtFAX.Text) ||
                string.IsNullOrEmpty(txtCODE.Text))
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                SUPPLIER.MaNhaCungCap  = txtID_SUPPLIER.Text;
                SUPPLIER.TenNhaCungCap = txtNAME_SUPPLIER.Text;
                SUPPLIER.DiaChi        = txtADDRESS.Text;
                SUPPLIER.Email         = txtEMAIL.Text;
                SUPPLIER.Fax           = txtFAX.Text;
                SUPPLIER.SoDienThoai   = txtPHONE.Text;
                SUPPLIER.MaSoThue      = Convert.ToInt32(txtCODE.Text);
                try
                {
                    DB.tblNhaCungCaps.Add(SUPPLIER);
                    DB.SaveChanges();
                    d(SUPPLIER.MaNhaCungCap, SUPPLIER.TenNhaCungCap);
                    this.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("Mã số bị trùng. Vui lòng nhập mã khác", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            this.Close();
        }
        // save change
        private void btnSAVE_Click(object sender, EventArgs e)
        {
            tblNhaCungCap supplier = new tblNhaCungCap();

            supplier.MaNhaCungCap  = txtID_SUPPLIER.Text.Trim();
            supplier.TenNhaCungCap = txtNAME_SUPPLIER.Text.Trim();
            supplier.DiaChi        = txtADDRESS.Text.Trim();
            supplier.SoDienThoai   = txtPHONE.Text.Trim();
            supplier.Email         = txtEMAIL.Text.Trim();
            supplier.Fax           = txtFAX.Text.Trim();
            supplier.MaSoThue      = txtID_TAX.Text;
            if (String.IsNullOrEmpty(supplier.TenNhaCungCap))
            {
                MessageBox.Show("Tên nhà cung cấp trống!", "Lỗi nhập thiếu thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Disable(true);
            }
            else
            {
                if (isAdd)
                {
                    BLL_SUPPLIER.Instance.FuncAddNewSupplier(supplier); // add new supplier
                    MessageBox.Show("Thêm nhà cung cấp thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadData();
                }
                else
                {
                    BLL_SUPPLIER.Instance.FuncEditSupplier(supplier); // edit staff
                    MessageBox.Show("Sửa nhà cung cấp thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadData();
                }
            }
        }
Пример #3
0
        // delete supplier
        public void FuncDeleteSupplier(List <string> listID)
        {
            var supplier = new tblNhaCungCap();

            foreach (string idSupplier in listID)
            {
                supplier = db.tblNhaCungCaps.Find(idSupplier);
                db.tblNhaCungCaps.Remove(supplier);
                db.SaveChanges();
            }
        }
Пример #4
0
        // edit supplier
        public void FuncEditSupplier(tblNhaCungCap supplier)
        {
            var getSupplier = db.tblNhaCungCaps.Find(supplier.MaNhaCungCap);

            getSupplier.TenNhaCungCap = supplier.TenNhaCungCap;
            getSupplier.DiaChi        = supplier.DiaChi;
            getSupplier.Email         = supplier.Email;
            getSupplier.Fax           = supplier.Fax;
            getSupplier.SoDienThoai   = supplier.SoDienThoai;
            getSupplier.MaSoThue      = supplier.MaSoThue;
            db.SaveChanges();
        }
Пример #5
0
 // add new supplier
 public void FuncAddNewSupplier(tblNhaCungCap supplier)
 {
     db.tblNhaCungCaps.Add(supplier);
     db.SaveChanges();
 }