예제 #1
0
 private void LoadData()
 {
     try
     {
         PhieuNhap pn = new PhieuNhap();
         dgv_DanhSachPhieuNhap.DataSource = client.PhieuNhap_GetPhieuNhap(pn, "").Tables[0];
         FormatGrid();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #2
0
 //Load thông tin thống kê
 private void LoadTotalReport()
 {
     try
     {
         #region Thống kê phiếu nhập
         PhieuNhapClient phieunhap_client = new PhieuNhapClient();
         PhieuNhap       pn = new PhieuNhap();
         pn.NgayNhap = DateTime.Today;
         DataTable dt = phieunhap_client.PhieuNhap_GetPhieuNhap(pn, "").Tables[0];
         lb_PhieuNhap1_SoPhieu_value.Text = dt.Rows.Count.ToString();
         decimal Tongtiennhap = 0;
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 Tongtiennhap += Convert.ToDecimal(row["TongTien"]);
             }
         }
         if (Tongtiennhap != 0)
         {
             lb_PhieuNhap1_Tien_value.Text = Tongtiennhap.ToString("#,##");
         }
         else
         {
             lb_PhieuNhap1_Tien_value.Text = "0";
         }
         pn = new PhieuNhap();
         dt = phieunhap_client.PhieuNhap_GetPhieuNhap(pn, " and Year(pns.NgayNhap) = " + DateTime.Today.Year + " and Month(pns.NgayNhap) = " + DateTime.Today.Month).Tables[0];
         lb_PhieuNhap2_SoPhieu_value.Text = dt.Rows.Count.ToString();
         Tongtiennhap = 0;
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 Tongtiennhap += Convert.ToDecimal(row["TongTien"]);
             }
         }
         if (Tongtiennhap != 0)
         {
             lb_PhieuNhap2_Tien_value.Text = Tongtiennhap.ToString("#,##");
         }
         else
         {
             lb_PhieuNhap2_Tien_value.Text = "0";
         }
         #endregion
         #region Thống kê phiếu xuất
         PhieuXuatClient phieuxuat_client = new PhieuXuatClient();
         PhieuXuat       px = new PhieuXuat();
         px.NgayXuat = DateTime.Today;
         dt          = phieuxuat_client.PhieuXuat_GetPhieuXuat(px, "").Tables[0];
         lb_PhieuXuat1_SoPhieu_value.Text = dt.Rows.Count.ToString();
         decimal Tongtienxuat = 0;
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 Tongtienxuat += Convert.ToDecimal(row["TongTien"]);
             }
         }
         if (Tongtienxuat != 0)
         {
             lb_PhieuXuat1_Tien_value.Text = Tongtienxuat.ToString("#,##");
         }
         else
         {
             lb_PhieuXuat1_Tien_value.Text = "0";
         }
         px = new PhieuXuat();
         dt = phieuxuat_client.PhieuXuat_GetPhieuXuat(px, " and Year(pxs.NgayXuat) = " + DateTime.Today.Year + " and Month(pxs.NgayXuat) = " + DateTime.Today.Month).Tables[0];
         lb_PhieuXuat2_SoPhieu_value.Text = dt.Rows.Count.ToString();
         Tongtienxuat = 0;
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 Tongtienxuat += Convert.ToDecimal(row["TongTien"]);
             }
         }
         if (Tongtienxuat != 0)
         {
             lb_PhieuXuat2_Tien_value.Text = Tongtienxuat.ToString("#,##");
         }
         else
         {
             lb_PhieuXuat2_Tien_value.Text = "0";
         }
         #endregion
         #region Thống kê hoá đơn - ghi nợ
         HoaDonClient hoadon_client = new HoaDonClient();
         HoaDon       hd            = new HoaDon();
         hd.NgayXuat = DateTime.Today;
         dt          = hoadon_client.HoaDon_GetHoaDon(hd, "").Tables[0];
         lb_HoaDon1_SoHD_value.Text = dt.Rows.Count.ToString();
         Tongtienxuat = 0;
         decimal Tongtienno = 0;
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 Tongtienxuat += Convert.ToDecimal(row["TongTien"]);
                 Tongtienno   += Convert.ToDecimal(row["ConLai"]);
             }
         }
         if (Tongtienxuat != 0)
         {
             lb_HoaDon1_DoanhThu_value.Text = Tongtienxuat.ToString("#,##");
         }
         else
         {
             lb_HoaDon1_DoanhThu_value.Text = "0";
         }
         if (Tongtienno != 0)
         {
             lb_SoNo_value.Text = Tongtienno.ToString("#,##");
         }
         else
         {
             lb_SoNo_value.Text = "0";
         }
         hd = new HoaDon();
         dt = hoadon_client.HoaDon_GetHoaDon(hd, " and Year(NgayXuat) = " + DateTime.Today.Year + " and Month(NgayXuat) = " + DateTime.Today.Month).Tables[0];
         lb_HoaDon2_SoHD_value.Text = dt.Rows.Count.ToString();
         Tongtienxuat = 0;
         Tongtienno   = 0;
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 Tongtienxuat += Convert.ToDecimal(row["TongTien"]);
                 Tongtienno   += Convert.ToDecimal(row["ConLai"]);
             }
         }
         if (Tongtienxuat != 0)
         {
             lb_HoaDon2_DoanhThu_value.Text = Tongtienxuat.ToString("#,##");
         }
         else
         {
             lb_HoaDon2_DoanhThu_value.Text = "0";
         }
         if (Tongtienno != 0)
         {
             lb_SoNo_Thang_value.Text = Tongtienno.ToString("#,##");
         }
         else
         {
             lb_SoNo_Thang_value.Text = "0";
         }
         #endregion
         #region Thống kê khách hàng
         KhachHangClient khachhang_client = new KhachHangClient();
         KhachHang       kh = new KhachHang();
         //Đếm tổng số khách hàng
         dt = khachhang_client.KhachHang_GetKhachHang(kh, "").Tables[0];
         lb_KhachHang_Tong_value.Text = dt.Rows.Count.ToString();
         //Đếm số khách hàng còn nợ
         dt = khachhang_client.KhachHang_GetKhachHang(kh, " and SoNo > 0").Tables[0];
         lb_KhachHang_ConNo_value.Text = dt.Rows.Count.ToString();
         #endregion
         #region Thống kê nhân viên
         NhanVienClient nhanvien_client = new NhanVienClient();
         //Đếm số nv nam
         NhanVien nv = new NhanVien();
         nv.GioiTinh = "Nam";
         dt          = nhanvien_client.NhanVien_GetNhanVien(nv, "").Tables[0];
         lb_NhanVien_Nam_value.Text = dt.Rows.Count.ToString();
         //Đếm số nv nữ
         nv          = new NhanVien();
         nv.GioiTinh = "Nu";
         dt          = nhanvien_client.NhanVien_GetNhanVien(nv, "").Tables[0];
         lb_NhanVien_Nu_value.Text = dt.Rows.Count.ToString();
         #endregion
         #region Thống kê phiếu thu - thanh toán nợ
         PhieuThuClient phieuthu_client = new PhieuThuClient();
         PhieuThu       pt = new PhieuThu();
         pt.NgayThu = DateTime.Today;
         dt         = phieuthu_client.PhieuThu_GetPhieuThu(pt, "").Tables[0];
         decimal TongTienThu = 0;
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 TongTienThu += Convert.ToDecimal(row["SoTienThu"]);
             }
         }
         if (TongTienThu != 0)
         {
             lb_TienThu_value.Text = TongTienThu.ToString("#,##");
         }
         else
         {
             lb_TienThu_value.Text = "0";
         }
         pt          = new PhieuThu();
         dt          = phieuthu_client.PhieuThu_GetPhieuThu(pt, " and Year(NgayThu) = " + DateTime.Today.Year + " and Month(NgayThu) = " + DateTime.Today.Month).Tables[0];
         TongTienThu = 0;
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 TongTienThu += Convert.ToDecimal(row["SoTienThu"]);
             }
         }
         if (TongTienThu != 0)
         {
             lb_TienThu_Thang_value.Text = TongTienThu.ToString("#,##");
         }
         else
         {
             lb_TienThu_Thang_value.Text = "0";
         }
         #endregion
         #region Thống kê sản phẩm
         SanPhamClient sanpham_client = new SanPhamClient();
         SanPham       sp             = new SanPham();
         SanPham[]     dssp           = sanpham_client.SanPham_GetSanPham(sp, "");
         lb_MaSanPham_value.Text = dssp.Length.ToString();
         decimal tongsotonkho = 0;
         if (dssp.Length > 0)
         {
             foreach (SanPham sanpham in dssp)
             {
                 tongsotonkho += Convert.ToDecimal(sanpham.LuongTon);
             }
         }
         lb_TongTon_value.Text = tongsotonkho.ToString();
         dssp = sanpham_client.SanPham_GetSanPham(sp, " and SoLuongTon > 0");
         lb_ConHang_value.Text = dssp.Length.ToString();
         dssp = sanpham_client.SanPham_GetSanPham(sp, " and SoLuongTon = 0");
         lb_HetHang_value.Text = dssp.Length.ToString();
         #endregion
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }