private void Loaddata()
 {
     if (frmDMOrderType.isAdd)
     {
         Reset();
         btnDelete.Enabled = false;
     }
     else
     {
         txtMa.Enabled             = false;
         dm                        = DMOrderTypeProvider.GetListDmOrderTypeInfoFromOid(frmDMOrderType.Oid);
         txtMa.Text                = dm.OrderType;
         txtTen.Text               = dm.Name;
         txtMoTa.Text              = dm.GhiChu;
         txtLine.Text              = dm.LineType;
         txtLineKm.Text            = dm.LineKm;
         txtLineCk.Text            = dm.LineCk;
         cbNganhHang.SelectedValue = dm.NganhHang;
         chkSuDung.Checked         = dm.SuDung == 1;
         txtMa.Focus();
     }
     if (frmDMOrderType.IsSync)
     {
         //không cho phép người dùng sửa, xóa các thông tin trên form.
         txtMa.Enabled     = false;
         txtTen.Enabled    = false;
         btnDelete.Enabled = false;
     }
 }
Example #2
0
        public void TestOrderType07_DeleteSuccess()
        {
            TestOrderType05_InsertSuccess();
            List <DMOrderTypeInfor> list  = DMOrderTypeProvider.GetListOrderTypeInfor();
            DMOrderTypeInfor        infor = list.Find(delegate(DMOrderTypeInfor match)
            {
                return(match.OrderType == "004001NuocNgoai");
            });

            frmDM_OrderType frm = new frmDM_OrderType();

            frm.isAdd = false;
            frm.Oid   = infor.IdOrderType;

            frmChiTiet_OrderType frmChiTietOrderType = new frmChiTiet_OrderType(frm);

            frmChiTietOrderType.TestDelete();
            list  = DMOrderTypeProvider.GetListOrderTypeInfor();
            infor = list.Find(delegate(DMOrderTypeInfor match)
            {
                return(match.OrderType == "004001NuocNgoai");
            });

            Assert.AreEqual(infor, null);
        }
 private bool Check()
 {
     if (String.IsNullOrEmpty(txtMa.Text))
     {
         txtMa.Focus();
         throw new InvalidOperationException("Mã OrderType không được để trống !");
     }
     if (String.IsNullOrEmpty(txtTen.Text))
     {
         txtTen.Focus();
         throw new InvalidOperationException("Tên OrderType không được để trống !");
     }
     if (frmDMOrderType.IsSync)
     {
         if (txtTen.Text != dm.Name)
         {
             throw new InvalidOperationException("Tên OrderType đã bị thay đổi !");
         }
         if (txtMa.Text != dm.OrderType)
         {
             throw new InvalidOperationException("Mã OrderType đã bị thay đổi !");
         }
     }
     if (frmDMOrderType.isAdd && DMOrderTypeProvider.KiemTra(new DMOrderTypeInfor {
         IdOrderType = frmDMOrderType.Oid, OrderType = txtMa.Text.Trim()
     }))
     {
         throw new InvalidOperationException("Mã OrderType đã tồn tại trong hệ thống!");
     }
     return(true);
 }
 private void Delete()
 {
     DMOrderTypeProvider.Delete(new DMOrderTypeInfor {
         IdOrderType = Oid
     });
     LoadData();
     SetControl(false);
 }
 private void ucActions1_OnDelete(object obj)
 {
     //DMOrderTypeInfor khaibao = new DMOrderTypeInfor();
     //khaibao.IdOrderType = Convert.ToInt32(getValue("clIdOrderType"));
     DMOrderTypeProvider.Delete(new DMOrderTypeInfor {
         IdOrderType = Convert.ToInt32(getValue("clIdOrderType"))
     });
     MessageBox.Show("Xóa Thành Công", "Thông Báo");
     dgvList.DataSource = DMOrderTypeProvider.GetListOrderTypeInfor();
 }
Example #6
0
 private void SetFormInfo(DMDoiTuongInfo doiTuongInfo)
 {
     txtWebSite.Text      = doiTuongInfo.WebSite;
     txtTyLePhat.Text     = Convert.ToString(doiTuongInfo.TyLePhat);
     txtTinh.Text         = doiTuongInfo.Tinh;
     txtThuNhap.Text      = Convert.ToString(doiTuongInfo.ThuNhap);
     txtTenDoiTuong.Text  = doiTuongInfo.TenDoiTuong;
     txtTaiKhoan.Text     = doiTuongInfo.TaiKhoan;
     txtSoLanMuaHang.Text = Convert.ToString(doiTuongInfo.SoLanMuaHang);
     txtSoDKKD.Text       = doiTuongInfo.SoDKKD;
     txtQuocGia.Text      = doiTuongInfo.QuocGia;
     txtPhongBan.Text     = doiTuongInfo.PhongBan;
     //lupOrderType.EditValue = doiTuongInfo.IdOrderType;
     bteOrderType.Tag          = DMOrderTypeProvider.GetListDmOrderTypeInfoFromOid(doiTuongInfo.IdOrderType);
     bteOrderType.Text         = bteOrderType.Tag == null ? String.Empty : ((DMOrderTypeInfor)bteOrderType.Tag).LineType;
     txtNguoiLienLac.Text      = doiTuongInfo.NguoiLienLac;
     txtNgheNghiep.Text        = doiTuongInfo.NgheNghiep;
     deNgaySinh.EditValue      = doiTuongInfo.NgaySinh;
     deNgayCapThe.EditValue    = doiTuongInfo.NgayCapThe;
     txtNganHang.Text          = doiTuongInfo.NganHang;
     txtMaSoThue.Text          = doiTuongInfo.MaSoThue;
     txtMaRieng.Text           = doiTuongInfo.MaRieng;
     txtMaDoiTuong.Text        = doiTuongInfo.MaDoiTuong;
     lupLoaiThe.EditValue      = doiTuongInfo.IdLoaiThe;
     txtKnownFrom.Text         = doiTuongInfo.Biet_Ta_Tu;
     txtHuyen.Text             = doiTuongInfo.Huyen;
     txtHanTra.Text            = Convert.ToString(doiTuongInfo.HanTra);
     txtHanMucTinDung.Text     = Common.Double2Str(doiTuongInfo.HanMucTinDung);
     txtHMTDConLai.Text        = Common.Double2Str(doiTuongInfo.HanMucTDConLai);
     cboGioiTinh.SelectedIndex = doiTuongInfo.GioiTinh > 2 ? 0 : doiTuongInfo.GioiTinh;
     txtGiaTriMuaHang.Text     = Common.Double2Str(doiTuongInfo.GiaTriMuaHang);
     txtFax.Text                   = doiTuongInfo.Fax;
     txtEmailDT.Text               = doiTuongInfo.Email;
     txtEmailCDN.Text              = doiTuongInfo.Email_CDN;
     txtDoTuoi.Text                = Convert.ToString(doiTuongInfo.DoTuoi);
     txtDienThoaiNLL.Text          = doiTuongInfo.DienThoai_NLL;
     txtDienThoaiDT.Text           = doiTuongInfo.DienThoai;
     txtDienThoaiCDN.Text          = doiTuongInfo.DienThoai_CDN;
     txtDiaChi.Text                = doiTuongInfo.DiaChi;
     txtCMTNLL.Text                = doiTuongInfo.CMND_NLL;
     txtCMTDT.Text                 = doiTuongInfo.SoCMND;
     txtCDN.Text                   = doiTuongInfo.ChuDoanhNghiep;
     cboLoaiDoiTuong.SelectedIndex = doiTuongInfo.Type;
     //lupDoiTuongCha.EditValue = doiTuongInfo.IdCha;
     bteDoiTuongCha.Tag        = DmDoiTuongProvider.GetDmDoiTuongInfoFromOid(doiTuongInfo.IdCha);
     bteDoiTuongCha.Text       = bteDoiTuongCha.Tag == null ? String.Empty : ((DMDoiTuongInfo)bteDoiTuongCha.Tag).TenDoiTuong;
     lupNhomDoiTuong.EditValue = doiTuongInfo.IdLoaiDoiTuong;
     txtBillTo.Text            = Convert.ToString(doiTuongInfo.BillTo);
     txtShipTo.Text            = Convert.ToString(doiTuongInfo.ShipTo);
     txtCongNoKhachHang.Text   = Common.Double2Str(doiTuongInfo.CongNoKhachHang);
 }
 private void LoadOderType()
 {
     litype = DMOrderTypeProvider.GetListOrderTypepairInfor();
     if (litype.Count > 0)
     {
         cboOrderType.DataSource    = litype;
         cboOrderType.DisplayMember = "Name";
         cboOrderType.ValueMember   = "IdOrderType";
     }
     else
     {
         cboOrderType.DataSource = null;
     }
 }
 private void SaveDoiTuong()
 {
     if (Check())
     {
         if (frmDMOrderType.isAdd)
         {
             DMOrderTypeProvider.Insert(SetDanhMuc());
         }
         else
         {
             DMOrderTypeProvider.Update(SetDanhMuc());
         }
     }
 }
        private void Delete()
        {
            if (frmDMOrderType.isAdd)
            {
                throw new InvalidOperationException("Bạn không thể xóa khi đang thêm mới!");
            }
            if (frmDMOrderType.IsSync)
            {
                throw new InvalidOperationException("Bạn không thể xóa dữ liệu được đồng bộ!");
            }

            DMOrderTypeProvider.Delete(new DMOrderTypeInfor {
                IdOrderType = frmDMOrderType.Oid
            });
        }
Example #10
0
        public void TestOrderType05_InsertSuccess()
        {
            frmDM_OrderType frm = new frmDM_OrderType();

            frm.Oid   = 0;
            frm.isAdd = true;
            frmChiTiet_OrderType frmChiTietOrderType = new frmChiTiet_OrderType(frm);

            frmChiTietOrderType.SetInput("Bán ngoài nước", "004001NuocNgoai", "Unit test OrderType", 1, "004001NN");
            frmChiTietOrderType.TestSave();
            List <DMOrderTypeInfor> list = DMOrderTypeProvider.Search(new DMOrderTypeInfor {
                OrderType = "004001NuocNgoai"
            });

            Assert.AreEqual(list.Count, 1);
        }
        private void frmDM_OrderType_Load(object sender, EventArgs e)
        {
            try
            {
                dgvList.DataSource = DMOrderTypeProvider.GetListOrderTypeInfor();
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show("Lỗi ngoại lệ: " + ex.ToString(), Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                MessageBox.Show("Lỗi ngoại lệ: " + ex.Message, Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif
                this.Dispose();
            }
        }
Example #12
0
        public frmDmOrderTypeTestUnits()
        {
            frmLogin frmLogin = new frmLogin();

            frmLogin.TestLogin("quantri", "quantri");

            //chuẩn bị dữ liệu để test
            List <DMOrderTypeInfor> list      = DMOrderTypeProvider.GetListOrderTypeInfor();
            List <DMOrderTypeInfor> listMatch = list.FindAll(delegate(DMOrderTypeInfor match)
            {
                return(match.OrderType == "004001NuocNgoai");
            });

            foreach (var dmOrderTypeInfor in listMatch)
            {
                DMOrderTypeProvider.Delete(dmOrderTypeInfor);
            }
        }
 private void ucActions1_OnValidate(object obj, ActionState actionMode)
 {
     switch (actionMode)
     {
     case ActionState.ADD:
     case ActionState.UPDATE:
         idOrderType = getEditId(obj);
         if (txtMaOrder.Text == String.Empty)
         {
             throw new Exception("Mã OrderType Không Được Để Trống!");
         }
         if (DMOrderTypeProvider.KiemTra(new DMOrderTypeInfor {
             IdOrderType = idOrderType, OrderType = txtMaOrder.Text
         }))
         {
             //todo: @HanhBD (PENDING) check delete references
             //với trường hợp update, delete thì thì phải check xem là đã có bảng nào tham chiếu đến chưa.
             //Nếu có thì không xóa mà warning người dùng và cập nhật lại sudung=0, và phải warning nếu update.
             throw new Exception("Mã OrderType Đã Tồn Tại!");
         }
         break;
     }
 }
Example #14
0
        public void TestOrderType03_MaOrderTypeHasExistedOnUpdate()
        {
            try
            {
                TestOrderType05_InsertSuccess();
                List <DMOrderTypeInfor> list  = DMOrderTypeProvider.GetListOrderTypeInfor();
                DMOrderTypeInfor        infor = list.Find(delegate(DMOrderTypeInfor match)
                {
                    return(match.OrderType == "004001NuocNgoai");
                });

                frmDM_OrderType frm = new frmDM_OrderType();
                frm.isAdd = false;
                frm.Oid   = infor.IdOrderType;
                frmChiTiet_OrderType frmChiTietOrderType = new frmChiTiet_OrderType(frm);
                frmChiTietOrderType.SetInput("Bán ngoài nước", "123", "Unit test OrderType", 1, "004001NN");
                frmChiTietOrderType.TestSave();
                list = DMOrderTypeProvider.GetListOrderTypeInfor();
                List <DMOrderTypeInfor> listDuplicate = list.FindAll(delegate(DMOrderTypeInfor match)
                {
                    return(match.OrderType == "123");
                });
                frmChiTietOrderType.TestDelete();
                Assert.AreEqual(1, listDuplicate.Count);
            }
            catch (Exception ex)
            {
                if (ex.GetType() != typeof(AssertFailedException))
                {
                    Assert.AreEqual(ex.Message, "Mã OrderType đã tồn tại trong hệ thống!");
                }
                else
                {
                    throw;
                }
            }
        }
 protected override void LoadData()
 {
     grcBase.DataSource = DMOrderTypeProvider.GetListOrderTypeInfor();
     btnTimKiem.Text    = Resources.btnSearch;
 }
 private void btnTimKiem_Click(object sender, EventArgs e)
 {
     grcBase.DataSource = DMOrderTypeProvider.Search(new DMOrderTypeInfor {
         OrderType = txtTimKiemMa.Text.Trim(), Name = txtTimKiemTen.Text.Trim()
     });
 }
 private void ucActions1_OnUpdate(object obj)
 {
     DMOrderTypeProvider.Update(getinfor());
     MessageBox.Show("Sửa bảng thành công!");
     dgvList.DataSource = DMOrderTypeProvider.GetListOrderTypeInfor();
 }
 protected override void OnLoad()
 {
     ListInitInfo = DMOrderTypeProvider.GetListOrderTypeInfor();
 }
 private void ucActions1_OnAdd(object obj)
 {
     DMOrderTypeProvider.Insert(getinfor());
     MessageBox.Show("Thêm bảng thành công!");
     dgvList.DataSource = DMOrderTypeProvider.GetListOrderTypeInfor();
 }