/// <summary>
        /// Select Bảng
        /// </summary>
        /// <returns></returns>
        public Entities.BCTonKhoTheoNhomHang[] Select(Entities.BCTonKhoTheoNhomHang bctktnh)
        {
            Sql    = new Constants.Sql();
            bctknh = new Constants.BCTonKhoTheoNhomHang();
            string        sql  = Sql.selectBCTonKhoTheoNhomHangTheoMa;
            Connection    conn = new Connection();
            SqlConnection cn   = conn.openConnection();
            SqlCommand    cmd  = new SqlCommand(sql, cn);

            cmd.Parameters.Add("@MaNhomHang", SqlDbType.VarChar, 20).Value = bctktnh.MaNhomHang;
            SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            //Insert Category into ArrayList
            ArrayList arr = new ArrayList();

            while (dr.Read())
            {
                Entities.BCTonKhoTheoNhomHang bctktkk = new Entities.BCTonKhoTheoNhomHang();
                bctktkk.MaNhomHang  = dr[bctknh.MaNhomHang].ToString();
                bctktkk.TenNhomHang = dr[bctknh.TenNhomHang].ToString();
                bctktkk.MaHangHoa   = dr[bctknh.MaHangHoa].ToString();
                bctktkk.TenHangHoa  = dr[bctknh.TenHangHoa].ToString();
                bctktkk.TenKho      = dr[bctknh.TenKho].ToString();
                bctktkk.HanSuDung   = DateTime.Parse(dr[bctknh.HanSuDung].ToString());
                bctktkk.SoLuong     = Convert.ToInt32(dr[bctknh.SoLuong].ToString());
                arr.Add(bctktkk);
            }
            int n = arr.Count;

            if (n == 0)
            {
                return(null);
            }

            Entities.BCTonKhoTheoNhomHang[] arrC = new Entities.BCTonKhoTheoNhomHang[n];
            for (int i = 0; i < n; i++)
            {
                arrC[i] = (Entities.BCTonKhoTheoNhomHang)arr[i];
            }

            //Giai phong bo nho
            arr = null;
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn   = null;
            conn = null;
            return(arrC);
        }
        /// <summary>
        /// Select Bảng
        /// </summary>
        /// <returns></returns>
        public Entities.BCTonKhoTheoNhomHang[] Select(Entities.BCTonKhoTheoNhomHang bctktnh)
        {
            Sql = new Constants.Sql();
            bctknh = new Constants.BCTonKhoTheoNhomHang();
            string sql = Sql.selectBCTonKhoTheoNhomHangTheoMa;
            Connection conn = new Connection();
            SqlConnection cn = conn.openConnection();
            SqlCommand cmd = new SqlCommand(sql, cn);
            cmd.Parameters.Add("@MaNhomHang", SqlDbType.VarChar, 20).Value = bctktnh.MaNhomHang;
            SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            //Insert Category into ArrayList
            ArrayList arr = new ArrayList();
            while (dr.Read())
            {
                Entities.BCTonKhoTheoNhomHang bctktkk = new Entities.BCTonKhoTheoNhomHang();
                bctktkk.MaNhomHang = dr[bctknh.MaNhomHang].ToString();
                bctktkk.TenNhomHang = dr[bctknh.TenNhomHang].ToString();
                bctktkk.MaHangHoa= dr[bctknh.MaHangHoa].ToString();
                bctktkk.TenHangHoa = dr[bctknh.TenHangHoa].ToString();
                bctktkk.TenKho = dr[bctknh.TenKho].ToString();
                bctktkk.HanSuDung = DateTime.Parse(dr[bctknh.HanSuDung].ToString());
                bctktkk.SoLuong = Convert.ToInt32(dr[bctknh.SoLuong].ToString());
                arr.Add(bctktkk);
            }
            int n = arr.Count;
            if (n == 0) return null;

            Entities.BCTonKhoTheoNhomHang[] arrC = new Entities.BCTonKhoTheoNhomHang[n];
            for (int i = 0; i < n; i++)
            {
                arrC[i] = (Entities.BCTonKhoTheoNhomHang)arr[i];
            }

            //Giai phong bo nho
            arr = null;
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn = null;
            conn = null;
            return arrC;
        }
Пример #3
0
 public frmBaoCaorpt(string hanhDong, string maKho)
 {
     try
     {
         InitializeComponent();
         CongTy();
         switch (hanhDong)
         {
             case "Kho":
                 {
                     cl = new Server_Client.Client();
                     this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                     Entities.BCTonKhoTheoKho ctxh = new Entities.BCTonKhoTheoKho("SelectTheoMa", maKho);
                     Entities.BCTonKhoTheoKho[] pt1 = new Entities.BCTonKhoTheoKho[1];
                     clientstrem = cl.SerializeObj(this.client1, "BCTonKhoTheoKho", ctxh);
                     pt1 = (Entities.BCTonKhoTheoKho[])cl.DeserializeHepper1(clientstrem, pt1);
                     if (pt1 == null)
                     {
                         MessageBox.Show("Không có dữ liệu", "Hệ thống cảnh báo");
                         return;
                     }
                     else
                     {
                         GUI.Report.rptBCTonKhoTheoKho report = new GUI.Report.rptBCTonKhoTheoKho();
                         report.SetDataSource(pt1);
                         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 Tồn Kho Theo Kho " + DateServer.Date().Month.ToString() + "/" + DateServer.Date().Year.ToString());
                         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 "Nhom":
                 {
                     cl = new Server_Client.Client();
                     this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                     Entities.BCTonKhoTheoNhomHang ctxh = new Entities.BCTonKhoTheoNhomHang("SelectTheoMa", maKho);
                     Entities.BCTonKhoTheoNhomHang[] pt1 = new Entities.BCTonKhoTheoNhomHang[1];
                     clientstrem = cl.SerializeObj(this.client1, "BCTonKhoTheoNhom", ctxh);
                     pt1 = (Entities.BCTonKhoTheoNhomHang[])cl.DeserializeHepper1(clientstrem, pt1);
                     if (pt1 == null)
                     {
                         MessageBox.Show("Không có dữ liệu", "Hệ thống cảnh báo");
                         return;
                     }
                     else
                     {
                         GUI.Report.rptBCTonKhoTheoNhomHang report = new GUI.Report.rptBCTonKhoTheoNhomHang();
                         report.SetDataSource(pt1);
                         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 Tồn Kho Theo Nhóm Hàng " + DateServer.Date().Month.ToString() + "/" + DateServer.Date().Year.ToString());
                         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 { }
 }