public void ProcessRequest(HttpContext context) { String act = ""; String resultMsg = ""; try { act = context.Request.Params["act"]; if (HttpContext.Current.Request.Cookies["UserID"] == null) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_Need_ReLogin, "登陆已失效,请重新登陆").ToMessage(); } else { int userId = Convert.ToInt32(HttpContext.Current.Request.Cookies["UserID"].Value); switch (act) { case "1": //GR_NewIV.aspx String refGRNumList = context.Request.Params["rgn"]; String refGRItemList = context.Request.Params["rgin"]; String invoiceNumber = context.Request.Params["ivn"]; String strInvoiceDate = context.Request.Params["ivd"]; String strTaxAmount = context.Request.Params["ivt"]; String strTotalAmount = context.Request.Params["iva"]; String strVendorRemark = context.Request.Params["vr"]; String poNumList = context.Request.Params["pn"]; String poINList = context.Request.Params["pin"]; DateTime invoiceDate = new DateTime(); double taxAmount; double totalAmount; if (String.IsNullOrEmpty(invoiceNumber) || !(!String.IsNullOrEmpty(strInvoiceDate) && DateTime.TryParse(strInvoiceDate, out invoiceDate)) || !(!String.IsNullOrEmpty(strTaxAmount) && double.TryParse(strTaxAmount, out taxAmount)) || !(!String.IsNullOrEmpty(strTotalAmount) && double.TryParse(strTotalAmount, out totalAmount))) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.New_Invoice_Error_IVInformation_Wrong, "发票输入信息不正确").ToMessage(); break; } if (String.IsNullOrEmpty(refGRItemList) || String.IsNullOrEmpty(refGRItemList) || String.IsNullOrEmpty(poNumList) || String.IsNullOrEmpty(poINList) || refGRItemList.Split(',').Length != refGRItemList.Split(',').Length) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.New_Invoice_Error_GRInformation_Wrong, "收货信息错误").ToMessage(); break; } var result = new VPBLL.GR.GRHelper().createNewIV(userId, refGRNumList, refGRItemList, poNumList, poINList, invoiceNumber, invoiceDate, taxAmount, totalAmount, strVendorRemark); resultMsg = result.ToMessage(); logger.LogInfo(String.Format("NewIV(userId:{0}, refGRNumbers:'{1}', refGRItemNumber'{2}', invoiceNumber:{3}, invoiceDate:{4}) = {5}", userId, refGRNumList, refGRItemList, invoiceNumber, invoiceDate, resultMsg)); if (result.ResponseCode == 1) { try { String subject = "开发票超容差,请备注"; String vendorCode = new VPBLL.Users.UsersHelper().getUsersByID(userId).First().Username; String vendorName = new VPBLL.Vendor.VenderHelper().getABiVendorByCode(vendorCode).First().VendorName; String content = new VPBLL.GR.GRHelper().GetEmailContent(int.Parse(result.ResponseMessage), 3, userId, invoiceNumber, vendorCode, vendorName); List<KeyValuePair<String, String>> buyers = new VPBLL.Vendor.VenderHelper().getBuyerOfCompany(result.ResponseMessage, 3); if (buyers.Count > 0) { var mh = new VPBLL.MailHelper(); mh.EmainSend((from o in buyers select o.Value).ToArray(), content, subject); } } catch (Exception ex) { logger.LogError(String.Format("开票超容差发送email失败"), ex); } } break; case "2": { VPBLL.BasePage bp = new VPBLL.BasePage(); if (bp.RoleID != 5) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_NoPermission, "用户无权限").ToMessage(); } else { String ivId = context.Request.Params["ivd"]; String payAmount = context.Request.Params["pa"]; String payDate = context.Request.Params["dp"]; String mdIV = context.Request.Params["in"]; resultMsg = new VPBLL.IV.IVHelper().updateInvoice(int.Parse(ivId), mdIV, DateTime.Parse(payDate), double.Parse(payAmount)).ToMessage(); logger.LogInfo(String.Format("updateInvoice(invoiceId'{0}', PayDate'{1}', PayAmount'{2}'). UserID:{3}", ivId, payDate, payAmount, bp.UserID)); } } break; case "3": { VPBLL.BasePage bp = new VPBLL.BasePage(); if (bp.RoleID != 5) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_NoPermission, "用户无权限").ToMessage(); } else { string grNumber = context.Request.Params["gn"]; string grItemNumber = context.Request.Params["gin"]; int nRow = new VPBLL.GR.GRHelper().deleteGR(grNumber, grItemNumber); resultMsg = String.Format("{0}&{1}", nRow > 0 ? 0 : -300, nRow.ToString()); logger.LogInfo(String.Format("deleteGR(userID={0}, grNumber={1}, grItemNumber={2}) = {3}", bp.UserID, grNumber, grItemNumber, nRow)); } } break; case "4": { VPBLL.BasePage bp = new VPBLL.BasePage(); if (bp.RoleID != 5) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_NoPermission, "用户无权限").ToMessage(); } else { string grNumber = context.Request.Params["pn"]; string grItemNumber = context.Request.Params["pin"]; int nRow = new VPBLL.PO.POHelper().deletePO(grNumber, grItemNumber); resultMsg = String.Format("{0}&{1}", nRow > 0 ? 0 : -300, nRow.ToString()); logger.LogInfo(String.Format("deleteGR(userID={0}, poNumber={1}, poItemNumber={2}) = {3}", bp.UserID, grNumber, grItemNumber, nRow)); } } break; case "5": { VPBLL.BasePage bp = new VPBLL.BasePage(); if (bp.RoleID != 5) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_NoPermission, "用户无权限").ToMessage(); } else { string strgrinfo = context.Request.Params["gn"]; string strpoinfo = context.Request.Params["po"]; string gn = strgrinfo.Split(',')[0]; string gin = strgrinfo.Split(',')[1]; string pn = strpoinfo.Split(',')[0]; string pin = strpoinfo.Split(',')[1]; int nDelRow = new VPBLL.GR.GRHelper().deleteGRNew(gn, gin, pn, pin, userId); resultMsg = String.Format("{0}&{1}", nDelRow > 0 ? 0 : -300, nDelRow.ToString()); logger.LogInfo(String.Format("deleteGRNew(userID={0}, gn={1}, po={2}) = {3}", bp.UserID, strgrinfo, strpoinfo, nDelRow)); } } break; } } } catch (Exception ex) { logger.LogError(this, ex); resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.SystemError, ex.Message).ToMessage();//"-550&未知错误"; } context.Response.ContentType = "text/plain"; context.Response.Write(resultMsg); }
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); } }
protected void gvV5Result_RowCommand(object sender, GridViewCommandEventArgs e) { lblV5ErrorMessage.Text = ""; if (e.CommandName == "PORecv") { int nIndex = ((GridViewRow)(((Button)(e.CommandSource)).Parent.Parent)).RowIndex; var obj = gvV5Result.DataKeys[nIndex]; int poSwapID = int.Parse(obj.Value.ToString()); VPBLL.PO.POHelper help = new VPBLL.PO.POHelper(); if (help.resetSwapPO(poSwapID) == "更新成功") { lblV5ErrorMessage.Text = "更新成功。请等待几分钟,后台同步服务将重新发送"; lblV5ErrorMessage.ForeColor = System.Drawing.Color.Green; UpdateV5Result(); } else { lblV5ErrorMessage.Text = "更新失败"; lblV5ErrorMessage.ForeColor = System.Drawing.Color.Red; } } }