示例#1
0
        private void frmInventory_Load(object sender, EventArgs e)
        {
            // load Tất cả các kho có trong tồn kho

            DataTable data = tonKhoBus.getTonKho();

            grvTonKho.DataSource = data;
            AddNhatKy("Xem");
            loadKhoHang();
        }
示例#2
0
        public List <TonKhoTongHop> getListTonKhoTongHop(int check, string maKho)
        {
            DataTable data;

            if (check == 0)
            {
                data = tkBus.getTonKho();
            }
            else
            {
                data = tkBus.getTonKhoFromMaKho(maKho);
            }
            List <TonKhoTongHop> listTonKhoTongHop = new List <TonKhoTongHop>();

            if (data.Rows.Count > 0)
            {
                foreach (DataRow dataRow in data.Rows)
                {
                    TonKhoTongHop tkTongHop = new TonKhoTongHop();
                    tkTongHop.MaHang    = dataRow["MaHang"].ToString();
                    tkTongHop.TenHang   = dataRow["TenHang"].ToString();
                    tkTongHop.NhomHang  = dataRow["TenNhom"].ToString();
                    tkTongHop.KhoHang   = dataRow["TenKho"].ToString();
                    tkTongHop.MaKHo     = dataRow["MaKho"].ToString();;
                    tkTongHop.ConQuanLy = bool.Parse(dataRow["Active"].ToString());
                    tkTongHop.DonVi     = dataRow["Ten"].ToString();
                    tkTongHop.SoLuong   = int.Parse(dataRow["SoLuongTon"].ToString());
                    if (tkTongHop.SoLuong <= 0)
                    {
                        tkTongHop.ThanhTien = tkTongHop.DonGia = 0;
                    }
                    else
                    {
                        object tien = sumDonGiaNhap(tkTongHop.MaHang, tkTongHop.MaKHo);
                        if (tien.ToString() == "")
                        {
                            tien = 0.0;
                        }
                        else
                        {
                            tien = (float)Convert.ToDouble(tien);
                        }

                        tkTongHop.DonGia = ((float)Convert.ToDouble(tien) / tkTongHop.SoLuong);

                        tkTongHop.ThanhTien = tkTongHop.DonGia * tkTongHop.SoLuong;
                    }
                    listTonKhoTongHop.Add(tkTongHop);
                }
            }
            return(listTonKhoTongHop);
        }
        public List <NhapXuatTon> getListNhapXuatTon(int check, string maKho)
        {
            List <NhapXuatTon> ListNhapXuatTon = new List <NhapXuatTon>();
            DataTable          data;

            if (check == 0)
            {
                data = tk.getTonKho();
            }
            else
            {
                data = tk.getTonKhoFromMaKho(maKho);
            }

            if (data.Rows.Count > 0)
            {
                foreach (DataRow dataRow in data.Rows)
                {
                    NhapXuatTon x = new NhapXuatTon();
                    x.MaHang    = dataRow["MaHang"].ToString();
                    x.TenHang   = dataRow["TenHang"].ToString();
                    x.TenKho    = dataRow["TenKho"].ToString();
                    x.MaKho     = dataRow["MaKho"].ToString();;
                    x.ConQuanLy = bool.Parse(dataRow["Active"].ToString());
                    x.DonVi     = dataRow["Ten"].ToString();
                    x.slDauKy   = 0;
                    x.TienDauKy = 0;
                    if (getSumSoLuongNhap(x.MaHang, x.MaKho).ToString() == "")
                    {
                        x.slNhapKho = 0;
                    }
                    else
                    {
                        x.slNhapKho = Convert.ToInt32(getSumSoLuongNhap(x.MaHang, x.MaKho));
                    }

                    if (getSumTongTienNhap(x.MaHang, x.MaKho).ToString() == "")
                    {
                        x.TienNhapKho = 0;
                    }
                    else
                    {
                        x.TienNhapKho = (float)Convert.ToDouble(getSumTongTienNhap(x.MaHang, x.MaKho));
                    }

                    if (getSumSoLuongXuat(x.MaHang, x.MaKho).ToString() == "")
                    {
                        x.slXuatKho = 0;
                    }
                    else
                    {
                        x.slXuatKho = Convert.ToInt32(getSumSoLuongXuat(x.MaHang, x.MaKho));
                    }

                    if (getSumTongTienXuat(x.MaHang, x.MaKho).ToString() == "")
                    {
                        x.TienXuatKho = 0;
                    }
                    else
                    {
                        x.TienXuatKho = (float)Convert.ToDouble(getSumTongTienXuat(x.MaHang, x.MaKho));
                    }

                    x.slCuoiKy   = x.slNhapKho - x.slXuatKho;
                    x.TienCuoiKy = x.TienNhapKho - x.TienXuatKho;
                    ListNhapXuatTon.Add(x);
                }
            }
            return(ListNhapXuatTon);
        }