private void btnThemTaiKhoan_Click_1(object sender, EventArgs e)
        {
            Object.ObjCustomerGroup ctg = new Object.ObjCustomerGroup();
            if (checkNullItem())
            {
                GanDuLieu(ctg);
                {
                    switch (customerGroupCtrl.Them(ctg))
                    {
                    case 1:
                        MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LamMoi();
                        break;

                    case 2:
                        text = "Vui lòng chọn tên nhóm khác!";
                        ThongBao(text);
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show("Vui lòng điền đầu đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#2
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (checkNullTextBox() == false)
            {
                MessageBox.Show("Xin mời nhập đầy đủ thông tin!", "Cảnh báo");
            }
            else
            {
                Object.ObjCustomerGroup objCustomerGroup = new Object.ObjCustomerGroup();
                SetDataCustomerGroup(objCustomerGroup);

                DialogResult dlg = MessageBox.Show("Bạn có chắc chắn muốn đổi dữ liệu này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dlg == DialogResult.Yes)
                {
                    switch (cutomerGroupCtrl.Update(objCustomerGroup))
                    {
                    case -1:
                    {
                        MessageBox.Show("Vui lòng chọn tên nhóm khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }

                    default:
                    {
                        MessageBox.Show("Lưu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        CustomerGroupManage.HienThi(dgvListCustomerGroup);
                        HienThiThongTin();
                        break;
                    }
                    }
                }
            }
        }
示例#3
0
 public int Them(Object.ObjCustomerGroup customerGroup)
 {
     if (!KTTenNhom(customerGroup.Name_Group))
     {
         return(2);
     }
     return(customerGroupMng.Save(customerGroup));
 }
        public int Save(Object.ObjCustomerGroup ctg)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "INSERT INTO Customer_Group (Name_Group) VALUES (@name)";

            cmd.Parameters.Add("name", SqlDbType.NVarChar).Value = ctg.Name_Group;
            return(cls.CapNhatDL(cmd));
        }
示例#5
0
 public int Update(Object.ObjCustomerGroup customerGroup)
 {
     if (!checkCustomerGroup(customerGroup.Name_Group))
     {
         return(-1);
     }
     else
     {
         return(customerGroupMng.Update(customerGroup));
     }
 }
        public int Update(Object.ObjCustomerGroup customerGroup)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "UPDATE Customer_Group SET Name_Group = @name WHERE Id_Group = @idGroup;";

            cmd.Parameters.Add("name", SqlDbType.NVarChar).Value = customerGroup.Name_Group;
            cmd.Parameters.Add("idGroup", SqlDbType.Int).Value   = customerGroup.Id_Group;

            return(cls.CapNhatDL(cmd));
        }
 //Hàm xử lý lưu dữ liệu.
 private void GanDuLieu(Object.ObjCustomerGroup customerGroup)
 {
     customerGroup.Name_Group = txtName_Group.Text.Trim();
 }
示例#8
0
 private void SetDataCustomerGroup(Object.ObjCustomerGroup customerGroup)
 {
     customerGroup.Id_Group   = txtId_Group.Text;
     customerGroup.Name_Group = txtName_Group.Text;
 }