using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.OA.DAL.Jiekuan2; using DSWeb.Areas.OA.Models.Jiekuan; using DSWeb.Areas.OA.Models.Comm; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using DSWeb.TruckMng.Helper.Repository; using DSWeb.Areas.CommMng.DAL; using HcUtility.Comm; using HcUtility.Core; using Microsoft.Practices.EnterpriseLibrary.Data; using System.Text; using System.Data; namespace DSWeb.Areas.OA.Controllers { [JsonRequestBehavior] public class Jiekuan2Controller : Controller { // // GET: /Import/XXH public ActionResult Index() { return View(); } // // GET: /Import/XXH/Edit public ActionResult Edit() { return View(); } // GET: /Import/XXH public ActionResult NewIndex() { return View(); } // // GET: /Import/XXH/Edit public ActionResult NewEdit() { return View(); } public ActionResult NewAuditIndex() { return View(); } // // GET:/Import/XXH/GetDataList public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = Jiekuan2DAL.GetDataList(condition); 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 GetJieKuan2Body ( string condition ) { var dataList = Jiekuan2DAL.GetJieKuan2Body(condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetData(string handle, string condition) { Jiekuan2mb head = null; if (handle == "edit") { var list = Jiekuan2DAL.GetDataList(condition); if (list.Count > 0) head = list[0]; } if (head == null) { head = new Jiekuan2mb(); head.OP = Convert.ToString(Session["SHOWNAME"]); head.CURRENCY = "RMB"; } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data, string data2, string Jiekuan2Body, string Jiekuan2DelBody) { var head = JsonConvert.Deserialize(data.Replace("}", ",") + data2.Replace("{", "") ); var FeebodyList = JsonConvert.Deserialize>(Jiekuan2Body); var FeeDelbodyList = JsonConvert.Deserialize>(Jiekuan2DelBody); if (Jiekuan2Body!="") { foreach (var _F in FeebodyList) { _F.UNITPRICE = _F.AMOUNT; _F.NOTAXAMOUNT = _F.AMOUNT; _F.TAXUNITPRICE = _F.AMOUNT; if (_F.JKGID == "*") { _F.DbOperationType = DbOperationType.DbotIns; } else _F.DbOperationType = DbOperationType.DbotUpd; } } if (opstatus == "add") { head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; head.GID = PubSysDAL.GetBillNo("0402"); //获取管理费单号 head.BILLNO = head.GID; //20131011 应客户要求,将合同号改为接单人手动填写的必填项目。不再自动生成合同号 //自动填写接单审单人id //改为由前台自动生成 //head.CREATEUSER = CookieConfig.GetCookie_UserName(Request); //head.COMPANY = CookieConfig.GetCookie_OrgName(Request); } else if (opstatus == "edit") { head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; head.BILLNO = head.GID; } else { head.DbOperationType = DbOperationType.DbotDel; } if (head.AMOUNT==null||head.AMOUNT=="") head.AMOUNT = "0"; var modb = new ModelObjectRepository(); DBResult result = modb.Save(head, ModelObjectConvert.ToModelObjectList(FeebodyList), ModelObjectConvert.ToModelObjectList(FeeDelbodyList) ); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = Jiekuan2DAL.GetData("jk.GID='" + head.GID + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Delete(string data,string USERID) { var head = JsonConvert.Deserialize(data); var modb = new ModelObjectDB(); DBResult result = modb.Delete(head,USERID,true); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SaveDetail(string Jiekuan2Body, string JKGID) { var FeebodyList = JsonConvert.Deserialize>(Jiekuan2Body); var JieKuanHead = Jiekuan2DAL.GetData("jk.GID='"+JKGID+"'"); decimal amount = 0; if (Jiekuan2Body != "") { foreach (var _F in FeebodyList) { _F.UNITPRICE = _F.AMOUNT; _F.NOTAXAMOUNT = _F.AMOUNT; _F.TAXUNITPRICE = _F.AMOUNT; if (_F.JKGID == "*") { _F.DbOperationType = DbOperationType.DbotIns; _F.JKGID = JKGID; } else _F.DbOperationType = DbOperationType.DbotUpd; amount = amount + _F.AMOUNT; } } if (amount > Convert.ToDecimal(JieKuanHead.AMOUNT)) { //刷新父窗口上的父节点 var jsonRespose2 = new JsonResponse { Success =false, Message ="添加金额不能大于借款总额!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } var modb = new ModelObjectRepository(); DBResult result = modb.Save(ModelObjectConvert.ToModelObjectList(FeebodyList)); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteDetail(string Jiekuan2Body) { var FeebodyList = JsonConvert.Deserialize>(Jiekuan2Body); var modb = new ModelObjectDB(); DBResult result = null; foreach(var items in FeebodyList) result = modb.Delete(items); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 工作流审批驳回部分 //提交审核 public ContentResult SubmitAuditNew(string JieKuan2List) { var billData = JsonConvert.Deserialize>(JieKuan2List); DBResult result = Jiekuan2DAL.SubmitAuditNew( Convert.ToString(Session["USERID"]), billData); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } //审核通过 public ContentResult Audit(string JieKuan2List) { var billData = JsonConvert.Deserialize>(JieKuan2List); DBResult result = Jiekuan2DAL.Audit( Convert.ToString(Session["USERID"]), billData); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } //审核驳回 public ContentResult AuditBack(string JieKuan2List, string reasean) { //需要处理 如果此借款单内存在“BXGID不为空”的chfee ,则不允许回退 var billData = JsonConvert.Deserialize>(JieKuan2List); var bxgidstr = ""; foreach (var bill in billData) { if (bxgidstr == "") bxgidstr = bxgidstr +"'"+bill.GID+"'"; else bxgidstr = bxgidstr + ",'" + bill.GID + "'"; } bxgidstr = "(" + bxgidstr + ")"; var JieKuanList = Jiekuan2DAL.GetDataList(" jk.GID IN (SELECT DISTINCT JKGID FROM ch_fee WHERE ISNULL(BXGID,'')<>'' AND JKGID IN " + bxgidstr + ") "); if (JieKuanList.Count != 0) { var JieKuanGID = ""; foreach (var JieKuan in JieKuanList) { if (JieKuanGID!="") JieKuanGID = JieKuanGID + "," + JieKuan.GID; else JieKuanGID =JieKuan.GID; } var jsonRespose2 = new JsonResponse { Success = false, Message = "借款单号:" + JieKuanGID+" 已核销不允许撤销审核!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } DBResult result = Jiekuan2DAL.AuditBack( Convert.ToString(Session["USERID"]), billData, reasean); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } #endregion } }