private void Delete() { DmLoaitheKhachHangProvider.Delete(new DMLoaiTheKhachHangInfo { IdLoaiThe = Oid }); MessageBox.Show("Xóa thành công bản ghi !"); LoadData(); SetControl(false); }
private bool Check() { if (String.IsNullOrEmpty(txtMaThe.Text)) { txtMaThe.Focus(); throw new InvalidOperationException("Mã thẻ không được để trống !"); } if (String.IsNullOrEmpty(txtTenThe.Text)) { txtTenThe.Focus(); throw new InvalidOperationException("Tên thẻ không được để trống !"); } if (String.IsNullOrEmpty(txtHieuLuc.Text)) { txtHieuLuc.Focus(); throw new InvalidOperationException("Hiệu lực không được để trống !"); } if (String.IsNullOrEmpty(txtGiaTriMuaLanDau.Text)) { txtGiaTriMuaLanDau.Focus(); throw new InvalidOperationException("Giá trị mua lần đầu không được để trống !"); } if (String.IsNullOrEmpty(txtTichLuyTu.Text)) { txtTichLuyTu.Focus(); throw new InvalidOperationException("Tích lũy tư không được để trống !"); } if (String.IsNullOrEmpty(txtTichLuyDen.Text)) { txtTichLuyDen.Focus(); throw new InvalidOperationException("Tích lũy điểm không được để trống !"); } if (String.IsNullOrEmpty(txtBaoLuuDiem.Text)) { txtBaoLuuDiem.Focus(); throw new InvalidOperationException("Bảo lưu điểm không được để trống !"); } if (frmThe.IsSync) { if (txtTenThe.Text != dm.TenThe) { throw new InvalidOperationException("Tên thẻ đã bị thay đổi !"); } if (txtMaThe.Text != dm.MaThe) { throw new InvalidOperationException("Mã thẻ đã bị thay đổi !"); } } if (DmLoaitheKhachHangProvider.KiemTra(new DMLoaiTheKhachHangInfo { IdLoaiThe = frmThe.Oid, MaThe = txtMaThe.Text.Trim() })) { throw new InvalidOperationException("Mã thẻ đã tồn tại trong hệ thống !"); } return(true); }
private void Delete() { if (frmThe.isAdd) { throw new InvalidOperationException("Bạn không thể xóa khi đang thêm mới!"); } if (frmThe.IsSync) { throw new InvalidOperationException("Bạn không thể xóa dữ liệu được đồng bộ!"); } DmLoaitheKhachHangProvider.Delete(new DMLoaiTheKhachHangInfo { IdLoaiThe = frmThe.Oid }); }
private void btnLoc_Click(object sender, EventArgs e) { #region old //string dk="1=1"; //if (txtMaTheLoc.Text.Trim() != "") dk += string.Format(" and MaThe Like N'%{0}%'", txtMaTheLoc.Text.Trim()); //if (txtTenTheLoc.Text.Trim() != "") dk += string.Format(" and TenThe Like N'%{0}%'", txtTenTheLoc.Text.Trim()); //if (txtGhiChuLoc.Text.Trim() != "") dk += string.Format(" and GhiChu Like N'%{0}%'", txtGhiChuLoc.Text.Trim()); //sLocThe(dk); #endregion dgvLoaiThe.DataSource = DmLoaitheKhachHangProvider.Search(new DMLoaiTheKhachHangInfo { TenThe = txtTenTheLoc.Text.Trim(), MaThe = txtMaTheLoc.Text.Trim() }); }
private void Delete() { if (MessageBox.Show("bạn có chắc chắn muốn xóa bản ghi này ?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes) { //DmLoaiTheKhachHangInfo dm = new DmLoaiTheKhachHangInfo(); //dm.IdLoaiThe = OidThe; DmLoaitheKhachHangProvider.Delete(new DMLoaiTheKhachHangInfo { IdLoaiThe = OidThe }); MessageBox.Show("Xóa thành công bản ghi !"); //this.Close(); LoadData(); SetControl(false); } }
public void TestThe05_InsertSuccess() { frmDM_The frm = new frmDM_The(); frm.Oid = 0; frm.isAdd = true; frmChiTiet_The frmChiTietThe = new frmChiTiet_The(frm); frmChiTietThe.SetInput("Thẻ số 1", "1111", 100, 150, 555000, 55, 2, 3); frmChiTietThe.TestSave(); List <DMLoaiTheKhachHangInfo> list = DmLoaitheKhachHangProvider.Search(new DMLoaiTheKhachHangInfo { TenThe = "Thẻ số 1", MaThe = "1111" }); Assert.AreEqual(list.Count, 1); }
public frmDmTheTestUnits() { frmLogin frmLogin = new frmLogin(); frmLogin.TestLogin("quantri", "quantri"); //chuẩn bị dữ liệu để test List <DMLoaiTheKhachHangInfo> list = DmLoaitheKhachHangProvider.GetListDmLoaiTheInfor(); if (list != null) { List <DMLoaiTheKhachHangInfo> listMatch = list.FindAll(delegate(DMLoaiTheKhachHangInfo match) { return(match.MaThe == "1111"); }); foreach (var dmTheInfor in listMatch) { DmLoaitheKhachHangProvider.Delete(dmTheInfor); } } }
public void TestThe07_DeleteSuccess() { TestThe05_InsertSuccess(); List <DMLoaiTheKhachHangInfo> list = DmLoaitheKhachHangProvider.GetListDmLoaiTheInfor(); DMLoaiTheKhachHangInfo infor = list.Find(delegate(DMLoaiTheKhachHangInfo match) { return(match.MaThe == "1111"); }); frmDM_The frm = new frmDM_The(); frm.isAdd = false; frm.Oid = infor.IdLoaiThe; frmChiTiet_The frmChiTietThe = new frmChiTiet_The(frm); frmChiTietThe.TestDelete(); list = DmLoaitheKhachHangProvider.GetListDmLoaiTheInfor(); infor = list.Find(delegate(DMLoaiTheKhachHangInfo match) { return(match.MaThe == "1111"); }); Assert.AreEqual(infor, null); }
private void SaveLoaiThe() { if (Check()) { try { ConnectionUtil.Instance.BeginTransaction(); if (frmThe.isAdd) { int OidLoaiThe = DmLoaitheKhachHangProvider.Insert(SetLoaiThe()); SaveQuyenLoi(OidLoaiThe); SaveUuDai(OidLoaiThe); ConnectionUtil.Instance.CommitTransaction(); } else { //dm = new DMLoaiTheKhachHangInfo(); //dm = SetLoaiThe(); //dm.IdLoaiThe = frmThe.Oid; DmLoaitheKhachHangProvider.Update(SetLoaiThe()); SaveQuyenLoi(frmThe.Oid); SaveUuDai(frmThe.Oid); ConnectionUtil.Instance.CommitTransaction(); } } catch (Exception) { ConnectionUtil.Instance.RollbackTransaction(); throw; } //this.Close(); //frmThe.ReLoad(); //frmThe.SetControl(false); } }
public void TestThe03_MaTheHasExistedOnUpdate() { try { TestThe05_InsertSuccess(); List <DMLoaiTheKhachHangInfo> list = DmLoaitheKhachHangProvider.GetListDmLoaiTheInfor(); DMLoaiTheKhachHangInfo infor = list.Find(delegate(DMLoaiTheKhachHangInfo match) { return(match.MaThe == "1111"); }); frmDM_The frm = new frmDM_The(); frm.isAdd = false; frmChiTiet_The frmChiTietThe = new frmChiTiet_The(frm); frmChiTietThe.SetInput("Thẻ số 1 ", "12345", 100, 150, 555000, 55, 2, 3); frmChiTietThe.TestSave(); list = DmLoaitheKhachHangProvider.GetListDmLoaiTheInfor(); List <DMLoaiTheKhachHangInfo> listDuplicate = list.FindAll(delegate(DMLoaiTheKhachHangInfo match) { return(match.MaThe == "12345"); }); frmChiTietThe.TestDelete(); Assert.AreEqual(1, listDuplicate.Count); } catch (Exception ex) { if (ex.GetType() != typeof(AssertFailedException)) { Assert.AreEqual(ex.Message, "Mã thẻ đã tồn tại trong hệ thống !"); } else { throw; } } }
private void btnLoc_Click(object sender, EventArgs e) { grcBase.DataSource = DmLoaitheKhachHangProvider.Search(new DMLoaiTheKhachHangInfo { TenThe = txtTenTheLoc.Text.Trim(), MaThe = txtMaTheLoc.Text.Trim() }); }
protected override void LoadData() { grcBase.DataSource = DmLoaitheKhachHangProvider.GetListDmLoaiTheInfo(); btnLoc.Text = Resources.btnSearch; }
private void LoadData() { if (frmThe.isAdd) { txtBaoLuuDiem.Text = ""; txtTinhNangKhac.Text = ""; txtTichLuyTu.Text = ""; txtTichLuyDen.Text = ""; txtTenThe.Text = ""; txtMaThe.Text = ""; txtHieuLuc.Text = ""; txtGiaTriMuaLanDau.Text = ""; txtMaThe.Focus(); btnXoa.Enabled = false; } else { dm = DmLoaitheKhachHangProvider.GetListDmLoaiTheInfoFromIdLoaiThe(frmThe.Oid); dmtheQL = DmLoaitheQuyenLoiProvider.GetListLoaiTheQuyenLoiInfoFromOid(frmThe.Oid); dmTheUD = DmLoaitheUuDaiProvider.GetListDmLoaiTheUuDaiInfoFromOid(frmThe.Oid); txtMaThe.Text = dm.MaThe; txtTenThe.Text = dm.TenThe; txtTinhNangKhac.Text = dm.GhiChu; txtTichLuyTu.Text = dm.DK_GT_TichLuy_Tu.ToString(); txtTichLuyDen.Text = dm.DK_GT_TichLuy_Den.ToString(); txtHieuLuc.Text = dm.ThoiGianHieuLuc.ToString(); txtGiaTriMuaLanDau.Text = dm.DK_GT_LanDau.ToString(); txtBaoLuuDiem.Text = dm.BaoLuuDiem.ToString(); cboDoUuTien.SelectedItem = dm.DoUuTien; if (dm.DK_SP_KemTheo != null) { string[] sp = dm.DK_SP_KemTheo.Split(','); for (int i = 0; i < sp.Length; i++) { for (int j = 0; j < liSP.Count; j++) { if (sp[i].ToString().ToUpper() == liSP[j].TenSanPham.ToUpper()) { chkLstSanPham.SetItemChecked(j, true); } } } } chkBaoHanhVang.Checked = dm.IsBHVang == 1; chkThamGiaDaoTao.Checked = dm.IsJointCourse == 1; chkSuDung.Checked = dm.SuDung == 1; chkDuocTuVanHoTro.Checked = dm.IsSupport == 1; chkTangQuaSinhNhat.Checked = dm.IsTangQuaSN == 1; chkThamGiaDaoTao.Checked = dm.IsJointCourse == 1; chkBaoHanhVang.Checked = dm.IsBHVang == 1; chkCapNhatThongTinSanPhamMoi.Checked = dm.IsUpdateSPNew == 1; dgvQuyenLoi.DataSource = new BindingList <DmLoaiTheQuyenLoiInfo>(dmtheQL) { AllowNew = true, AllowEdit = true, AllowRemove = true }; dgvUuDai.DataSource = new BindingList <DmLoaiTheUuDaiInfo>(dmTheUD) { AllowNew = true, AllowEdit = true, AllowRemove = true }; } if (frmThe.IsSync) { //không cho phép người dùng sửa, xóa các thông tin trên form. txtMaThe.Enabled = false; txtTenThe.Enabled = false; btnXoa.Enabled = false; } }
private void LoadLoaiTheKhachHang() { lupLoaiThe.Properties.DataSource = DmLoaitheKhachHangProvider.GetCboDmLoaiTheInfo(); lupLoaiThe.Properties.DisplayMember = "TenThe"; lupLoaiThe.Properties.ValueMember = "IdLoaiThe"; }
//private void sLocThe(string dk) //{ // string sql = "SELECT * FROM tbl_DM_LoaiThe_KhachHang WHERE " + dk; // dgvLoaiThe.DataSource = ut.getDataTable(sql); // for (int i = 0; i < dgvLoaiThe.Rows.Count; i++) // dgvLoaiThe.Rows[i].Cells["colTT"].Value = i + 1; //} //private bool DuLieuHopLe() //{ // if (txtMaThe.Text.Trim() == "" || txtTenThe.Text.Trim() == "") // { // MessageBox.Show("Mã thẻ, tên thẻ chưa đủ"); // return false; // } // //Kiem tra trung ma // string sql = string.Format("SELECT IDLoaiThe FROM tbl_DM_LoaiThe_KhachHang WHERE MaThe='{0}'", txtMaThe.Text); // if (g1Sua) sql += " And IdLoaiThe<>" + g1LoaiThe.Id.ToString(); // int ID = ut.fGetID_sql(sql); // if (ID > 0) // { // MessageBox.Show("Trùng mã thẻ. Mời nhập lại"); // return false; // } // return true; //} //private void sLoad_LoaiThe(int IdLoaiThe) //{ // g1LoaiThe.getLoaiThe(IdLoaiThe); // txtMaThe.Text = g1LoaiThe.MaThe; // txtTenThe.Text = g1LoaiThe.TenThe; // cboDoUuTien.Text = g1LoaiThe.DoUuTien.ToString(); // txtHieuLuc.Text = g1LoaiThe.ThoiGianHieuLuc.ToString(); // txtTinhNangKhac.Text = g1LoaiThe.GhiChu; // chkCapNhatThongTinSanPhamMoi.Checked = g1LoaiThe.DuocCapNhatSanPhamMoi; // chkThamGiaDaoTao.Checked = g1LoaiThe.DuocThamGiaDaoTao; // chkDuocTuVanHoTro.Checked = g1LoaiThe.DuocTuVanHoTro; // txtBaoLuuDiem.Text = g1LoaiThe.BaoLuuDiem.ToString(); // chkTangQuaSinhNhat.Checked = g1LoaiThe.DuocTangQuaSinhNhat; // chkBaoHanhVang.Checked = g1LoaiThe.DuocBaoHanhVang; // txtGiaTriMuaLanDau.Text = this.txtGiaTriMuaLanDau.Text = Common.Double2Str(g1LoaiThe.Dk_GiaTri_LanDau);// g1LoaiThe.Dk_GiaTri_LanDau.ToString(); // txtTichLuyTu.Text = Common.Double2Str(g1LoaiThe.Dk_GiaTri_TichLuy_Tu); // txtTichLuyDen.Text = Common.Double2Str(g1LoaiThe.Dk_GiaTri_TichLuy_Den); // //Load Quyen Loi // dgvQuyenLoi.DataSource=null; // dgvQuyenLoi.Rows.Clear(); // g1QuyenLoi_Count = 0; // foreach (LoaiThe_QuyenLoi tmp in g1LoaiThe.LstQuyenLoi) // { // g1QuyenLoi_Count++; // dgvQuyenLoi.Rows.Add(g1QuyenLoi_Count,tmp.IdSanPham, tmp.TyleGiam); // } // //Load Uu dai // dgvUuDai.DataSource = null; // dgvUuDai.Rows.Clear(); // g1UuDai_Count = 0; // foreach (LoaiThe_UuDai tmp in g1LoaiThe.LstUuDai) // { // g1UuDai_Count++; // dgvUuDai.Rows.Add(g1UuDai_Count,tmp.DichVu, tmp.UuDai); // } // chkSuDung.Checked = g1LoaiThe.SuDung; // string Ds_SanPham_KemTheo = g1LoaiThe.Dk_SanPham_KemTheo + ","; // for (int i = 0; i < chkLstSanPham.Items.Count; i++) // { // if (Ds_SanPham_KemTheo.IndexOf(g1Lst_IdSanPham[i].ToString() + ",") > -1) // chkLstSanPham.SetItemChecked(i, true); // else // chkLstSanPham.SetItemChecked(i, false); // } //} //private void sCapNhat() //{ // if (!DuLieuHopLe()) return; // //Gan gia tri tu form vao g1LoaiThe // g1LoaiThe.MaThe = txtMaThe.Text; // g1LoaiThe.TenThe = txtTenThe.Text; // g1LoaiThe.DoUuTien = ut.getInt(cboDoUuTien.Text); // g1LoaiThe.ThoiGianHieuLuc = ut.getInt(txtHieuLuc.Text); // g1LoaiThe.GhiChu = txtTinhNangKhac.Text; // g1LoaiThe.DuocCapNhatSanPhamMoi = chkCapNhatThongTinSanPhamMoi.Checked; // g1LoaiThe.DuocThamGiaDaoTao = chkThamGiaDaoTao.Checked; // g1LoaiThe.DuocTuVanHoTro = chkDuocTuVanHoTro.Checked; // g1LoaiThe.BaoLuuDiem = ut.getDouble(txtBaoLuuDiem.Text);///100; // g1LoaiThe.DuocTangQuaSinhNhat = chkTangQuaSinhNhat.Checked; // g1LoaiThe.DuocBaoHanhVang = chkBaoHanhVang.Checked; // g1LoaiThe.Dk_GiaTri_LanDau = ut.getDouble(txtGiaTriMuaLanDau.Text); // g1LoaiThe.Dk_GiaTri_TichLuy_Tu = ut.getDouble(txtTichLuyTu.Text); // g1LoaiThe.Dk_GiaTri_TichLuy_Den = ut.getDouble(txtTichLuyDen.Text); // g1LoaiThe.SuDung = chkSuDung.Checked; // g1LoaiThe.Dk_SanPham_KemTheo = fGet_DS_IdSanPham(); // if (g1Sua == false) // { // bool kq = g1LoaiThe.AddNew(); // if (kq == false) // MessageBox.Show("Không thêm mới được"); // else // MessageBox.Show("Dữ liệu đã được thêm mới"); // g1Sua = true; // sLocThe("1=1"); // } // else // { // g1LoaiThe.Update(); // MessageBox.Show("Dữ liệu đã được sửa"); // //Gan lai cac o trong dgvLoaiThe // int r = dgvLoaiThe.CurrentRow.Index; // dgvLoaiThe.Rows[r].Cells["colMaThe"].Value=g1LoaiThe.MaThe; // dgvLoaiThe.Rows[r].Cells["colTenThe"].Value=g1LoaiThe.TenThe; // dgvLoaiThe.Rows[r].Cells["colGhiChu"].Value=g1LoaiThe.GhiChu; // dgvLoaiThe.Rows[r].Cells["colSuDung"].Value = g1LoaiThe.SuDung; // } // btnThemMoi.Enabled = true; //} //private string fGet_DS_IdSanPham() //{ // string kq = ""; // for (int i = 0; i < chkLstSanPham.Items.Count; i++) // { // if (chkLstSanPham.GetItemChecked(i)) // kq += g1Lst_IdSanPham[i].ToString() + ","; // } // return kq.Trim(','); //} #endregion #region LoadData private void LoadData() { dgvLoaiThe.DataSource = DmLoaitheKhachHangProvider.GetListDmLoaiTheInfo(); }