Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                int userId = -1;
                int roleId = -1;

                String strUId = context.Request.QueryString["apiuid"];
                String strRId = context.Request.QueryString["apirid"];
                if (!String.IsNullOrEmpty(strUId) && !String.IsNullOrEmpty(strRId))
                {
                    userId = int.Parse(strUId);
                    roleId = int.Parse(strRId);
                }
                else
                {
                    VPBLL.BasePage bp = new VPBLL.BasePage();

                    bp.CheckUser(HttpContext.Current.Request.Cookies["LastLogin"], context);

                    userId = bp.UserID;
                    roleId = bp.RoleID;
                }

                String act = context.Request.QueryString["act"];
                bool bExport = ("1" == context.Request.QueryString["be"]);

                VPBLL.DataTable.FormatedList fl = new VPBLL.DataTable.FormatedList();
                switch (act)
                {
                    case "1"://GRReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.GR.ABiGR>(context.Request);
                            var helper = new VPBLL.GR.GRHelper();
                            var list = helper.GetGR(new VPBLL.GR.GRHelper.QueryCondition()
                            {
                                GRNumber = context.Request.QueryString["gn"],
                                MoveType = context.Request.QueryString["mt"],
                                VendorCode = context.Request.QueryString["vc"],
                                PONumber = context.Request.QueryString["pn"],
                                DateStart = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToDateTime(context.Request.QueryString["ed"]),
                                UserID = userId,
                                IsExport = bExport,
                                RoleID = roleId
                            });

                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "2": //GRIVReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.GR.ABiGRIV>(context.Request);
                            var helper = new VPBLL.GR.GRHelper();
                            var list = helper.GetGRIV(new VPBLL.GR.GRHelper.QueryCondition()
                            {
                                IVNumber = context.Request.QueryString["iv"],
                                VendorCode = context.Request.QueryString["vc"],
                                DateStart = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToDateTime(context.Request.QueryString["ed"]),
                                PONumber = context.Request.QueryString["pn"],
                                UserID = userId,
                                IsExport = bExport
                            });

                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "3": //POReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.PO.ABiPO>(context.Request);
                            var helper = new VPBLL.PO.POHelper();
                            var list = helper.getPO(new VPBLL.PO.POHelper.QueryCondition()
                            {
                                CompanyCode = context.Request.QueryString["cc"],
                                CompanyName = context.Request.QueryString["cn"],
                                VendorCode = context.Request.QueryString["vc"],
                                MeterialNumber = context.Request.QueryString["mn"],
                                PONumber = context.Request.QueryString["pn"],
                                DateBegin = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToDateTime(context.Request.QueryString["ed"]),
                                UserID = userId,
                                IsExport = bExport,
                                RoleID = roleId
                            });

                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "4":   //POIVReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.PO.ABiPOIV>(context.Request);
                            var helper = new VPBLL.PO.POHelper();
                            var list = helper.getPOIV(new VPBLL.PO.POHelper.QueryCondition()
                            {
                                CompanyCode = context.Request.QueryString["cc"],
                                CompanyName = context.Request.QueryString["cn"],
                                VendorCode = context.Request.QueryString["vc"],
                                MeterialNumber = context.Request.QueryString["mn"],
                                PONumber = context.Request.QueryString["pn"],
                                DateBegin = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToDateTime(context.Request.QueryString["ed"]),
                                UserID = userId,
                                IsExport = bExport
                            });

                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "5":   //POStatusReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.PO.ABiPOStatus>(context.Request);
                            var helper = new VPBLL.PO.POHelper();
                            var list = helper.getPOStatus(new VPBLL.PO.POHelper.QueryCondition()
                            {
                                CompanyCode = context.Request.QueryString["cc"],
                                CompanyName = context.Request.QueryString["cn"],
                                VendorCode = context.Request.QueryString["vc"],
                                MeterialNumber = context.Request.QueryString["mn"],
                                PONumber = context.Request.QueryString["pn"],
                                DateBegin = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToDateTime(context.Request.QueryString["ed"]),
                                UserID = userId,
                                IsExport = bExport
                            });

                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "6":   //IVReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.IV.ABiIV>(context.Request);
                            var helper = new VPBLL.IV.IVHelper();
                            var list = helper.getIV(new VPBLL.IV.IVHelper.QueryCondition()
                            {
                                CompanyCode = context.Request.QueryString["cc"],
                                VendcorName = context.Request.QueryString["vn"],
                                VendorCode = context.Request.QueryString["vc"],
                                InvoiceNumber = context.Request.QueryString["in"],
                                IsTolerance = context.Request.QueryString["it"],
                                DateBegin = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToDateTime(context.Request.QueryString["ed"]),
                                PaymentStatus = context.Request.QueryString["ps"],
                                UserID = userId,
                                IsExport = bExport,
                                RoleID = roleId
                            });

                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "7":   //IVCompletedReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.IV.ABiIVCompleted>(context.Request);
                            var helper = new VPBLL.IV.IVHelper();
                            var list = helper.getIVCompleted(new VPBLL.IV.IVHelper.QueryCondition()
                            {
                                CompanyCode = context.Request.QueryString["cc"],
                                VendcorName = context.Request.QueryString["vn"],
                                VendorCode = context.Request.QueryString["vc"],
                                InvoiceNumber = context.Request.QueryString["in"],
                                IsTolerance = context.Request.QueryString["it"],
                                DateBegin = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToDateTime(context.Request.QueryString["ed"]),
                                UserID = userId,
                                IsExport = bExport
                            });

                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "8":   //IVPendingReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.IV.ABiIVPending>(context.Request);
                            var helper = new VPBLL.IV.IVHelper();
                            var list = helper.getIVPending(new VPBLL.IV.IVHelper.QueryCondition()
                            {
                                CompanyCode = context.Request.QueryString["cc"],
                                VendcorName = context.Request.QueryString["vn"],
                                VendorCode = context.Request.QueryString["vc"],
                                InvoiceNumber = context.Request.QueryString["in"],
                                IsTolerance = context.Request.QueryString["it"],
                                DateBegin = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToDateTime(context.Request.QueryString["ed"]),
                                Buys = context.Request.QueryString["b"],
                                UserID = userId,
                                IsExport = bExport
                            });

                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "9": //GR_NewIV.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.GR.ABiNewIV>(context.Request);
                            var helper = new VPBLL.GR.GRHelper();
                            var list = helper.getNewIV(new VPBLL.GR.GRHelper.QueryCondition() {
                                CompanyCode = context.Request.QueryString["cc"],
                                GRNumber = context.Request.QueryString["gn"],
                                PONumber = context.Request.QueryString["pn"],
                                DateStart = ToDateTime(context.Request.QueryString["ds"]),
                                DateEnd = ToDateTime(context.Request.QueryString["de"]),
                                PODateStart = ToDateTime(context.Request.QueryString["pds"]),
                                PODateEnd = ToDateTime(context.Request.QueryString["pde"]),
                                VendorCode = context.Request.QueryString["vc"],
                                UserID = userId,
                                IsExport = bExport,
                                RoleID = roleId
                            });

                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "10":  //IVRemark.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.IV.ABiIVRemark>(context.Request);
                            var helper = new VPBLL.IV.IVHelper();
                            int invoiceId;
                            if (int.TryParse(context.Request.QueryString["id"], out invoiceId))
                            {
                                var list = helper.getIVRemarkGR(invoiceId, userId);

                                fl = parser.Parse(list.AsQueryable(), bExport);
                            }
                        }
                        break;
                    case "11":  //IVDetail.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.IV.ABiIVDetail>(context.Request);
                            var helper = new VPBLL.IV.IVHelper();
                            int invoiceId;
                            if (int.TryParse(context.Request.QueryString["id"], out invoiceId))
                            {
                                var list = helper.getInvoiceDetail(invoiceId, userId);
                                fl = parser.Parse(list.AsQueryable(), bExport);
                            }
                        }
                        break;
                    case "21"://VendorCompanyReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.Vendor.ABiVendorCompany>(context.Request);
                            var helper = new VPBLL.Vendor.VenderHelper();
                            string seachCode = context.Request.QueryString["vc"];
                            if (roleId == 4)
                            {
                                VPBLL.Users.UsersHelper uhelper = new VPBLL.Users.UsersHelper();
                                List<VPBLL.Users.ABiAdminUsers> uList = uhelper.getUsersByID(userId);
                                if (uList != null && uList.Count > 0)
                                {
                                    seachCode = uList[0].Username;
                                }
                            }

                            var list = helper.getABiVendorCompany(new VPBLL.Vendor.VenderHelper.QueryCondition()
                            {

                                VendorCode = seachCode,
                                VendorName = context.Request.QueryString["vn"],
                                TaxNumber = context.Request.QueryString["tn"],
                                CompanyCode = context.Request.QueryString["cc"],
                                DateBegin = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToMaxDateTime(context.Request.QueryString["ed"]),
                                //DateBegin = Convert.ToDateTime("2001-01-01 00:00:00"),
                                //DateEnd = Convert.ToDateTime("2020-01-01 00:00:00"),
                                UserID=userId,
                                RoleID=roleId
                            });
                            list.AsQueryable();
                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;

                    case "22"://CompanyReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.Company.ABiCompany>(context.Request);
                            var helper = new VPBLL.Company.CompanyHelper();
                            var list = helper.getABiCompany(new VPBLL.Company.CompanyHelper.QueryCondition()
                            {
                                CompanyCode = context.Request.QueryString["cc"],
                                CompanyName = context.Request.QueryString["cn"],
                            });
                            list.AsQueryable();
                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "23"://PlantReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.Plant.ABiPlant>(context.Request);
                            var helper = new VPBLL.Plant.PlantHelper();
                            var list = helper.getABiPlant(new VPBLL.Plant.PlantHelper.QueryCondition()
                            {
                                PlantCode = context.Request.QueryString["pc"]
                            });
                            list.AsQueryable();
                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "24"://VendorActiveReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.Vendor.ABiVendorReport>(context.Request);
                            var helper = new VPBLL.Vendor.VenderHelper();
                            var list = helper.getABiVendorActive(new VPBLL.Vendor.VenderHelper.QueryCondition()
                            {
                                VendorCode = context.Request.QueryString["vc"],
                                VendorName = context.Request.QueryString["vn"],
                                TaxNumber = context.Request.QueryString["tn"],
                                DateBegin = ToDateTime(context.Request.QueryString["sd"]),
                                DateEnd = ToMaxDateTime(context.Request.QueryString["ed"])
                                //DateBegin = Convert.ToDateTime("2001-01-01 00:00:00"),
                                //DateEnd = Convert.ToDateTime("2020-01-01 00:00:00")
                            });
                            list.AsQueryable();
                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "25"://UsersReport.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.Users.ABiUsersRoles>(context.Request);
                            var helper = new VPBLL.Users.UsersHelper();
                            string UserName = context.Request.QueryString["un"];
                            var list = helper.getABiUsersRoles(new VPBLL.Users.UsersHelper.QueryCondition()
                            {
                                UserName = context.Request.QueryString["un"],
                                Name = context.Request.QueryString["nm"],
                                Status = context.Request.QueryString["st"],
                                ABi_Admin_Roles_ID = context.Request.QueryString["ro"]
                            });
                            list.AsQueryable();
                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "26"://UsersCompany.aspx
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.Users.UsersCompany>(context.Request);
                            var helper = new VPBLL.Company.CompanyHelper();
                            var list = helper.getUsersCompany(new VPBLL.Company.CompanyHelper.QueryCondition()
                            {
                                CompanyCode = context.Request.QueryString["cc"],
                                CompanyName = context.Request.QueryString["cn"],
                                ABi_Admin_Users_ID = context.Request.QueryString["Admin_Users_ID"],
                                Type = context.Request.QueryString["type"]
                            });
                            list.AsQueryable();
                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                    case "30":
                        {
                            var parser = new VPBLL.DataTable.DataTableParser<VPBLL.Vendor.ABiVendor>(context.Request);
                            var helper = new VPBLL.Vendor.VenderHelper();
                            String cc = context.Request.QueryString["cc"];
                            String ia = context.Request.QueryString["ia"];
                            String hi = context.Request.QueryString["hi"];
                            var list = helper.getVenders(ia, cc, hi);
                            list.AsQueryable();
                            fl = parser.Parse(list.AsQueryable(), bExport);
                        }
                        break;
                }

                if (fl != null)
                {
                    if (!bExport)
                    {
                        context.Response.ContentType = "application/json";
                        context.Response.Write(fl.ToJSON());
                    }
                    else
                    {
                        context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                        context.Response.ContentType = "application/ms-excel";
                        context.Response.Charset = "GB2312";
                        context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("export" + ".xls", System.Text.Encoding.GetEncoding("GB2312")).ToString());
                        context.Response.Write(fl.ToCVS());
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogError("", ex);
            }
        }
Exemplo n.º 2
0
        protected void btnV2DataQuery_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtInvoiceNumber.Text))
            {
                VPBLL.IV.IVHelper helper = new VPBLL.IV.IVHelper();
                var ivs = helper.getIV(new VPBLL.IV.IVHelper.QueryCondition() {
                    InvoiceNumber = txtInvoiceNumber.Text,
                    VendorCode = txtVendorCode.Text,
                    UserID = this.UserID
                });

                gvV2Invoices.DataSource = ivs;
                gvV2Invoices.DataKeyNames = new String[] { "InvoiceID"};
                gvV2Invoices.DataBind();
            }
        }