Пример #1
0
        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();
            }
        }
Пример #2
0
 public Customer(string firstName, string lastName, int id, CustomersType customerType)
 {
     this.FirstName    = firstName;
     this.LastName     = lastName;
     this.ID           = id;
     this.CustomerType = customerType;
 }
Пример #3
0
        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");
            }
        }
Пример #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            CustomersType customersType = db.CustomersTypes.Find(id);

            db.CustomersTypes.Remove(customersType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        private void _LoadNhomDoiTac()
        {
            DataTable NhomDT = CustomersType.GetAll();

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

            lookUpEdit_Nhom.Properties.DataSource    = NhomDT;
            lookUpEdit_Nhom.Properties.DisplayMember = "Name";
            lookUpEdit_Nhom.Properties.ValueMember   = "Code";
        }
Пример #7
0
 private void _ClearForm()
 {
     txtMa.Enabled  = true;
     txtMa.Text     = "";
     txtTen.Text    = "";
     txtGhiChu.Text = "";
     txtMa.Text     = "";
     _cusType       = null;
 }
Пример #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));
 }
Пример #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));
        }
Пример #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));
        }
Пример #11
0
        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);
        }
Пример #12
0
 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 {}
 }
Пример #13
0
 public frmCustomerType()
 {
     InitializeComponent();
     _cusType = null;
 }
Пример #14
0
        private void _LoadDSNHom()
        {
            DataTable list = CustomersType.GetAll();

            gridControl1.DataSource = list;
        }
Пример #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;
 }