private void btnDel_Click(object sender, EventArgs e) { KhachhangBUL cls = new KhachhangBUL(); KhachhangPublic p = new KhachhangPublic(); int r = dataGridView1.CurrentCell.RowIndex; string Makhachhang = dataGridView1.Rows[r].Cells[0].Value.ToString(); p.MaKH1 = Makhachhang; cls.XoaKhachhang(p); frmKhachhang_Load(sender, e); }
private void btnOK_Click(object sender, EventArgs e) { KhachhangBUL cls = new KhachhangBUL(); KhachhangPublic p = new KhachhangPublic(); p.MaKH1 = txtMakh.Text.Trim(); p.HoTen1 = txtHoten.Text.Trim(); p.CMND1 = txtCmnd.Text.Trim(); p.GioiTinh1 = txtGtinh.Text.Trim(); //string NgaySinh = DateTime.ParseExact(dtpNgdk.Value.ToString(), "dd/MM/yyyy h:mm:ss tt", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy"); p.NgSinh1 = dtpNgsinh.Value.Date.ToString("MM/dd/yyyy"); p.NgayDK1 = dtpNgdk.Value.Date.ToString("MM/dd/yyyy"); p.DiaChi1 = txtDchi.Text.Trim(); p.DThoai1 = txtDthoai.Text.Trim(); p.Diem1 = Convert.ToInt32(txtDiem.Text.Trim()); p.LoaiKh1 = txtLoaikh.Text.Trim(); if (IorU == true) { cls.ThemKhachhang(p); } else if (IorU == false) { cls.SuaKhachhang(p); dtpNgdk.DataBindings.Clear(); dtpNgsinh.DataBindings.Clear(); for (int i = 0; i < chua.Count(); i++) { chua[i].DataBindings.Clear(); } } for (int i = 0; i < chua.Count(); i++) { chua[i].Clear(); chua[i].Enabled = false; } dtpNgdk.Enabled = false; dtpNgsinh.Enabled = false; btnInsert.Enabled = true; btnUpdate.Enabled = true; btnDel.Enabled = true; btnOK.Enabled = false; btnCancel.Enabled = false; btnRefresh.Enabled = true; frmKhachhang_Load(sender, e); }