Exemplo n.º 1
0
        public List <BaoCaoTheoChungTu> getListBaoCaoTheoHangHoa(int check, string maKho)
        {
            string sql;

            if (check == 0)
            {
                sql = "SELECT  ct.MaHang, ct.TenHang, ct.DonVi,  ct.SoLuong,hh.GiaMua, nh.TenNhom, kh.TenKho,  " +
                      " ct.DonGia, ct.ThanhToan FROM CT_PHIEUXUAT ct, THONGTIN_PHIEU_BANHANG tt, HANGHOA_DICHVU hh, NHOMHANG nh, KHOHANG kh " +
                      "WHERE ct.MaPhieuXuat = tt.MaPhieu and hh.MaHang = ct.MaHang and hh.MaHang = ct.MaHang and hh.MaNhom = nh.MaNhom and tt.MaKho = kh.MaKho";
            }
            else
            {
                sql = string.Format("SELECT  ct.MaHang, ct.TenHang, ct.DonVi,  ct.SoLuong,hh.GiaMua, nh.TenNhom, kh.TenKho,  " +
                                    " ct.DonGia, ct.ThanhToan FROM CT_PHIEUXUAT ct, THONGTIN_PHIEU_BANHANG tt, HANGHOA_DICHVU hh, NHOMHANG nh, KHOHANG kh " +
                                    "WHERE ct.MaPhieuXuat = tt.MaPhieu and hh.MaHang = ct.MaHang and hh.MaHang = ct.MaHang and hh.MaNhom = nh.MaNhom and tt.MaKho = kh.MaKho and tt.MaKho = '{0}'", maKho);
            }
            DataTable data = ConnectionDB.getData(sql);

            List <BaoCaoTheoChungTu> ListBaoCaoTheoHangHoa = new List <BaoCaoTheoChungTu>();

            if (data.Rows.Count > 0)
            {
                foreach (DataRow dataRow in data.Rows)
                {
                    BaoCaoTheoChungTu x = new BaoCaoTheoChungTu();
                    x.MaHang       = dataRow["MaHang"].ToString();
                    x.TenHang      = dataRow["TenHang"].ToString();
                    x.DonVi        = dataRow["DonVi"].ToString();
                    x.SoLuong      = (dataRow["SoLuong"].ToString());
                    x.DonGiaNhap   = (dataRow["GiaMua"].ToString());
                    x.TongTienNhap = (int.Parse(x.SoLuong) * float.Parse(x.DonGiaNhap)).ToString();
                    x.DonGiaXuat   = (dataRow["DonGia"].ToString());
                    x.TongTienXuat = (int.Parse(x.SoLuong) * float.Parse(x.DonGiaXuat)).ToString();
                    x.ChenhLech    = (float.Parse(x.TongTienXuat) - float.Parse(x.TongTienNhap)).ToString();
                    x.KhoHang      = dataRow["TenKho"].ToString();
                    x.NhomHang     = dataRow["TenNhom"].ToString();
                    ListBaoCaoTheoHangHoa.Add(x);
                }
            }
            return(ListBaoCaoTheoHangHoa);
        }
Exemplo n.º 2
0
        public List <BaoCaoTheoChungTu> getListBaoCaoTheoNgay(int check, DateTime a, DateTime b)
        {
            List <DateTime> listDateMuaBan = new List <DateTime>();

            if (check == 0)
            {
                listDateMuaBan = getListDateMuaBan();
            }
            else
            {
                listDateMuaBan = getListDateMuaBanFromDate(a, b);
            }
            List <BaoCaoTheoChungTu> ListBaoCaoTheoNgay = new List <BaoCaoTheoChungTu>();

            for (int i = 0; i < listDateMuaBan.Count; i++)
            {
                BaoCaoTheoChungTu x = new BaoCaoTheoChungTu();
                x.NgayLap      = listDateMuaBan[i].ToString();
                x.TongTienNhap = sumTienMua(listDateMuaBan[i]).ToString();
                x.TongTienXuat = sumTienBan(listDateMuaBan[i]).ToString();
                ListBaoCaoTheoNgay.Add(x);
            }
            return(ListBaoCaoTheoNgay);
        }
Exemplo n.º 3
0
        public List <BaoCaoTheoChungTu> getListBaoCao(int check, DateTime a, DateTime b)
        {
            List <string> ListMaPhieuSell;

            if (check == 0)
            {
                ListMaPhieuSell = getMaPhieuInSell();
            }
            else
            {
                ListMaPhieuSell = getMaPhieuInSellNgay(a, b);
            }
            List <BaoCaoTheoChungTu> listBaoCaoTheoChungTu = new List <BaoCaoTheoChungTu>();

            for (int i = 0; i < ListMaPhieuSell.Count; i++)
            {
                DataTable data = getListBaoCao(ListMaPhieuSell[i]);

                BaoCaoTheoChungTu y = new BaoCaoTheoChungTu();

                y.TenKH   = data.Rows[0]["TenKH"].ToString();
                y.MaKH    = data.Rows[0]["MaKH"].ToString();
                y.MaPhieu = data.Rows[0]["MaPhieuXuat"].ToString();
                y.NgayLap = (data.Rows[0]["NgayLap"].ToString());


                y.TienHang = (data.Rows[0]["TongTienBan"].ToString());
                y.CK       = (data.Rows[0]["CK"].ToString());
                y.VAT      = (data.Rows[0]["VAT"].ToString());
                y.DoanhSo  = (data.Rows[0]["TongTienNhan"].ToString());



                float giaTriXuatKho = 0;
                foreach (DataRow dataRow in data.Rows)
                {
                    giaTriXuatKho += (int.Parse(dataRow["SoLuong"].ToString()) * float.Parse(dataRow["GiaMua"].ToString()));
                }
                y.GiaTriXuatKho = giaTriXuatKho.ToString();
                y.LoiNhuan      = (Convert.ToDouble(y.DoanhSo) - Convert.ToDouble(y.GiaTriXuatKho)).ToString();
                listBaoCaoTheoChungTu.Add(y);

                if (data.Rows.Count > 0)
                {
                    foreach (DataRow dataRow in data.Rows)
                    {
                        BaoCaoTheoChungTu x = new BaoCaoTheoChungTu();
                        x.TenKH        = dataRow["TenKH"].ToString();
                        x.MaKH         = dataRow["MaKH"].ToString();
                        x.MaPhieu      = dataRow["MaPhieuXuat"].ToString();
                        x.MaHang       = dataRow["MaHang"].ToString();
                        x.TenHang      = dataRow["TenHang"].ToString();
                        x.DonVi        = dataRow["DonVi"].ToString();
                        x.SoLuong      = (dataRow["SoLuong"].ToString());
                        x.DonGiaNhap   = (dataRow["GiaMua"].ToString());
                        x.TongTienNhap = (int.Parse(x.SoLuong) * float.Parse(x.DonGiaNhap)).ToString();
                        x.DonGiaXuat   = (dataRow["DonGia"].ToString());
                        x.TongTienXuat = (int.Parse(x.SoLuong) * float.Parse(x.DonGiaXuat)).ToString();
                        x.ChenhLech    = (float.Parse(x.TongTienXuat) - float.Parse(x.TongTienNhap)).ToString();

                        listBaoCaoTheoChungTu.Add(x);
                    }
                }
            }
            return(listBaoCaoTheoChungTu);
        }