Example #1
0
        private void SearchByMaVach()
        {
            DMSanPhamBriefInfo spb = null;

            if (!string.IsNullOrEmpty(txtMaSanPham.Text))
            {
                spb = QLBanHang.Modules.DanhMuc.Providers.DmSanPhamProvider.GetSanPhamBriefByNSDMa(txtMaSanPham.Text.Trim(),
                                                                                                   (nguoiDung.SupperUser == 1
                                                                                  ? -1
                                                                                  : nguoiDung.IdNhomNguoiDung));
            }
            if (spb == null)
            {
                frmLookUp_HangHoa frm = new frmLookUp_HangHoa(false,
                                                              (Common.Int2Bool(nguoiDung.SupperUser)
                                                                   ? -1
                                                                   : nguoiDung.IdNhomNguoiDung), 1, -1,
                                                              -1, -1);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    spb = frm.SelectedItem;
                }
            }

            if (spb == null)
            {
                return;
            }
            txtTenSanPham.Text            = spb.TenSanPham;
            NhapHangTraChiTietHHInfor ctu = Business.ListChiTietChungTu.Find(delegate(NhapHangTraChiTietHHInfor match)
                                                                             { return(match.MaSanPham == spb.MaSanPham && spb.TrungMaVach == 1); });

            if (ctu != null)
            {
                ctu.SoLuong    += 1;
                ctu.SoLuongTra += 1;
                ((BindingList <NhapHangTraChiTietHHInfor>)grcHangBan.DataSource).ResetBindings();
            }
            else
            {
                ctu           = new NhapHangTraChiTietHHInfor(spb);
                ctu.IdChungTu = Business.ChungTu.IdChungTu;
                ((BindingList <NhapHangTraChiTietHHInfor>)grcHangBan.DataSource).Add(ctu);
                ((BindingList <NhapHangTraChiTietHHInfor>)grcHangBan.DataSource).ResetBindings();
            }
            //UpdateSummariesInfors();
        }
Example #2
0
        private void InputDataFromCode(string code)
        {
            try
            {
                if (!code.Equals(""))
                {
                    SanPhamDoi = BangGiaDataProvider.Instance.GetGiaBan(IdTrungTam, IdKho, code);
                }
                if (SanPhamDoi == null)
                {
                    frmLookUp_HangHoa frm = new frmLookUp_HangHoa(false,
                                                                  (Common.Int2Bool(nguoiDung.SupperUser)
                                                                       ? -1
                                                                       : nguoiDung.IdNhomNguoiDung), 1, -1,
                                                                  IdKho, 1);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        SanPhamDoi = BangGiaDataProvider.Instance.GetGiaBan(IdTrungTam, IdKho, frm.SelectedItem.MaSanPham);
                    }
                    else
                    {
                        return;
                    }
                }

                if (SanPhamDoi == null)
                {
                    MessageBox.Show("Giá chưa thiết lập!");
                    return;
                }
                txtComment.Text = SanPhamDoi.TenSanPham;
            }
            catch (Exception ex)
            {
                EventLogProvider.Instance.WriteLog(ex.ToString()
                                                   + "\nUser: "******"\nMay: " + Declare.TenMay,
                                                   this.Name);
#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
            }
        }
Example #3
0
        private void InputDataFromCode(string code)
        {
            try
            {
                DMSanPhamBriefInfo sp = DmSanPhamProvider.GetSanPhamBriefByNSDMa(code, nguoiDung.IdNhomNguoiDung);
                if (sp == null)
                {
                    frmLookUp_HangHoa frm = new frmLookUp_HangHoa(false,
                                                                  (Common.Int2Bool(nguoiDung.SupperUser)
                                                                       ? -1
                                                                       : nguoiDung.IdNhomNguoiDung), 1, -1);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        sp = frm.SelectedItem;
                    }
                }

                if (sp != null)
                {
                    BangGiaBanChiTietInfor spb;
                    spb = liBangGiaBan.Find(delegate(BangGiaBanChiTietInfor match)
                    {
                        return(match.MaSanPham.Equals(code));
                    });
                    if (spb == null)
                    {
                        spb = BangGiaDataProvider.Instance.GetGiaBan(IdTTamSelected, IdKhoSelected, sp.MaSanPham);
                    }

                    if (spb == null)
                    {
                        MessageBox.Show("Giá chưa thiết lập!");
                        return;
                    }
                    else if (!DatTruoc && spb.ChietKhau != 1 && GetTonConLai(spb) <= 0)
                    {
                        MessageBox.Show("Hàng đã hết tồn kho!");
                        return;
                    }

                    liBangGiaBan.Add(spb);
                    int    isHangKem  = (rdHangBanKem.Checked ? 1 : 0);
                    string tenHangKem = (rdHangBanKem.Checked ? strMuaKem : strKhuyenMai);
                    ChungTuBanHangChiTietInfor ctu = liSanPhamSelected.Find(delegate(ChungTuBanHangChiTietInfor match)
                    {
                        return(match.MaSanPham.Equals(spb.MaSanPham) && match.LoaiHangKem == isHangKem);
                    });
                    if (ctu != null)
                    {
                        ctu.SoLuong          += 1;
                        ctu.TienSauChietKhau += spb.DonGiaChuaVAT;
                        ctu.TienVAT          += spb.TienVAT;
                        ctu.ThanhTien        += spb.DonGiaCoVAT;
                        ctu.ThuongNong       += spb.ThuongNong;
                        ctu.NoKhuyenMai       = (spb.TonKho >= ctu.SoLuong || DatTruoc || rdHangBanKem.Checked) ? 0 : ctu.SoLuong - spb.TonKho;
                        ctu.GhiChu            = Common.Int2Bool(spb.ChietKhau) ? "CK" : (ctu.NoKhuyenMai > 0 ? "Nợ khuyến mại" : "");
                        ctu.SoLuongOld        = ctu.SoLuong;

                        ((BindingList <ChungTuBanHangChiTietInfor>)gSanPham.DataSource).ResetBindings();
                    }
                    else
                    {
                        //add san pham ban
                        ChungTuBanHangChiTietInfor ct = null;
                        if (rdHangBanKem.Checked)
                        {
                            ct = BanHangDataProvider.Instance.ConvertBG2SanPhamBan(spb);
                        }
                        else
                        {
                            ct         = BanHangDataProvider.Instance.ConvertBG2SanPhamKM(spb);
                            ct.TyleVAT = Common.Int2Bool(spb.ChietKhau) ? spb.TyLeVAT : 0;
                            //if (liSanPhamSelected.Exists(delegate (ChungTuBanHangChiTietInfor match)
                            //                                 {
                            //                                     return
                            //                                         match.MaSanPham.Equals(ct.MaSanPham) && match.LoaiHangKem == 0;
                            //                                 }))
                            //{
                            //    ct.TyleChietKhau = 0;
                            //}
                        }
                        ct.NoKhuyenMai    = (spb.TonKho >= ct.SoLuong || DatTruoc || rdHangBanKem.Checked) ? 0 : ct.SoLuong - spb.TonKho;
                        ct.LoaiHangKem    = isHangKem;
                        ct.TenLoaiHangKem = tenHangKem;
                        ct.IdSanPhamBan   = CTu.IdSanPham;
                        ct.TenSanPhamBan  = CTu.TenSanPham;
                        ct.GhiChu         = Common.Int2Bool(spb.ChietKhau) ? "CK" : (ct.NoKhuyenMai > 0 ? "Nợ khuyến mại" : "");
                        ct.SoLuongOld     = ct.SoLuong;
                        ((BindingList <ChungTuBanHangChiTietInfor>)gSanPham.DataSource).Add(ct);
                    }
                    //spb.TonKho = spb.TonKho - 1;
                }
            }
            catch (System.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
            }
        }
        public void TestLookUpHangHoa()
        {
            frmLookUp_HangHoa frm = new frmLookUp_HangHoa(true, 1, 1, -1);

            frm.ShowDialog();
        }