/// <summary>
 /// khoi tao gia tri
 /// </summary>
 public BCChiTietHangHoa()
 {
     kh = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     khachhang = null;
     cn = null;
 }
 /// <summary>
 /// khoi tao gia tri
 /// </summary>
 public BCChiTietHangHoa()
 {
     kh        = null;
     Sql       = null;
     conn      = null;
     cmd       = null;
     arr       = null;
     dr        = null;
     khachhang = null;
     cn        = null;
 }
Example #3
0
        public frmBaoCaorpt(string hanhDong)
        {
            try
            {
                InitializeComponent();
                switch (hanhDong)
                {
                    case "Test":
                        {
                            Entities.KhachHang[] kh1 = new Entities.KhachHang[0];
                            GUI.Report.rptBCCongNoKhachHang report = new GUI.Report.rptBCCongNoKhachHang();
                            report.SetDataSource(kh1);
                            crvReport.ReportSource = report;
                            report.SetParameterValue("TenCongTy", CT.TenCongTy);
                            report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
                            report.SetParameterValue("DienThoai", CT.SoDienThoai);
                            report.SetParameterValue("FaxCongTy", CT.Fax);
                            report.SetParameterValue("Web", CT.Website);
                            report.SetParameterValue("TenBaoCao", "Báo Cáo Công Nợ Khách Hàng");
                            report.SetParameterValue("MaNhanVien", Common.Utilities.User.TenNhanVien);
                            report.SetParameterValue("Email", CT.Email);
                            crvReport.Show();
                            break;
                        }
                    case "KhachHang":
                        {
                            CongTy();
                            cl = new Server_Client.Client();
                            this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                            Entities.KhachHang kh = new Entities.KhachHang("Select");
                            Entities.KhachHang[] kh1 = new Entities.KhachHang[1];
                            clientstrem = cl.SerializeObj(this.client1, "KhachHang", kh);
                            kh1 = (Entities.KhachHang[])cl.DeserializeHepper1(clientstrem, kh1);
                            if (kh1 == null)
                            {
                                MessageBox.Show("Không có dữ liệu", "Hệ thống cảnh báo");
                                return;
                            }
                            GUI.Report.rptBCCongNoKhachHang report = new GUI.Report.rptBCCongNoKhachHang();
                            report.SetDataSource(kh1);
                            crvReport.ReportSource = report;
                            report.SetParameterValue("TenCongTy", CT.TenCongTy);
                            report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
                            report.SetParameterValue("DienThoai", CT.SoDienThoai);
                            report.SetParameterValue("FaxCongTy", CT.Fax);
                            report.SetParameterValue("Web", CT.Website);
                            report.SetParameterValue("TenBaoCao", "Báo Cáo Công Nợ Khách Hàng");
                            report.SetParameterValue("NgayTao", new Common.Utilities().XuLy(2, DateServer.Date().ToShortDateString()));
                            report.SetParameterValue("MaNhanVien", Common.Utilities.User.TenNhanVien);
                            report.SetParameterValue("Email", CT.Email);
                            crvReport.Show();
                            break;
                        }
                    case "ChiTietHangHoa":
                        {
                            CongTy();
                            cl = new Server_Client.Client();
                            this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                            Entities.rptBCChiTietHangHoa kh = new Entities.rptBCChiTietHangHoa("Select");
                            Entities.rptBCChiTietHangHoa[] kh1 = new Entities.rptBCChiTietHangHoa[1];
                            clientstrem = cl.SerializeObj(this.client1, "BCChiTietHangHoa", kh);
                            kh1 = (Entities.rptBCChiTietHangHoa[])cl.DeserializeHepper1(clientstrem, kh1);
                            if (kh1 == null)
                            {
                                MessageBox.Show("Không có dữ liệu", "Hệ thống cảnh báo");
                                return;
                            }
                            GUI.Report.rptBCChiTietHangHoa report = new GUI.Report.rptBCChiTietHangHoa();
                            report.SetDataSource(kh1);
                            crvReport.ReportSource = report;
                            report.SetParameterValue("TenCongTy", CT.TenCongTy);
                            report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
                            report.SetParameterValue("DienThoai", CT.SoDienThoai);
                            report.SetParameterValue("FaxCongTy", CT.Fax);
                            report.SetParameterValue("Web", CT.Website);
                            report.SetParameterValue("TenBaoCao", "Báo Cáo Chi Tiết Hàng Hóa");
                            report.SetParameterValue("NgayTao", new Common.Utilities().XuLy(2, DateServer.Date().ToShortDateString()));
                            report.SetParameterValue("MaNhanVien", Common.Utilities.User.TenNhanVien);
                            report.SetParameterValue("Email", CT.Email);
                            crvReport.Show();
                            break;
                        }
                    case "NCC":
                        {
                            CongTy();
                            cl = new Server_Client.Client();
                            this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                            Entities.NhaCungCap kh = new Entities.NhaCungCap("Select");
                            Entities.NhaCungCap[] kh1 = new Entities.NhaCungCap[1];
                            clientstrem = cl.SerializeObj(this.client1, "NhaCungCap", kh);
                            kh1 = (Entities.NhaCungCap[])cl.DeserializeHepper1(clientstrem, kh1);
                            if (kh1 == null)
                            {
                                MessageBox.Show("Không có dữ liệu", "Hệ thống cảnh báo");
                                return;
                            }
                            GUI.Report.rptBCCongNoNCC report = new GUI.Report.rptBCCongNoNCC();
                            report.SetDataSource(kh1);
                            crvReport.ReportSource = report;
                            report.SetParameterValue("TenCongTy", CT.TenCongTy);
                            report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
                            report.SetParameterValue("DienThoai", CT.SoDienThoai);
                            report.SetParameterValue("FaxCongTy", CT.Fax);
                            report.SetParameterValue("Web", CT.Website);
                            report.SetParameterValue("TenBaoCao", "Báo Cáo Công Nợ Nhà Cung Cấp");
                            report.SetParameterValue("NgayTao", new Common.Utilities().XuLy(2, DateServer.Date().ToShortDateString()));
                            report.SetParameterValue("MaNhanVien", Common.Utilities.User.TenNhanVien);
                            report.SetParameterValue("Email", CT.Email);
                            crvReport.Show();
                            break;
                        }

                    default: break;
                }
            }
            catch
            {
            }
        }
        /// <summary>
        /// Select Bảng
        /// </summary>
        /// <returns></returns>
        public rptBCChiTietHangHoa[] Select()
        {
            rptBCChiTietHangHoa[] arrC = null;
            try
            {
                kh = new Constants.BCChiTietHangHoa();
                Sql = new Constants.Sql();
                string sql = Sql.SelectChiTietHangHoa;
                conn = new Connection();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr = new ArrayList();
                while (dr.Read())
                {
                    rptBCChiTietHangHoa rptBcChiTietHangHoa = new rptBCChiTietHangHoa
                                                                 {
                                                                     MaHangHoa = dr[kh.MaHangHoa].ToString(),
                                                                     TenNhomHang = dr[kh.TenNhomHang].ToString(),
                                                                     TenHangHoa = dr[kh.TenHangHoa].ToString(),
                                                                     TenDonViTinh = dr[kh.TenDonViTinh].ToString(),
                                                                     GiaNhap = double.Parse(dr[kh.GiaNhap].ToString()),
                                                                     GiaBanBuon = double.Parse(dr[kh.GiaBanBuon].ToString()),
                                                                     GiaBanLe = double.Parse(dr[kh.GiaBanLe].ToString()),
                                                                     MucDatHang = Convert.ToInt32(dr[kh.MucDatHang].ToString()),
                                                                     MucTonToiThieu = Convert.ToInt32(dr[kh.MucTonToiThieu].ToString())
                                                                 };
                    arr.Add(rptBcChiTietHangHoa);
                }
                int n = arr.Count;
                if (n == 0) { return null; }
                arrC = new rptBCChiTietHangHoa[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (rptBCChiTietHangHoa)arr[i];
                }
            }

            catch (Exception)
            {
            }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return arrC;
        }