using System; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.Account.DAL.Chfee_Recvapplication; using DSWeb.Areas.Account.Models.Chfee_Recvapplication; using DSWeb.Areas.Account.Models.Chfee_do_detail; using DSWeb.Areas.Account.Models.BillChfeeDetail; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using DSWeb.Areas.CommMng.DAL; using System.Collections.Generic; using HcUtility.Comm; using HcUtility.Core; using DSWeb.EntityDA; using DSWeb.Areas.Account.Models.Chfee_Exrate; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using DSWeb.MvcShipping.Models.MsSysBillNoSet; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.Areas.Account.DAL.Chfee_payapplication; using System.IO; using DSWeb.Areas.Account.Models.Chfee_payapplication; using System.Globalization; using System.Web.Script.Serialization; namespace DSWeb.Areas.Account.Controllers { [JsonRequestBehavior] public class Chfee_recvapplicationController : Controller { // // GET: public ActionResult Index() { return View(); } // // GET: / public ActionResult Edit() { return View(); } public ActionResult BLEdit() { return View(); } //付费申请审核 public ActionResult Audit() { return View(); } // // GET: public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = ChrecvapplicationDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetData(string handle, string condition) { ChRecvapplication head = null; if (handle == "edit") { var list = ChrecvapplicationDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request),Convert.ToString(Session["COMPANYID"])); if (list.Count > 0) head = list[0]; } if (head == null) { head = new ChRecvapplication(); } if (handle == "add") { head.APPLICANT = Convert.ToString(Session["USERID"]); head.APPLICANTNAME = Convert.ToString(Session["SHOWNAME"]); head.RECVTIME = DateTime.Now.ToString("yyyy-MM-dd"); // head.CURR = Convert.ToString(Session["LOCALCURR"]); head.SETTLETYPE = 7; head.COMPANYID = Convert.ToString(Session["COMPANYID"]); //head.SALECORPID = Convert.ToString(Session["COMPANYID"]); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult GetBillList(string condition, string sort) { var dataList = ChrecvapplicationDAL.GetBodyList(condition,sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBillSum(string condition) { var dataList = ChrecvapplicationDAL.GetBodySumList(condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetFeeDataList(int start, int limit, string sort, string condition) { var dataList = ChrecvapplicationDAL.GetFeeDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBillDataList(int start, int limit, string sort, string condition) { var dataList = ChrecvapplicationDAL.GetAddBillList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetFeeDetailList(string sort, string condition) { var dataList = ChrecvapplicationDAL.GetFeeDetailList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetAddSum(string condition) { var dataList = ChrecvapplicationDAL.GetAddSum(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data) { var headData = JsonConvert.Deserialize(data); if (opstatus == "add") { headData.GID = Guid.NewGuid().ToString(); headData.COMPANYID = Convert.ToString(Session["COMPANYID"]); headData.APPLICANT = Convert.ToString(Session["USERID"]); headData.APPLYTIME = null; headData.ENTERTIME = DateTime.Now; headData.SETTLETIME = null; headData.AUDITTIME = null; //headData.DELETETIME = null; headData.DbOperationType = DbOperationType.DbotIns; var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='收费申请'", Convert.ToString(Session["COMPANYID"])); var RECVAPPBILLISCUSTNO = MsSysParamSetDAL.GetData("PARAMNAME='RECVAPPBILLISCUSTNO'"); if (headData.BILLNO != ""&& RECVAPPBILLISCUSTNO.PARAMVALUE == "1") { headData.BILLNO = ChrecvapplicationDAL.GetCustNo(headData.BILLNO); } else { if (billnoset.BILLTYPE != "") headData.BILLNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.RECVTIME.ToString().Trim(), headData.APPLYTIME.ToString()); else headData.BILLNO = PubSysDAL.GetBillNo("0307"); } } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } var ct = ChrecvapplicationDAL.GetRdCount("GID<>'" + headData.GID + "' AND BILLNO='" + headData.BILLNO + "' "); if (ct != 0) { var jsonRespose0 = new JsonResponse { Success = false, Message = "收费申请重复,不允许保存!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose0) }; } var BILLNO = headData.BILLNO; var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); if (result.Success == true) { } else { MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = ChrecvapplicationDAL.GetData(" BILLNO='" + BILLNO + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddDetail(string bill, string data, string curr) { var bodyList = JsonConvert.Deserialize>(data); //2023-1-28 //如果此次选择的业务中,销售人员的所属公司分属不同,返回错误 //如果头表所属分部为空 将其设置为所选业务的销售人员所属的公司 并保存; //如果头表所属分部不为空 判断所属分部与所选业务的销售人员所属的公司是否相同 如否则返回错误; var bsnoList = bodyList.Select(s => s.BSNO).Distinct().ToList(); var _r = ChrecvapplicationDAL.SetSALECORP(bill, bsnoList, "", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"])); if (!_r.Success) { return BasicDataRefDAL.GetContentResult(_r); } var modb = new ModelObjectDB(); DBResult result = ChrecvapplicationDAL.AddDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"])); if (result.Success) { ChrecvapplicationDAL.p_update_Amount(bill); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddBill(string billno, string billcust, string billcurr, string feesql, string storeCurrExrate, bool custgroup = false) { var exrateList = JsonConvert.Deserialize>(storeCurrExrate); if (!custgroup) feesql = feesql + " AND CUSTOMERNAME='" + billcust + "'"; var feelist = ChrecvapplicationDAL.GetFeeDetailList(feesql, Convert.ToString(Session["USERID"]), "", Convert.ToString(Session["COMPANYID"])); //2023-1-28 //如果此次选择的业务中,销售人员的所属公司分属不同,返回错误 //如果头表所属分部为空 将其设置为所选业务的销售人员所属的公司 并保存; //如果头表所属分部不为空 判断所属分部与所选业务的销售人员所属的公司是否相同 如否则返回错误; var _r = ChrecvapplicationDAL.SetSALECORP(billno, feesql, billcust, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), custgroup); if (!_r.Success) { return BasicDataRefDAL.GetContentResult(_r); } if ((exrateList == null) || (exrateList.Count == 0)) { if (billcurr != "") exrateList = ChrecvapplicationDAL.GetCurrExrateData(billcust, billcurr, feesql, custgroup); if ((exrateList == null) || (exrateList.Count == 0)) { var modb = new ModelObjectDB(); DBResult result = ChrecvapplicationDAL.AddBill(billno, billcust, billcurr, feesql, exrateList, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), custgroup); if (result.Success) { ChrecvapplicationDAL.p_update_Amount(billno); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = true, Message = "查询成功", Data = exrateList.ToList() }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } else { var modb = new ModelObjectDB(); DBResult result = ChrecvapplicationDAL.AddBill(billno, billcust, billcurr, feesql, exrateList, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"])); if (result.Success) { ChrecvapplicationDAL.p_update_Amount(billno); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult DelBill(string data, string billno) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChrecvapplicationDAL.DelFeeDo(bodyList); if (result.Success) { ChrecvapplicationDAL.p_update_Amount(billno); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } // public ContentResult Delete(string data) { var headData = JsonConvert.Deserialize(data); var dataList = ChrecvapplicationDAL.GetBodyList("BILLNO='" + headData.BILLNO + "'"); DBResult result = ChrecvapplicationDAL.DelFeeDo(dataList); if (result.Success == true) { var modb = new ModelObjectDB(); modb.Delete(headData); MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 提交和撤销审核 public ContentResult SubmitAudit(string bill) { DBResult result = ChrecvapplicationDAL.SubmitAudit("FeeSettleAudit", Convert.ToString(Session["USERID"]), bill); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult SubmitAuditBack(string bill) { DBResult result = ChrecvapplicationDAL.SubmitAuditBack(bill); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult SubmitAuditList(string bills) { DBResult result = ChrecvapplicationDAL.SubmitAuditList(bills); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult SubmitAuditBackList(string bills) { DBResult result = ChrecvapplicationDAL.SubmitAuditBackList(bills); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult AuditList(string data) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChrecvapplicationDAL.AuditList(bodyList, Convert.ToString(Session["SHOWNAME"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AuditBackList(string data,string ORREASON) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChrecvapplicationDAL.AuditBackList(bodyList, ORREASON, Convert.ToString(Session["SHOWNAME"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult UpdatePrint(string billnos) { var result = new DBResult(); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string blUpSQL = " update ch_fee_recvapplication set PRINTCOUNT=ISNULL(PRINTCOUNT,0)+1 where BILLNO IN (" + billnos + ")"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); result.Success = true; result.Message = "更新成功!"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, // Data = MsChFeeDAL.GetDataList(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 参照部分 #endregion /// /// 获取车辆证件信息 /// /// /// public ContentResult GetFileList(string BillNo) { var dataList = ChfeeFileDal.GetFileList(BillNo); //var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } /// /// 上传证件照片 /// /// public ContentResult FileUpload() { var jsonRespose = new JsonResponse { Success = false, Message = "" }; if (Request.Files.Count != 1) { jsonRespose.Success = false; jsonRespose.Message = "请选择上传的文件"; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var imgFile = Request.Files["file"]; var BillNo = Request.Form["BillNo"].ToString().Trim(); String strPath = "/Areas/Account/Files/" + BillNo + "/"; String dirPath = System.Web.HttpContext.Current.Server.MapPath(strPath); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } string fileOriginalName = Path.GetFileNameWithoutExtension(imgFile.FileName); String fileExt = Path.GetExtension(imgFile.FileName).ToLower(); String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt; String filePath = dirPath + newFileName; imgFile.SaveAs(filePath); //写入数据库 ChfeeFile model = new ChfeeFile(); model.GID = Guid.NewGuid().ToString(); model.BillNo = BillNo; model.File_Type = 0; model.File_Name = newFileName; model.File_Path = filePath; model.CreateTime = DateTime.Now.ToShortDateString(); model.Operator = Session["USERID"] != null ? Session["USERID"].ToString() : ""; model.File_OriginalName = fileOriginalName; model.File_DocNo = Request.Form["File_DocNo"]; model.File_DocType = Request.Form["File_DocType"]; string msg = ""; bool success = ChfeeFileDal.SaveFile(model, 0, out msg); jsonRespose.Success = success; jsonRespose.Message = msg; var json = JsonConvert.Serialize(new { success = success, Message = "上传成功", filePath = filePath }); return new ContentResult() { Content = json }; } public ContentResult CertDel(string TruckNo) { var data = Request["data"]; JavaScriptSerializer json = new JavaScriptSerializer(); List file = json.Deserialize>(data); string msg = ""; bool rst = false; if (file != null) { rst = ChfeeFileDal.DelFile(file, out msg); //20220823 增加处理 删除路径相同的其他附件数据, //ChfeeFileDal.DelOtherFile(file, out msg); } var jsonstr = JsonConvert.Serialize(new { Success = rst, Message = rst ? "删除成功" : msg }); return new ContentResult() { Content = jsonstr }; } } }