private void btnthemthe_Click(object sender, EventArgs e) { string mathe = txtmathe.Text; eThethanhvien k = new eThethanhvien(); k.Mathe = txtmathe.Text; k.Makh = txtmakh.Text; k.Diemtichluy = Convert.ToInt32(txtdiemtichluy.Text); k.Tongtien = Convert.ToInt32(txttongtien.Text); k.Ngaylap = Convert.ToDateTime(dtpngaylap.Text); k.Ngayhethan = Convert.ToDateTime(dtpngayhethan.Text); k.Ghichu = txtghichu.Text; int kq = thetvbll.AddThe(k); if (kq == 1) { MessageBox.Show("them thanh cong"); } else { MessageBox.Show("Thêm Thất Bại!Kiểm Tra Chùng Mã."); } dgvthethanhvien.DataSource = thetvbll.GetAllTheThanhVien(); }
private void btnluu_Click(object sender, EventArgs e) { txtmathe.Text = dgvthethanhvien.CurrentRow.Cells[3].Value.ToString(); txtmakh.Text = dgvthethanhvien.CurrentRow.Cells[4].Value.ToString(); txtdiemtichluy.Text = dgvthethanhvien.CurrentRow.Cells[5].Value.ToString(); eThethanhvien kh = new eThethanhvien(); kh.Makh = txtmakh.Text.Trim(); kh.Mathe = txtmathe.Text.Trim(); kh.Ghichu = txtghichu.Text.Trim(); // kh.Diemtichluy = Convert.ToInt32(txtdiemtichluy.Text.Trim()); kh.Tongtien = Convert.ToInt32(txttongtien.Text.Trim()); kh.Ngayhethan = Convert.ToDateTime(dtpngayhethan.Text.Trim()); kh.Ngaylap = Convert.ToDateTime(dtpngaylap.Text.Trim()); bool kq = thetvbll.UpdateThe(kh); if (kq == false) { MessageBox.Show("Không có mã để sửa!", "Thông báo!"); } else { MessageBox.Show("Sửa thành công!", "Thông báo!"); dgvthethanhvien.DataSource = thetvbll.GetAllTheThanhVien(); } EnableButton(true); btnLuu.Enabled = true; DisableTextbox(true); btnsua.Text = "Sua"; }
/*public bool Delete(string deleteID) * { * try * { * Tbl_KhachHang deleteRecord = DB.Tbl_KhachHangs.Single(record => record.maKH == deleteID); * * DB.Tbl_KhachHangs.DeleteOnSubmit(deleteRecord); * DB.SubmitChanges(); * * return true; * } * catch { return false; } * }*/ public bool UpdateThe(eThethanhvien updateThe) { try { Tbl_TheThanhVien updateRecord = DB.Tbl_TheThanhViens.Single(record => record.maThe == updateThe.Mathe); updateRecord.maKH = updateThe.Makh; updateRecord.diemTichLuy = Convert.ToInt32(updateThe.Diemtichluy); updateRecord.ngayLap = updateThe.Ngaylap; updateRecord.ngayHetHan = updateThe.Ngayhethan; updateRecord.ghiChu = updateThe.Ghichu; updateRecord.tongTien = Convert.ToDecimal(updateThe.Tongtien); DB.SubmitChanges(); return(true); } catch { return(false); } }
public List <eThethanhvien> GetAllTheThanhVien() { var dsthe = DB.Tbl_TheThanhViens.ToList(); List <eThethanhvien> listThe = new List <eThethanhvien>(); foreach (Tbl_TheThanhVien the_DAL in dsthe) { eThethanhvien ethe = new eThethanhvien(); ethe.Mathe = the_DAL.maThe; ethe.Ngayhethan = Convert.ToDateTime(the_DAL.ngayHetHan); ethe.Makh = the_DAL.maKH; ethe.Ghichu = the_DAL.ghiChu; ethe.Ngaylap = Convert.ToDateTime(the_DAL.ngayLap); ethe.Tongtien = (float)the_DAL.tongTien; listThe.Add(ethe); } return(listThe); }
/* private eThethanhvien eThethanhvien() * { * throw new NotImplementedException(); * }*/ public int AddThe(eThethanhvien the) { var mathe = DB.Tbl_TheThanhViens.Where(x => x.maThe == the.Makh).FirstOrDefault(); if (mathe != null) { return(0); } Tbl_TheThanhVien khTmp = new Tbl_TheThanhVien(); khTmp.maThe = the.Mathe; khTmp.maKH = the.Makh; khTmp.tongTien = Convert.ToDecimal(the.Tongtien); khTmp.ngayHetHan = the.Ngayhethan; khTmp.ngayLap = the.Ngaylap; khTmp.ghiChu = the.Ghichu; DB.Tbl_TheThanhViens.InsertOnSubmit(khTmp); DB.SubmitChanges(); return(1); }