private void Luu()
        {
            CustomersType temp = _getFormInfo();

            if (temp != null)
            {
                if (status == "NEW") //thêm mới
                {
                    try
                    {
                        txtMa.Text = CustomersType.Insert(temp).ToString();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                else if (status == "EDIT")
                {
                    temp.Code = long.Parse(txtMa.Text);
                    CustomersType.Update(temp);
                }
                _setFormStatus("NORMAL");
                _LoadDSNHom();
            }
        }
Exemple #2
0
 public Customer(string firstName, string lastName, int id, CustomersType customerType)
 {
     this.FirstName    = firstName;
     this.LastName     = lastName;
     this.ID           = id;
     this.CustomerType = customerType;
 }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (status == "NORMAL")
            {
                if (_cusType != null)
                {
                    try
                    {
                        //if (_phanQuyen == null || _phanQuyen.Xoa == false)
                        //{
                        //    MessageBox.Show("Không có quyền thực hiện chức năng này", "Phân quyền", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //    return;
                        //}
                        CustomersType.Delete(long.Parse(txtMa.Text));

                        _ClearForm();

                        _LoadDSNHom();
                        _setFormStatus("NORMAL");
                    }
                    catch
                    {
                        MessageBox.Show("Không thể xoá loại khách hàng đang sử dụng");
                    }
                }
                else
                {
                    MessageBox.Show("Chưa có loại khách hàng được chọn");
                }
            }
            else
            {
                _setFormStatus("NORMAL");
            }
        }
Exemple #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            CustomersType customersType = db.CustomersTypes.Find(id);

            db.CustomersTypes.Remove(customersType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private void _LoadNhomDoiTac()
        {
            DataTable NhomDT = CustomersType.GetAll();

            ItemLookUp_Nhom.DisplayMember = "Name";
            ItemLookUp_Nhom.ValueMember   = "Code";
            ItemLookUp_Nhom.DataSource    = NhomDT;
        }
Exemple #6
0
        private void _LoadCustomersType()
        {
            DataTable NhomDT = CustomersType.GetAll();

            lookUpEdit_Nhom.Properties.DataSource    = NhomDT;
            lookUpEdit_Nhom.Properties.DisplayMember = "Name";
            lookUpEdit_Nhom.Properties.ValueMember   = "Code";
        }
 private void _ClearForm()
 {
     txtMa.Enabled  = true;
     txtMa.Text     = "";
     txtTen.Text    = "";
     txtGhiChu.Text = "";
     txtMa.Text     = "";
     _cusType       = null;
 }
Exemple #8
0
 public ActionResult Edit([Bind(Include = "CustomersTypeId,Name")] CustomersType customersType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customersType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customersType));
 }
Exemple #9
0
        public ActionResult Create([Bind(Include = "CustomersTypeId,Name")] CustomersType customersType)
        {
            if (ModelState.IsValid)
            {
                db.CustomersTypes.Add(customersType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customersType));
        }
Exemple #10
0
        // GET: CustomersTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomersType customersType = db.CustomersTypes.Find(id);

            if (customersType == null)
            {
                return(HttpNotFound());
            }
            return(View(customersType));
        }
        private CustomersType _getFormInfo()
        {
            CustomersType nhom = null;

            if (txtTen.Text != "")
            {
                nhom = new CustomersType();
                //nhom.Ma = int.Parse(txtMa.Text);
                nhom.Name = txtTen.Text;
                nhom.Note = txtGhiChu.Text;
            }
            else
            {
                MessageBox.Show("Nhập vào tên loại khách hàng");
                txtTen.Focus();
            }

            return(nhom);
        }
 private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     try
     {
         int k = gridView1.SelectedRowsCount;
         if (k > 0)
         {
             int RowHandle = gridView1.FocusedRowHandle;
             if (RowHandle >= 0)
             {
                 _cusType      = new CustomersType();
                 _cusType.Code = int.Parse(gridView1.GetRowCellValue(RowHandle, colMa).ToString());
                 _cusType.Name = gridView1.GetRowCellValue(RowHandle, colTen).ToString();
                 _cusType.Note = gridView1.GetRowCellValue(RowHandle, colGhiChu).ToString();
                 _SetFormInfo();
                 _setFormStatus("NORMAL");
             }
         }
     }
     catch {}
 }
 public frmCustomerType()
 {
     InitializeComponent();
     _cusType = null;
 }
        private void _LoadDSNHom()
        {
            DataTable list = CustomersType.GetAll();

            gridControl1.DataSource = list;
        }
Exemple #15
0
 public Customer(int id, string firstName, string lastName, string phoneNumber, string address, string username, string password, string email, CustomersType customersType)
     : base(id, firstName, lastName, phoneNumber, address, username, password, email)
 {
     Type = customersType;
 }