You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
15 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using DSWeb.MvcShipping.Comm.Cookie;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Helper.Repository;
using DSWeb.MvcShipping.Models.MsOpAuditDetail;
using DSWeb.Areas.Account.Models.MsOpBill;
using DSWeb.Areas.MvcShipping.DAL;
using HcUtility.Comm;
using HcUtility.Core;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpAuditDetailController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult PiLiang()
{
return View();
}
public ActionResult LogIndex()
{
return View();
}
public ActionResult AUIndex()
{
return View();
}
public ContentResult GetListData(int start, int limit, string sort, string condition)
{
var dataList = MsOpAuditDetailDAL.GetDataList(condition,sort);
var list = dataList.Skip(start).Take(limit).ToList();
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list });//list.ToList()
return new ContentResult() { Content = json };
}
public ContentResult GetData(string condition)
{
MsOpAuditDetail head = null;
var list = MsOpAuditDetailDAL.GetDataList(condition);
if (list.Count > 0)
head = list[0];
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetAuditLogList(int start, int limit, string sort, string condition)
{
var dataList = MsOpAuditDetailDAL.GetAuditLogList(condition);
var list = dataList.Skip(start).Take(limit).ToList();
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list });//list.ToList()
return new ContentResult() { Content = json };
}
public ContentResult SaveAndAudit(string bsno, string body,string audit,string oplb,string isamend)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var bodyList = JsonConvert.Deserialize<List<MsOpAuditDetail>>(body);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpAuditDetailDAL.SaveUpdate(bodyList, bsno, Convert.ToString(Session["SHOWNAME"]));
if (result.Success)
{
result = MsOpAuditDetailDAL.SubmitBL(bsno, oplb, isamend, audit, false, Convert.ToString(Session["USERID"]).ToString(), Convert.ToString(Session["SHOWNAME"]));
}
}
else {
result = MsOpAuditDetailDAL.SubmitBL(bsno, oplb, isamend, audit, false, Convert.ToString(Session["USERID"]).ToString(), Convert.ToString(Session["SHOWNAME"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SubmitBL(string bsno, string audit, string oplb, string isamend)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var result= MsOpAuditDetailDAL.SubmitBL(bsno, oplb, isamend, audit, true, Convert.ToString(Session["USERID"]).ToString(), Convert.ToString(Session["SHOWNAME"]));
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AuditBL(string data, string isamend,string amendop,string audit, string auditremark, string isfinish, string errmsg, string errop,string errcust,string auditbody,string prreason="",string bssourcedetail="")
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var auditbodyList = JsonConvert.Deserialize<List<MsOpAuditDetail>>(auditbody);
var billData = JsonConvert.Deserialize<List<MsOpBill>>(data);
var result = new DBResult();
if (billData != null)
{
foreach (var bill in billData)
{
result = MsOpAuditDetailDAL.SaveUpdate(auditbodyList, bill.BSNO, Convert.ToString(Session["SHOWNAME"]));
result = MsOpAuditDetailDAL.AuditBL(bill.BSNO,bill.OPLB,bill.OPTYPE,isamend, amendop, audit, auditremark, isfinish, errmsg, errop,errcust, bill.OP,Convert.ToString(Session["USERID"]).ToString(), Convert.ToString(Session["SHOWNAME"]), prreason, bssourcedetail);
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SelAuditBackBL(string data, string reason,string isnotstl="0")
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var billData = JsonConvert.Deserialize<List<MsOpBill>>(data);
var result = new DBResult();
if (isnotstl != "1")
{
if (billData != null)
{
foreach (var bill in billData)
{
var feecount = MsOpAuditDetailDAL.GetFeeSettCount(" BSNO='" + bill.BSNO + "' AND SETTLEMENT<>0 ");
if (feecount > 0)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "提单号:" + bill.MBLNO + "存在已结算的费用不允许驳回!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
}
}
if (billData != null)
{
foreach (var bill in billData)
{
var ISAMEND = "0";
if (bill.OPTYPE == "更改单") ISAMEND = "1";
result = MsOpAuditDetailDAL.AuditBackBL(bill.BSNO, bill.OPLB, ISAMEND, reason,bill.OP,Convert.ToString(Session["USERID"]).ToString(), Convert.ToString(Session["SHOWNAME"]));
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult CloseAuditBL(string bsno, string oplb, string isamend)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var result = new DBResult();
result = MsOpAuditDetailDAL.CloseAuditBL(bsno,oplb, isamend, Convert.ToString(Session["USERID"]).ToString(), Convert.ToString(Session["SHOWNAME"]));
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult modify(string data, string modifydata)
{
var bodyList = JsonConvert.Deserialize<List<MsOpBill>>(data);
var amodifydata = JsonConvert.Deserialize<MsOpBill>(modifydata);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpAuditDetailDAL.Modify(bodyList, amodifydata, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//public ContentResult PiliangSave(string bill, string body)
//{
// var billList = JsonConvert.Deserialize<List<MsOpBill>>(bill);
// var bodyList = JsonConvert.Deserialize<List<MsOpStatus>>(body);
// var result = new DBResult();
// if (bodyList != null)
// {
// result = MsOpStatusDAL.SavePiliangUpdate(billList,bodyList, Convert.ToString(Session["SHOWNAME"]));
// }
// var jsonRespose = new JsonResponse
// {
// Success = result.Success,
// Message = result.Message,
// };
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//}
public ContentResult Delete(string bsno, string data)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var bodyList = JsonConvert.Deserialize<List<MsOpAuditDetail>>(data);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpAuditDetailDAL.DeleteStatus(bodyList);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult IsAutoAudit(string bsno, string oplb,string isamend,bool issubmit=true)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var result = MsOpAuditDetailDAL.IsAutoAudit(bsno, oplb,isamend, Convert.ToString(Session["USERID"]).ToString(),Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_CompanyId(Request), issubmit);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult CancelAuditBL(string bsno, string oplb, string isamend)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var result = MsOpAuditDetailDAL.CancelAuditBL(bsno, oplb, isamend, Convert.ToString(Session["USERID"]).ToString(), Convert.ToString(Session["SHOWNAME"]));
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
}