Exemplo n.º 1
0
        private void btnInPhieu_Click(object sender, EventArgs e)
        {
            frmChonBaoCao frm = new frmChonBaoCao(true);

            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                if (frm.Value == 1)
                {
                    DMSanPhamInfo sp = DmSanPhamProvider.Instance.GetSanPhamByMa(txtMaThanhPham.Text.Trim());
                    foreach (ChungTuNhapNccChiTietHangHoaInfo pt in liMaVach)
                    {
                        if (pt.ThoiHanBH != 0)
                        {
                            pt.ThoiHanBH = sp.BaoHanhHang;
                        }
                    }
                    rptInPhieuBHSX rpt = new rptInPhieuBHSX(txtTenThanhPham.Text.Trim(), txtMaLenh.Text.Trim(), txtMaVachTP.Text.Trim());
                    rpt.DataSource = liMaVach;
                    rpt.ShowPreview();
                }
                else
                {
                    rptInPhieuBHSX rpt = new rptInPhieuBHSX(txtTenThanhPham.Text.Trim(), txtMaLenh.Text.Trim(), txtMaVachTP.Text.Trim());
                    rpt.DataSource = liMaVach;
                    rpt.ShowPreview();
                }
            }
        }
Exemplo n.º 2
0
        protected override void PickUpSanPhamInfo(DMSanPhamInfo sanPhamInfo)
        {
            foreach (ChungTuXuatNhapNccChiTietInfo pt in XuatTraNccBusiness.ListChiTietChungTu)
            {
                if (pt.IdSanPham == sanPhamInfo.IdSanPham)
                {
                    MessageBox.Show("Không được nhập 2 mã sản phẩm giống nhau trên cùng 1 phiếu !");
                    return;
                }
            }
            List <TonDauKyInfo> item = DeNghiDieuChuyenDataProvider.Instance.GetListHangTonKhoByIdSanPham(Declare.IdKho, sanPhamInfo.IdSanPham);

            if (item.Count > 0)
            {
                MessageBox.Show("Sản phẩm đã hết tồn kho xin mời bạn chọn hàng khác!");
                return;
            }
            XuatTraNccBusiness.ListChiTietChungTu[dgvChiTiet.Rows.IndexOf(dgvChiTiet.CurrentRow)] = new ChungTuXuatNhapNccChiTietInfo()
            {
                MaSanPham   = sanPhamInfo.MaSanPham,
                IdSanPham   = sanPhamInfo.IdSanPham,
                TenSanPham  = sanPhamInfo.TenSanPham,
                DonGia      = sanPhamInfo.GiaNhap,
                TrungMaVach = sanPhamInfo.TrungMaVach,
                SoLuong     = 1
            };
            ((BindingSource)dgvChiTiet.DataSource).ResetBindings(false);
        }
Exemplo n.º 3
0
        protected void PickUpSanPhamInfo(DMSanPhamInfo sanPhamInfo)
        {
            if (bteKho.Tag == null)
            {
                clsUtils.MsgThongBao("Bạn chưa chọn kho xuất nên chưa thể chọn sản phẩm được!");
                return;
            }
            List <TonDauKyInfo> item = DeNghiDieuChuyenDataProvider.Instance.GetListHangTonKhoByIdSanPham(((DMKhoInfo)bteKho.Tag).IdKho, sanPhamInfo.IdSanPham);

            if (item.Count > 0)
            {
                MessageBox.Show("Sản phẩm đã hết tồn kho xin mời bạn chọn hàng khác!");
                return;
            }
            business.ListChiTietChungTu.Add(new DeNghiXuatTieuHaoChiTietInfonew()
            {
                MaSanPham   = sanPhamInfo.MaSanPham,
                IdSanPham   = sanPhamInfo.IdSanPham,
                TenSanPham  = sanPhamInfo.TenSanPham,
                DonGia      = sanPhamInfo.GiaNhap,
                TrungMaVach = sanPhamInfo.TrungMaVach,
                Nganh       = sanPhamInfo.Nganh,
                SoLuong     = 1,
            });
            //((BindingSource)grvList.DataSource).ResetBindings(false);
            grcList.DataSource = null;
            grcList.DataSource = business.ListChiTietChungTu;
            btnCapNhat.Enabled = business.ListChiTietChungTu.Count > 0;
        }
Exemplo n.º 4
0
 internal void Delete(DMSanPhamInfo dmSanPhamInfor)
 {
     //CreateCommonCommand(Declare.StoreProcedureNamespace.spSanPhamDelete);
     //Parameters.AddWithValue("@IdSanPham", dmSanPhamInfor.IdSanPham);
     //ExecuteNoneQuery();
     ExecuteCommand(Declare.StoreProcedureNamespace.spSanPhamDelete, dmSanPhamInfor.IdSanPham);
 }
Exemplo n.º 5
0
 private bool Search(DMSanPhamInfo dmQuyenHoaDonInfo)
 {
     return((txtFilterMa.Text.Trim() == String.Empty || (txtFilterMa.Text.Trim() != String.Empty &&
                                                         dmQuyenHoaDonInfo.MaSanPham.ToLower().Contains(txtFilterMa.Text.Trim().ToLower()))) &&
            (txtFilterTen.Text.Trim() == String.Empty || (txtFilterTen.Text.Trim() != String.Empty &&
                                                          dmQuyenHoaDonInfo.TenSanPham.ToLower().Contains(txtFilterTen.Text.Trim().ToLower()))));
 }
        protected override void PickUpSanPhamInfo(DMSanPhamInfo sanPhamInfo)
        {
            foreach (DeNghiDieuChuyenInfor pt in business.ListChiTietChungTu)
            {
                if (pt.IdSanPham == sanPhamInfo.IdSanPham)
                {
                    MessageBox.Show("Không được nhập 2 mã sản phẩm giống nhau trên cùng 1 phiếu !");
                    return;
                }
            }
            if (bteKhoDi.Tag == null)
            {
                clsUtils.MsgThongBao("Bạn chưa chọn kho đi nên chưa thể chọn sản phẩm được!");
                return;
            }
            List <TonDauKyInfo> item = DeNghiDieuChuyenDataProvider.Instance.GetListHangTonKhoByIdSanPham(((DMKhoInfo)bteKhoDi.Tag).IdKho, sanPhamInfo.IdSanPham);

            if (item.Count > 0)
            {
                MessageBox.Show("Sản phẩm đã hết tồn kho xin mời bạn chọn hàng khác!");
                return;
            }
            business.ListChiTietChungTu[dgvChiTiet.Rows.IndexOf(dgvChiTiet.CurrentRow)] = new DeNghiDieuChuyenInfor()
            {
                MaSanPham   = sanPhamInfo.MaSanPham,
                IdSanPham   = sanPhamInfo.IdSanPham,
                TenSanPham  = sanPhamInfo.TenSanPham,
                DonGia      = sanPhamInfo.GiaNhap,
                TrungMaVach = sanPhamInfo.TrungMaVach,
                SoLuong     = 1
            };
            ((BindingSource)dgvChiTiet.DataSource).ResetBindings(false);
            btnCapNhat.Enabled = business.ListChiTietChungTu.Count > 0;
        }
Exemplo n.º 7
0
 internal bool Exist(DMSanPhamInfo dmSanPhamInfor)
 {
     //CreateCommonCommand(Declare.StoreProcedureNamespace.spSanPhamExist);
     //Parameters.AddWithValue("@Count", 0).Direction = ParameterDirection.Output;
     //Parameters.AddWithValue("@IdSanPham", dmSanPhamInfor.IdSanPham);
     //Parameters.AddWithValue("@MaSanPham", dmSanPhamInfor.MaSanPham);
     //ExecuteNoneQuery();
     //return Convert.ToInt32(Parameters["@Count"].Value) == 1;
     return(GetObjectCommand <int>(Declare.StoreProcedureNamespace.spSanPhamExist,
                                   dmSanPhamInfor.IdSanPham,
                                   dmSanPhamInfor.MaSanPham) > 0);
 }
        private void btnSaoChep_Click(object sender, EventArgs e)
        {
            try
            {
                frmLookUp_SanPham frmLookUpSanPham = new frmLookUp_SanPham("%%");
                if (frmLookUpSanPham.ShowDialog() == DialogResult.OK)
                {
                    DMSanPhamInfo dmSanPhamInfo = frmLookUpSanPham.SelectedItem;
                    if (DMCauHinhSanPhamDataProvider.Instance.DaCoCauHinh(dmSanPhamInfo.IdSanPham))
                    {
                        if (MessageBox.Show("Sản phẩm này đã có cấu hình, bạn chắc chắn có muốn ghi đè không?", "Xác nhận", MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                        {
                            return;
                        }
                    }
                    else if (MessageBox.Show("Bạn chắc chắn sẽ sao chép cấu hình cho sản phẩm " + dmSanPhamInfo.MaSanPham + " không?", "Xác nhận", MessageBoxButtons.YesNo,
                                             MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return;
                    }

                    try
                    {
                        ConnectionUtil.Instance.BeginTransaction();

                        DMCauHinhSanPhamDataProvider.Instance.Delete(dmSanPhamInfo.IdSanPham);

                        for (int i = 0; i < lst.Count; i++)
                        {
                            DMCauHinhSanPhamInfo infor = lst[i];
                            DMCauHinhSanPhamDataProvider.Instance.Insert(dmSanPhamInfo.IdSanPham, infor.TenCauHinh, infor.GiaTri, infor.SoTT);
                        }

                        ConnectionUtil.Instance.CommitTransaction();
                    }
                    catch (Exception)
                    {
                        ConnectionUtil.Instance.RollbackTransaction();
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show(ex.ToString());
#else
                MessageBox.Show(ex.Message);
#endif
            }
        }
Exemplo n.º 9
0
        public void SaoChep()
        {
            try
            {
                frmLookUp_SanPham frm = new frmLookUp_SanPham("%%");
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    DMSanPhamInfo dmSanPhamInfo = frm.SelectedItem;
                    if (DmCauHinhSanPhamDAO.Instance.DaCoCauHinh(View.IdSanPham))
                    {
                        if (
                            MessageBox.Show("Sản phẩm này đã có cấu hình bạn có muốn ghi đè không ?", "Xác Nhận ",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                            MessageBoxDefaultButton.Button2) == DialogResult.No)
                        {
                            return;
                        }
                    }
                    else if (
                        MessageBox.Show("Bạn chắc chắn sẽ sao chép cấu hình cho sản phẩm ?",
                                        dmSanPhamInfo.MaSanPham, MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                        MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return;
                    }
                    try
                    {
                        ConnectionUtil.Instance.BeginTransaction();
                        DmCauHinhSanPhamDAO.Instance.Delete(dmSanPhamInfo.IdSanPham);
                        List <DMCauHinhSanPhamInfo> list = new List <DMCauHinhSanPhamInfo>();
                        for (int i = 0; i < list.Count; i++)
                        {
                            DMCauHinhSanPhamInfo info = list[i];
                            DmCauHinhSanPhamDAO.Instance.Update(info.IdSanPham, info.TenCauHinh, info.GiaTri, info.SoTT);
                            ConnectionUtil.Instance.CommitTransaction();
                        }
                    }
                    catch (Exception)
                    {
                        {
                            ConnectionUtil.Instance.RollbackTransaction();
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)

            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 10
0
 protected override void PickUpSanPhamInfo(DMSanPhamInfo sanPhamInfo)
 {
     business.ListChiTietChungTu[dgvChiTiet.Rows.IndexOf(dgvChiTiet.CurrentRow)] = new DeNghiDieuChuyenInfor()
     {
         MaSanPham   = sanPhamInfo.MaSanPham,
         IdSanPham   = sanPhamInfo.IdSanPham,
         TenSanPham  = sanPhamInfo.TenSanPham,
         DonGia      = sanPhamInfo.GiaNhap,
         TrungMaVach = sanPhamInfo.TrungMaVach,
         SoLuong     = 1
     };
     ((BindingSource)dgvChiTiet.DataSource).ResetBindings(false);
     btnCapNhat.Enabled = business.ListChiTietChungTu.Count > 0;
 }
Exemplo n.º 11
0
        private void LoadData()
        {
            if (frmMH.isAdd)
            {
                txtMaSanPham.Enabled = true;
                txtMaSanPham.Focus();
                txtTenTat.Text       = "";
                txtTenSanPham.Text   = "";
                txtMoTa.Text         = "";
                txtMaVach.Text       = "";
                txtMaSanPham.Text    = "";
                txtGiaNhap.Text      = "0";
                txtBaoHanhHang.Text  = "0";
                txtBaohanhKhach.Text = "0";
                txtMaSanPham.Focus();
                btnXoa.Enabled = false;
            }
            else
            {
                txtMaSanPham.Enabled = false;
                dm = DmSanPhamProvider.GetSanPhamById(frmMH.Oid);

                txtTenTat.Text             = dm.TenVietTat;
                txtTenSanPham.Text         = dm.TenSanPham;
                txtMoTa.Text               = dm.MoTa;
                txtMaVach.Text             = dm.MaVach;
                txtMaSanPham.Text          = dm.MaSanPham;
                txtGiaNhap.Text            = Convert.ToString(dm.GiaNhap);
                txtBaoHanhHang.Text        = Convert.ToString(dm.BaoHanhHang);
                txtBaohanhKhach.Text       = Convert.ToString(dm.BaoHanhKhach);
                cboDonViTinh.SelectedValue = dm.IdDonViTinh;
                cbTyLeVAT.SelectedValue    = dm.TyLeVAT;
                bteLoaiSanPham.Tag         = DMLoaiSanPhamDataProvider.Instance.GetFullInfoByKey(dm.IdCha);
                if (bteLoaiSanPham.Tag != null)
                {
                    bteLoaiSanPham.Text = ((DMLoaiSanPhamInfo)bteLoaiSanPham.Tag).TenLoaiSP;
                }
                chkSuDung.Checked      = dm.SuDung == 1;
                chkTrungMaVach.Checked = dm.TrungMaVach == 1;
                chkChietKhau.Checked   = dm.ChietKhau == 1;
            }
            if (frmMH.IsSync)
            {
                //không cho phép người dùng sửa, xóa các thông tin trên form.
                txtMaSanPham.Enabled = false;
                txtMaVach.Enabled    = false;
                btnXoa.Enabled       = false;
            }
        }
Exemplo n.º 12
0
        internal void Update(DMSanPhamInfo dmSanPhamInfor)
        {
            ExecuteCommand(Declare.StoreProcedureNamespace.spSanPhamUpdate,

                           dmSanPhamInfor.IdCha,
                           dmSanPhamInfor.MaVach,
                           dmSanPhamInfor.MaSanPham,
                           dmSanPhamInfor.TenSanPham,
                           dmSanPhamInfor.IdDonViTinh,
                           dmSanPhamInfor.GiaNhap,
                           dmSanPhamInfor.MoTa,
                           dmSanPhamInfor.SuDung,
                           dmSanPhamInfor.TrungMaVach,
                           dmSanPhamInfor.TenVietTat,
                           dmSanPhamInfor.ChietKhau,
                           dmSanPhamInfor.BaoHanhHang,
                           dmSanPhamInfor.BaoHanhKhach,
                           dmSanPhamInfor.TyLeVAT,
                           dmSanPhamInfor.IdSanPham);
        }
Exemplo n.º 13
0
 internal int Insert(DMSanPhamInfo dmSanPhamInfor)
 {
     return(GetObjectCommand <int>(Declare.StoreProcedureNamespace.spSanPhamInsert,
                                   //dmSanPhamInfor.IdSanPham,
                                   dmSanPhamInfor.IdCha,
                                   dmSanPhamInfor.MaVach,
                                   dmSanPhamInfor.MaSanPham,
                                   dmSanPhamInfor.TenSanPham,
                                   dmSanPhamInfor.IdDonViTinh,
                                   dmSanPhamInfor.GiaNhap,
                                   dmSanPhamInfor.MoTa,
                                   dmSanPhamInfor.SuDung,
                                   dmSanPhamInfor.TrungMaVach,
                                   dmSanPhamInfor.TenVietTat,
                                   dmSanPhamInfor.ChietKhau,
                                   dmSanPhamInfor.BaoHanhHang,
                                   dmSanPhamInfor.BaoHanhKhach,
                                   dmSanPhamInfor.TyLeVAT));
     //return Convert.ToInt32(Parameters["p_IdSanPham"].Value.ToString());
 }
Exemplo n.º 14
0
        private void frmBH_TimChungTu_Load(object sender, EventArgs e)
        {
            try
            {
                bool view = true;
                LoadNganhHang();
                CommonFuns.Instance.LoadComboBoxPages(cboPage);
                if (_IdTrungTam == 0)
                {
                    _IdTrungTam = Declare.IdTrungTam;
                    view        = false;
                }

                DMTrungTamInfor tt = DMTrungTamDataProvider.GetTrungTamByIdInfo(_IdTrungTam);
                if (tt != null)
                {
                    bteTrungTam.Text    = tt.TenTrungTam;
                    bteTrungTam.Tag     = tt;
                    bteTrungTam.Enabled = !view;
                }

                DMSanPhamInfo sp = DmSanPhamProvider.GetSanPhamById(_IdSanPham);
                if (sp != null)
                {
                    bteSanPham.Text    = sp.TenSanPham;
                    bteSanPham.Tag     = sp;
                    bteSanPham.Enabled = !view;
                }
                btnDeleteLS.Enabled    = nguoiDung.SupperUser == 1 ? true : false;
                btnDeleteAllLS.Enabled = nguoiDung.SupperUser == 1 ? true : false;

                if (_IdSanPham > 0)
                {
                    btnTim_Click(sender, e);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi ngoại lệ: " + ex.Message, Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 15
0
        private DMSanPhamInfo SetMatHang()
        {
            DMSanPhamInfo dm = new DMSanPhamInfo();

            dm.TenSanPham   = txtTenSanPham.Text.Trim();
            dm.TenVietTat   = txtTenTat.Text.Trim();
            dm.MaSanPham    = txtMaSanPham.Text.Trim();
            dm.MaVach       = txtMaVach.Text.Trim();
            dm.MoTa         = txtMoTa.Text.Trim();
            dm.GiaNhap      = Convert.ToInt32(txtGiaNhap.Text.Trim());
            dm.BaoHanhHang  = Convert.ToInt32(txtBaoHanhHang.Text.Trim());
            dm.BaoHanhKhach = Convert.ToInt32(txtBaohanhKhach.Text.Trim());
            dm.IdDonViTinh  = Convert.ToInt32(cboDonViTinh.SelectedValue);
            dm.TyLeVAT      = Convert.ToInt32(cbTyLeVAT.SelectedValue);
            dm.IdCha        = ((DMLoaiSanPhamInfo)bteLoaiSanPham.Tag).IdLoaiSP;
            dm.SuDung       = Convert.ToInt32(chkSuDung.Checked);
            dm.ChietKhau    = Convert.ToInt32(chkChietKhau.Checked);
            dm.TrungMaVach  = Convert.ToInt32(chkTrungMaVach.Checked);
            dm.IdSanPham    = frmMH.Oid;
            return(dm);
        }
Exemplo n.º 16
0
        //Ghi kèm trạng thái duyệt và thoát
        //private void btnInPhieu_Click(object sender, EventArgs e)
        //{
        //tblChungTuDataProvider.UpdateTrangThai(OID, TrangThaiDuyet.DA_XUAT);
        //DialogResult = DialogResult.OK;//tự hiểu và load lại datagridview
        //}

        protected override void PickUpSanPhamInfo(DMSanPhamInfo sanPhamInfo)
        {
            foreach (DeNghiXuatTieuHaoChiTietInfo pt in business.ListChiTietChungTu)
            {
                if (pt.IdSanPham == sanPhamInfo.IdSanPham)
                {
                    MessageBox.Show("Không được nhập 2 mã sản phẩm giống nhau trên cùng 1 phiếu !");
                    return;
                }
            }
            business.ListChiTietChungTu[dgvChiTiet.Rows.IndexOf(dgvChiTiet.CurrentRow)] = new DeNghiXuatTieuHaoChiTietInfo()
            {
                MaSanPham   = sanPhamInfo.MaSanPham,
                IdSanPham   = sanPhamInfo.IdSanPham,
                TenSanPham  = sanPhamInfo.TenSanPham,
                DonGia      = sanPhamInfo.GiaNhap,
                TrungMaVach = sanPhamInfo.TrungMaVach,
                SoLuong     = 1
            };
            ((BindingSource)dgvChiTiet.DataSource).ResetBindings(false);
            btnCapNhat.Enabled = business.ListChiTietChungTu.Count > 0;
        }
        public void TestMatHang03_MaMatHangHasExistedOnUpdate()
        {
            try
            {
                TestMatHang05_InsertSuccess();
                List <DMSanPhamInfo> list  = DmSanPhamProvider.GetListDmSanPhamInfo();
                DMSanPhamInfo        infor = list.Find(delegate(DMSanPhamInfo match)
                {
                    return(match.MaSanPham == "11111");
                });

                frmDM_HangHoa frm = new frmDM_HangHoa();
                frm.isAdd = false;
                frm.Oid   = Convert.ToInt32(infor.MaSanPham);
                frmChiTiet_MatHang frmChiTietListDM = new frmChiTiet_MatHang(frm);
                frmChiTietListDM.SetInput("sản phẩm 1", "1234", "SP1", "123654", 120000, "UnitsTest sản phẩm", 1, 0, 0);
                frmChiTietListDM.TestSave();
                list = DmSanPhamProvider.GetListDmSanPhamInfo();
                List <DMSanPhamInfo> listDuplicate = list.FindAll(delegate(DMSanPhamInfo match)
                {
                    return(match.MaSanPham == "1234");
                });
                frmChiTietListDM.TestDelete();
                Assert.AreEqual(1, listDuplicate.Count);
            }
            catch (Exception ex)
            {
                if (ex.GetType() != typeof(AssertFailedException))
                {
                    Assert.AreEqual(ex.Message, "Mã sản phẩm đã tồn tại trong hệ thống !");
                }
                else
                {
                    throw;
                }
            }
        }
 private void Save()
 {
     if (Check())
     {
         try
         {
             ConnectionUtil.Instance.BeginTransaction();
             if (TenCauHinh == "" && GiaTri == "")
             {
                 DMSanPhamInfo obj = (DMSanPhamInfo)bteSanPham.Tag;
                 for (int i = 0; i < lst.Count; i++)
                 {
                     DMCauHinhSanPhamInfo infor = lst[i];
                     DMCauHinhSanPhamDataProvider.Instance.Insert(obj.IdSanPham, infor.TenCauHinh, infor.GiaTri, infor.SoTT);
                 }
                 //DMCauHinhSanPhamDataProvider.Instance.UpdateLogo(obj.IdSanPham, txtLogo.Text);
                 ConnectionUtil.Instance.CommitTransaction();
             }
             else
             {
                 //DMSanPhamInfo obj = (DMSanPhamInfo)bteSanPham.Tag;
                 for (int i = 0; i < lst.Count; i++)
                 {
                     DMCauHinhSanPhamInfo infor = lst[i];
                     DMCauHinhSanPhamDataProvider.Instance.Update(IdSanPham, infor.TenCauHinh, infor.GiaTri, infor.SoTT);
                 }
                 //DMCauHinhSanPhamDataProvider.Instance.UpdateLogo(IdSanPham, txtLogo.Text);
                 ConnectionUtil.Instance.CommitTransaction();
             }
         }
         catch (Exception)
         {
             ConnectionUtil.Instance.RollbackTransaction();
             throw;
         }
     }
 }
        public void TestMatHang07_DeleteSuccess()
        {
            TestMatHang05_InsertSuccess();
            List <DMSanPhamInfo> list  = DmSanPhamProvider.GetListDmSanPhamInfo();
            DMSanPhamInfo        infor = list.Find(delegate(DMSanPhamInfo match)
            {
                return(match.MaSanPham == "11111");
            });

            frmDM_HangHoa frm = new frmDM_HangHoa();

            frm.isAdd = false;
            frm.Oid   = infor.IdSanPham;
            frmChiTiet_MatHang frmChiTietListDM = new frmChiTiet_MatHang(frm);

            frmChiTietListDM.TestDelete();
            list  = DmSanPhamProvider.GetListDmSanPhamInfo();
            infor = list.Find(delegate(DMSanPhamInfo match)
            {
                return(match.MaSanPham == "11111");
            });

            Assert.AreEqual(infor, null);
        }
Exemplo n.º 20
0
 private void Insert()
 {
     if (_sanphaminfo == null)
     {
         _sanphaminfo              = new DMSanPhamInfo();
         _sanphaminfo.MaSanPham    = View.MaSanPham;
         _sanphaminfo.MaVach       = View.MaVach;
         _sanphaminfo.TenSanPham   = View.TenSanPham;
         _sanphaminfo.TenVietTat   = View.TenVietTat;
         _sanphaminfo.TenLoaiSP    = View.TenLoaiSP;
         _sanphaminfo.IdDonViTinh  = View.IdDonViTinh;
         _sanphaminfo.GiaNhap      = View.GiaNhap;
         _sanphaminfo.TyLeVAT      = View.TyLeVAT;
         _sanphaminfo.MoTa         = View.MoTa;
         _sanphaminfo.TrungMaVach  = View.TrungMaVach;
         _sanphaminfo.SuDung       = View.SuDung;
         _sanphaminfo.BaoHanhHang  = View.BaoHanhHang;
         _sanphaminfo.BaoHanhKhach = View.BaoHanhKhach;
         _sanphaminfo.ChietKhau    = View.ChietKhau;
         _sanphaminfo.IdSanPham    = DMSanPhamDAO.Instance.Insert(_sanphaminfo);
         ((List <DMSanPhamInfo>)DSHangHoaView.Instance.DataSource).Add(_sanphaminfo);
         DSHangHoaView.Instance.RefreshDataSource();
     }
 }
Exemplo n.º 21
0
 internal List <DMSanPhamInfo> Search(DMSanPhamInfo dmSanPhamInfor)
 {
     return(GetListCommand <DMSanPhamInfo>(Declare.StoreProcedureNamespace.spSanPhamSearch,
                                           dmSanPhamInfor.MaSanPham,
                                           dmSanPhamInfor.TenSanPham));
 }
Exemplo n.º 22
0
        private void btnImportNoiDungChiTiet_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet ds;
                string  sql;
                openFileDialog1.FileName = String.Empty;
                //openFileDialog1.Filter = "*.xls|*.xlsx";
                if (openFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                frmProgress.Instance.DoWork(DoVaoBangTam, openFileDialog1.FileName);
                //frmProgress.Instance.DoWork(GenMaVachTuDong);

                return;

                int idSanPham, idDuDauKy;
                openFileDialog1.FileName = String.Empty;
                //openFileDialog1.Filter = "*.xls|*.xlsx";
                if (openFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                try
                {
                    using (OleDbConnection oConn = new OleDbConnection())
                    {
                        oConn.ConnectionString = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes\"", openFileDialog1.FileName);
                        oConn.Open();
                        sql = "Select [ma fpt] as MaSanPham, [Ten] as TenSanPham, sum([số lượng]) as SoLuong from [Items$] group by [ma fpt], [Ten]";
                        //sql = "Select [Mã hàng] as MaSanPham, [Tên hàng] as TenSanPham, [Giá nhập] as DonGia, sum([Số lượng]) as SoLuong from [Items$] group by [Mã hàng], [Tên hàng], [Giá nhập]";
                        using (OleDbDataAdapter ad = new OleDbDataAdapter(sql, oConn))
                        {
                            ds = new DataSet();
                            ad.Fill(ds, "HangHoaDuDauKy");

                            ad.SelectCommand.CommandText = "Select [ma fpt] as MaSanPham, [Ten] as TenSanPham, [Serial] as Mavach, [số lượng] as SoLuong from [Items$]";
                            ad.Fill(ds, "ImportTable");
                        }
                    }
                }
                catch (Exception exception)
                {
#if DEBUG
                    MessageBox.Show(exception.ToString());
#else
                    MessageBox.Show(exception.Message);
#endif

                    return;
                }

                ConnectionUtil.Instance.BeginTransaction();

                foreach (DataRow dr in ds.Tables["HangHoaDuDauKy"].Rows)
                {
                    if (dr["MaSanPham"] == DBNull.Value)
                    {
                        continue;
                    }

                    DMSanPhamInfo sanPhamInfo = DmSanPhamProvider.Instance.GetSanPhamByMa(dr["MaSanPham"].ToString());
                    if (sanPhamInfo == null)
                    {
                        continue;
                        //throw new Exception(String.Format("Mã sản phẩm '{0}' này không có trong danh mục", dr["MaSanPham"]));
                    }
                    idSanPham = sanPhamInfo.IdSanPham;

                    DataRow[] foundRows = ds.Tables["ImportTable"].Select(String.Format("MaSanPham='{0}'", dr["MaSanPham"]));
                    if (foundRows.Length > 0)
                    {
                        TonDauKyInfo tonDauKyInfo =
                            TonDauKyDataProvider.Instance.GetTonDauKy(idSanPham, Convert.ToInt32(cboKho.SelectedValue),
                                                                      dtNgayDuDau.Value, Declare.UserId) ??
                            new TonDauKyInfo();

                        tonDauKyInfo.ThoiGian  = dtNgayDuDau.Value.Date;
                        tonDauKyInfo.IdKho     = Convert.ToInt32(cboKho.SelectedValue);
                        tonDauKyInfo.IdSanPham = idSanPham;
                        tonDauKyInfo.SoLuong   = Convert.ToInt32(dr["SoLuong"]);
                        tonDauKyInfo.DonGia    = 0; //dr["DonGia"]);
                        tonDauKyInfo.ThanhTien = 0; // Common.IntValue(dr["SoLuong"]) * Common.DoubleValue(dr["DonGia"]));

                        if (tonDauKyInfo.IdDuDauKy != 0)
                        {
                            TonDauKyDataProvider.Instance.Update(tonDauKyInfo);
                        }
                        else
                        {
                            tonDauKyInfo.NguoiTao = Declare.UserId;
                            _IdDuDauKy            = TonDauKyDataProvider.Instance.Insert(tonDauKyInfo);
                        }
                        foreach (DataRow dr1 in foundRows)
                        {
                            HangHoaChiTietInfo hangHoaChiTietInfo = TonDauKyDataProvider.Instance.
                                                                    GetIdHangHoaChiTietMaVachTonDauKy(
                                dr1["MaVach"].ToString(),
                                _IdDuDauKy) ??
                                                                    new HangHoaChiTietInfo();

                            hangHoaChiTietInfo.IdDuDauKy = _IdDuDauKy;
                            hangHoaChiTietInfo.IdKho     = Convert.ToInt32(cboKho.SelectedValue);
                            hangHoaChiTietInfo.IdSanPham = idSanPham;
                            hangHoaChiTietInfo.MaVach    = Convert.ToString(dr1["MaVach"]);
                            hangHoaChiTietInfo.SoLuong   = Convert.ToInt32(dr1["SoLuong"]);

                            if (hangHoaChiTietInfo.IdChiTiet != 0)
                            {
                                TonDauKyDataProvider.Instance.Update(hangHoaChiTietInfo);
                            }
                            else
                            {
                                TonDauKyDataProvider.Instance.Insert(hangHoaChiTietInfo);
                            }
                        }
                    }
                }// end for each row in the grid
                TonDauKyDataProvider.Instance.Update(DateTime.Now, Convert.ToInt32(cboKho.SelectedValue));

                ConnectionUtil.Instance.CommitTransaction();

                MessageBox.Show("Cập nhật thành công");
            }
            catch (Exception exception)
            {
                ConnectionUtil.Instance.RollbackTransaction();
#if DEBUG
                MessageBox.Show(exception.ToString());
#else
                MessageBox.Show(exception.Message);
#endif
            }
        }
Exemplo n.º 23
0
 private void Save()
 {
     if (txtMaVachTP.Text == "")
     {
         throw new ManagedException("Mã vạch cho thành phẩm không được để trống !");
     }
     for (int i = 0; i < lisx.Count; i++)
     {
         if (lisx[i].SoLuongDaQuet < lisx[i].SoLuongTrenTPham)
         {
             throw new ManagedException("Linh kiện " + lisx[i].TenLinhKien + " chưa nhập đủ số lượng mã vạch !");
         }
     }
     if (check == 0)
     {
         int SoLuongCT = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
             Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), txtMaLenh.Text.Trim(), Declare.MaTrungTam);
         if (Convert.ToInt32(txtSoLuongYC.Text) <= SoLuongCT)
         {
             throw new ManagedException("Số lượng yêu cầu đã đủ, bạn không thể nhập thêm");
         }
     }
     if (check == 0 && isXuatLoi == false)
     {
         if (TblHangHoaChiTietDataProvider.IsUsedForAnotherProduct(txtMaVachTP.Text.Trim(), frm.idThanhPham))
         {
             throw new ManagedException("Mã vạch đã sử dụng cho 1 sản phẩm khác. Xin hãy kiểm tra lại !");
         }
         if (NhapThanhPhamSanXuatDataProvider.Instance.CheckMaVachNTP(frm.idThanhPham, txtMaVachTP.Text.Trim()) > 0)
         {
             throw new ManagedException("Mã vạch đã sử dụng cho 1 sản phẩm khác. Xin hãy kiểm tra lại !");
         }
         if (NhapThanhPhamSanXuatDataProvider.Instance.CheckMaVach(frm.idThanhPham, txtMaVachTP.Text.Trim()) > 0)
         {
             throw new ManagedException("Mã vạch đã sử dụng cho 1 sản phẩm khác. Xin hãy kiểm tra lại !");
         }
     }
     for (int i = 0; i < lisx.Count; i++)
     {
         if (lisx[i].SoLuongDaQuet < lisx[i].SoLuongTrenTPham)
         {
             throw new ManagedException("Bạn chưa nhập đủ số lượng mã vạch cho linh kiện " + lisx[i].MaLinhKien + " !");
         }
     }
     if (string.IsNullOrEmpty(dtNgayLap.Text))
     {
         dtNgayLap.Focus();
         throw new ManagedException("Bạn chưa chọn ngày lập !");
     }
     if (Convert.ToDateTime(dtNgayLap.EditValue) < frm.NgayLap)
     {
         dtNgayLap.Focus();
         throw new ManagedException("Ngày xuất linh kiện không được nhỏ hơn ngày lập của mã lệnh !");
     }
     try
     {
         ConnectionUtil.Instance.BeginTransaction();
         if (check == 0)
         {
             SaveXuatLinhKien(SaveNhapThanhPham());
             SLCT++;
         }
         else
         {
             XLKBussiness.SaveChungTu();
         }
         txtSoLuongCT.Text = SLCT.ToString();
         UpdateSoLuongDaXuat();
         if (SanXuatLenhProvier.GetSoLuongSanXuatLenh(Declare.IdKho, Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), txtMaLenh.Text.Trim(), 0) > 0)
         {
             SanXuatLenhProvier.UpdateTrangThai(new SanXuatLenhInfo {
                 MaLenh = txtMaLenh.Text.Trim(), MaThanhPham = txtMaThanhPham.Text.Trim(), TrangThai = Convert.ToInt32(TrangThaiSanXuat.DangSX)
             });
         }
         if (check == 0)
         {
             int SoLuongCT = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                 Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), txtMaLenh.Text.Trim(), Declare.MaTrungTam);
             if (Convert.ToInt32(txtSoLuongYC.Text) < SoLuongCT)
             {
                 throw new ManagedException("Số lượng yêu cầu đã đủ,bạn không thể nhập thêm");
             }
         }
         ConnectionUtil.Instance.CommitTransaction();
         clsUtils.MsgThongBao("Xuất thành công !");
         if (clsUtils.MsgXoa("Bạn có muốn in phiếu bảo hành cho bộ linh kiện không ?") == System.Windows.Forms.DialogResult.Yes)
         {
             List <ChungTuNhapNccChiTietHangHoaInfo> lst = new List <ChungTuNhapNccChiTietHangHoaInfo>();
             lst.AddRange(liMaVach);
             frmChonBaoCao frm1 = new frmChonBaoCao(true);
             frm1.ShowDialog();
             if (frm1.DialogResult == DialogResult.OK)
             {
                 if (frm1.Value == 1)
                 {
                     DMSanPhamInfo sp = DmSanPhamProvider.Instance.GetSanPhamByMa(txtMaThanhPham.Text.Trim());
                     foreach (ChungTuNhapNccChiTietHangHoaInfo pt in lst)
                     {
                         pt.ThoiHanBH = sp.BaoHanhHang;
                     }
                     rptInPhieuBHSX rpt = new rptInPhieuBHSX(txtTenThanhPham.Text.Trim(), txtMaLenh.Text.Trim(), txtMaVachTP.Text.Trim());
                     rpt.DataSource = lst;
                     rpt.ShowPreview();
                 }
                 else
                 {
                     rptInPhieuBHSX rpt = new rptInPhieuBHSX(txtTenThanhPham.Text.Trim(), txtMaLenh.Text.Trim(), txtMaVachTP.Text.Trim());
                     rpt.DataSource = lst;
                     rpt.ShowPreview();
                 }
             }
         }
         Clear();
         frm.LoadDuLieu();
     }
     catch (Exception ex)
     {
         ConnectionUtil.Instance.RollbackTransaction();
         throw ex;
     }
 }
Exemplo n.º 24
0
 private bool Exist(DMSanPhamInfo dmOrderTypeInfor)
 {
     return(dmOrderTypeInfor.IdSanPham == frmMH.Oid);
 }
Exemplo n.º 25
0
 protected virtual void PickUpSanPhamInfo(DMSanPhamInfo sanPhamInfo)
 {
 }
        private void LoadDuLieu()
        {
            if (!String.IsNullOrEmpty(filter.SanPham))
            {
                DMSanPhamInfo sanPhamInfo = DmSanPhamProvider.Instance.GetSanPhamByMa(filter.SanPham);

                var liNganh = new List <TimKiemItemInfor>();
                liNganh.AddRange((List <TimKiemItemInfor>)lueNganhHang.Properties.DataSource);

                if (sanPhamInfo != null &&
                    (!String.IsNullOrEmpty(filter.Nganh) && filter.Nganh == sanPhamInfo.Nganh ||
                     liNganh.Exists(delegate(TimKiemItemInfor match) { return(match.Ma == sanPhamInfo.Nganh); })))
                {
                    frmProgress.Instance.MaxValue = 1;
                    frmProgress.Instance.Value    = 0;
                    filter.SoBatDau  = -1;
                    filter.SoKetThuc = -1;
                    //filter.SoBatDau = SoLuongHienTai;
                    //filter.SoKetThuc = SoLuongTimKiem != -1 ? SoLuongHienTai + SoLuongTimKiem : -1;
                    liTimKiem = BanHangDataProvider.Instance.TimKiemTonChiTietMaVachPg(filter);
                    liChungTuChiTiet.AddRange(liTimKiem);
                }
            }
            else if (filter.IdTrungTam > 0 && filter.IdKho > 0 &&
                     filter.Nganh != String.Empty && filter.Nganh != "-1")
            {
                frmProgress.Instance.MaxValue = 1;
                frmProgress.Instance.Value    = 0;
                filter.SoBatDau  = -1;
                filter.SoKetThuc = -1;
                //filter.SoBatDau = SoLuongHienTai;
                //filter.SoKetThuc = SoLuongTimKiem != -1 ? SoLuongHienTai + SoLuongTimKiem : -1;
                liTimKiem = BanHangDataProvider.Instance.TimKiemTonChiTietMaVachPg(filter);
                liChungTuChiTiet.AddRange(liTimKiem);
            }
            else if (filter.IdTrungTam == -1 || filter.IdKho == -1 ||
                     filter.Nganh == String.Empty || filter.Nganh == "-1")
            {
                var liNganh = new List <TimKiemItemInfor>();
                var liKho   = new List <DMKhoSInfo>();

                frmProgress.Instance.MaxValue = 1;
                frmProgress.Instance.Value    = 0;

                if (filter.Nganh == String.Empty || filter.Nganh == "-1")
                {
                    liNganh.AddRange((List <TimKiemItemInfor>)lueNganhHang.Properties.DataSource);
                }
                else
                {
                    liNganh.Add(new TimKiemItemInfor {
                        Ma = filter.Nganh
                    });
                }

                if (filter.IdKho == -1)
                {
                    liKho.AddRange(DMKhoDataProvider.Instance.GetListIdKhoTon(filter.IdTrungTam));
                }
                else
                {
                    liKho.Add(new DMKhoSInfo {
                        IdKho = filter.IdKho, IdTrungTam = filter.IdTrungTam
                    });
                }

                frmProgress.Instance.MaxValue = liKho.Count * liNganh.Count;
                filter.SoBatDau  = -1;
                filter.SoKetThuc = -1;

                foreach (DMKhoSInfo dMKhoSInfo in liKho)
                {
                    filter.IdKho = dMKhoSInfo.IdKho;

                    filter.IdTrungTam = dMKhoSInfo.IdTrungTam;

                    var liNganhTon = DmNganhDataProvider.Instance.GetListNganhTonKho(filter.IdKho);

                    foreach (TimKiemItemInfor timKiemItemInfor in liNganh)
                    {
                        if (liNganhTon.Contains(timKiemItemInfor.Ma))
                        {
                            filter.Nganh = timKiemItemInfor.Ma;

                            liTimKiem = BanHangDataProvider.Instance.TimKiemTonChiTietMaVachPg(filter);

                            if (liTimKiem.Count > 0)
                            {
                                liChungTuChiTiet.AddRange(liTimKiem);

                                if (InvokeRequired)
                                {
                                    Invoke((MethodInvoker) delegate { gListChungTu.RefreshDataSource(); });
                                }
                                else
                                {
                                    gListChungTu.RefreshDataSource();
                                }
                            }
                        }
                        frmProgress.Instance.Value += 1;
                    }
                }
            }
            frmProgress.Instance.Description = "Đã xong";
            frmProgress.Instance.Value       = frmProgress.Instance.MaxValue;
            frmProgress.Instance.IsCompleted = true;
        }
Exemplo n.º 27
0
 private bool Select(DMSanPhamInfo dmSanPhamInfo)
 {
     return(dmSanPhamInfo.IdCha == 0 || dmSanPhamInfo.IdCha.ToString() == string.Empty);
 }
Exemplo n.º 28
0
 private void GetData()
 {
     _sanphaminfo = View.sanphaminfo;
 }
        protected internal bool Calculable(int idSanPham)
        {
            DMSanPhamInfo dmSanPhamInfo = DmSanPhamProvider.Instance.GetSanPhamById(idSanPham);

            return(dmSanPhamInfo != null && dmSanPhamInfo.ChietKhau == 0);
        }
Exemplo n.º 30
0
        private void GenSerial()
        {
            var result = new List <string>();

            var ngayThang = sysDate.ToString("yyMMdd");

            if (!(ChungTuChiTietInfo is ChungTuChiTietBaseInfo))
            {
                throw new ManagedException("Không đúng kiểu dữ liệu!");
            }

            sanPhamInfo = DmSanPhamProvider.Instance.GetSanPhamById((ChungTuChiTietInfo as ChungTuChiTietBaseInfo).IdSanPham);

            var sanPham = sanPhamInfo.MaSanPham.Substring(sanPhamInfo.MaSanPham.LastIndexOf(".") + 1);

            if (sanPhamInfo.TrungMaVach == 1)
            {
                var s = String.Format("{0} {1} {2}", sanPham, MaTrungTam, ngayThang);

                var count = 0;

                while (!TblHangHoaChiTietDataProvider.IsNotInUniqueSerial(s) || lstChiTiet.Exists(delegate(T1 match)
                {
                    return(match is ChungTuChiTietHangHoaBaseInfo &&

                           (match as ChungTuChiTietHangHoaBaseInfo).MaVach == s &&

                           (match as ChungTuChiTietHangHoaBaseInfo).IdSanPham != sanPhamInfo.IdSanPham);
                }))
                {
                    s = String.Format("{0} {1} {2}-{3}", sanPham, MaTrungTam, ngayThang, count);

                    count++;
                }

                lstChiTiet.Add(CreateSerial(s));

                frmProgress.Instance.Value += 1;

                return;
            }

            //kiểm tra xem nhân viên này đã dùng hết số serial tự sinh chưa
            //nếu chưa, nếu số lượng serial chưa dùng >= số lượng cần sinh thì không sinh thêm nữa,
            //  ngược lại thì tính lại số lượng serial cần sinh

            bool isNotUnique;

            do
            {
                isNotUnique = false;

                var soLuongCanSinhThem = (ChungTuChiTietInfo as ChungTuChiTietBaseInfo).SoLuong -

                                         AutoGenSerialProvider.Instance.CountNotUsed(sanPham, MaTrungTam, ngayThang, IdNhanVien);

                if (soLuongCanSinhThem > 0)
                {
                    for (var i = 0; i < soLuongCanSinhThem; i++)
                    {
                        var success = false;

                        while (!success)
                        {
                            try
                            {
                                //tăng số nhảy
                                var seqNum = AutoGenSerialProvider.Instance.IncreaseCount(sanPham, MaTrungTam);

                                var serial = String.Format("{0} {1} {2} {3}", sanPham, MaTrungTam, ngayThang, seqNum);

                                if (!TblHangHoaChiTietDataProvider.IsUniqueSerial(serial) || lstChiTiet.Exists(delegate(T1 match)
                                {
                                    return(match is ChungTuChiTietHangHoaBaseInfo &&

                                           (match as ChungTuChiTietHangHoaBaseInfo).MaVach == serial);
                                }))
                                {
                                    throw new ManagedException("Mã vạch này đã được sử dụng!");
                                }

                                //lưu vào bảng quản lý
                                AutoGenSerialProvider.Instance.SaveToManaged(sanPham, MaTrungTam, ngayThang, IdNhanVien, seqNum, 0);

                                frmProgress.Instance.Value += 1;

                                success = true;
                            }
                            catch (Exception)
                            {
                                success = false;
                            }
                        }
                    }

                    foreach (var genCodeInfo in AutoGenSerialProvider.Instance.GetListGenCodeInfo(sanPham, MaTrungTam, IdNhanVien))
                    {
                        result.Add(String.Format("{0} {1} {2} {3}", genCodeInfo.SanPham, genCodeInfo.TrungTam,

                                                 genCodeInfo.NgayTao, genCodeInfo.GenCode));
                    }
                }
                else
                {
                    foreach (var genCodeInfo in AutoGenSerialProvider.Instance.GetListGenCodeInfoInNumRow(sanPham, MaTrungTam, IdNhanVien,

                                                                                                          (ChungTuChiTietInfo as ChungTuChiTietBaseInfo).SoLuong))
                    {
                        result.Add(String.Format("{0} {1} {2} {3}", genCodeInfo.SanPham, genCodeInfo.TrungTam,

                                                 genCodeInfo.NgayTao, genCodeInfo.GenCode));
                    }
                }

                foreach (var s in result)
                {
                    if (TblHangHoaChiTietDataProvider.IsUniqueSerial(s))
                    {
                        continue;
                    }

                    isNotUnique = true;

                    AutoGenSerialProvider.Instance.DeleteSerial(s);

                    frmProgress.Instance.Value -= 1;
                }
            } while (isNotUnique);

            foreach (var s in result)
            {
                lstChiTiet.Add(CreateSerial(s));
            }
        }