Beispiel #1
0
 void gandulieu(ClassKhachhang kh)
 {
     kh.Ma = txtMaKH.Text.Trim();
     if (cbGioiTinh.SelectedIndex == 0)
     {
         kh.Gioitinh = "Nam";
     }
     else
     {
         kh.Gioitinh = "Nữ";
     }
     kh.Gioitinh = cbGioiTinh.Text.Trim();
     kh.Diachi   = txtDiaChi.Text.Trim();
     kh.Sdt      = txtSDT.Text.Trim();
     kh.Ten      = txtTenKH.Text.Trim();
 }
Beispiel #2
0
        private void btnluu_Click(object sender, EventArgs e)
        {
            ClassKhachhang kh2 = new ClassKhachhang();

            gandulieu(kh2);
            if (txtMaKH.Text == "" || txtTenKH.Text == "" || txtDiaChi.Text == "" || cbGioiTinh.Text == "" || txtSDT.Text == "")
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dis_end(true);
            }
            else
            {
                if (flag == 0)
                {
                    if (khctrl.AddData(kh2))
                    {
                        MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    if (khctrl.UpdData(kh2))
                    {
                        MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Sửa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                dis_end(false);
                frmkhachhang_Load(sender, e);
            }
        }