Пример #1
0
        private void Import_Temp(DataTable datatable)
        {
            int intRow = datatable.Rows.Count;

            if (datatable.Columns.Contains("Mã hàng hóa") && datatable.Columns.Contains("Tồn thực tế") && datatable.Columns.Contains("Lý do kiểm kê"))
            {
                if (intRow != 0)
                {
                    for (int i = 0; i <= intRow - 1; i++)
                    {
                        DataRow dr     = datatable.Rows[i];
                        string  MaHang = dr["Mã hàng hóa"].ToString().Trim();
                        if (MaHang != "")
                        {
                            int tblHangHoa_Count = DBDataProvider.DB.hhHangHoas.Where(x => x.MaHang == MaHang && x.DaXoa == 0).Count();
                            if (tblHangHoa_Count > 0)
                            {
                                var tblHangHoa     = DBDataProvider.DB.hhHangHoas.Where(x => x.MaHang == MaHang && x.DaXoa == 0 && x.LoaiHHID == 1).FirstOrDefault();
                                var exitProdInList = listReceiptProducts.SingleOrDefault(r => r.MaHang == MaHang);
                                if (exitProdInList == null)
                                {
                                    int TonKhoThucTe = Convert.ToInt32(dr["Tồn thực tế"] == "" ? "0" : dr["Tồn thực tế"].ToString().Trim());

                                    string DienGiai = dr["Lý do kiểm kê"] == "" ? "" : dr["Lý do kiểm kê"].ToString();
                                    oImportProduct_ChiTietKiemKe newKiemKe = new oImportProduct_ChiTietKiemKe(
                                        tblHangHoa.IDHangHoa,
                                        tblHangHoa.MaHang,
                                        tblHangHoa.TenHangHoa,
                                        Convert.ToInt32(tblHangHoa.hhTonKhos.Where(s => s.ChiNhanhID == Convert.ToInt32(Formats.IDChiNhanh())).FirstOrDefault().SoLuong),
                                        TonKhoThucTe,
                                        TonKhoThucTe - Convert.ToInt32(tblHangHoa.hhTonKhos.Where(s => s.ChiNhanhID == Convert.ToInt32(Formats.IDChiNhanh())).FirstOrDefault().SoLuong),
                                        1,
                                        DienGiai
                                        );
                                    listReceiptProducts.Add(newKiemKe);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                throw new Exception("File excel không đúng. Vui lòng kiểm tra lại!!");
            }
        }
Пример #2
0
        public void Insert_Hang(int ID)
        {
            int tblHangHoa_Count = DBDataProvider.DB.hhHangHoas.Where(x => x.IDHangHoa == ID && x.DaXoa == 0 && x.LoaiHHID == 1).Count();

            if (tblHangHoa_Count > 0)
            {
                var tblHangHoa     = DBDataProvider.DB.hhHangHoas.Where(x => x.IDHangHoa == ID && x.DaXoa == 0).FirstOrDefault();
                var exitProdInList = listReceiptProducts.SingleOrDefault(r => r.IDHangHoa == ID);
                if (exitProdInList == null)
                {
                    oImportProduct_ChiTietKiemKe newKiemKe = new oImportProduct_ChiTietKiemKe(
                        tblHangHoa.IDHangHoa,
                        tblHangHoa.MaHang,
                        tblHangHoa.TenHangHoa,
                        Convert.ToInt32(tblHangHoa.hhTonKhos.Where(s => s.ChiNhanhID == Convert.ToInt32(Formats.IDChiNhanh())).FirstOrDefault().SoLuong),
                        0,
                        -Convert.ToInt32(tblHangHoa.hhTonKhos.Where(s => s.ChiNhanhID == Convert.ToInt32(Formats.IDChiNhanh())).FirstOrDefault().SoLuong),
                        0,
                        ""
                        );
                    listReceiptProducts.Add(newKiemKe);
                }
                else
                {
                    exitProdInList.TonKhoThucTe += 1;
                    exitProdInList.ChenhLech     = exitProdInList.TonKhoThucTe - exitProdInList.TonKhoHeThong;
                }
                UpdateSTT();
            }
            else
            {
                ccbBarcode.Value = "";
                ccbBarcode.Text  = "";
                ccbBarcode.Focus();
                throw new Exception("Mã hàng không tồn tại!!");
            }
        }