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.

2133 lines
103 KiB
C#

11 months ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcContainer.Models.MsOpCtnApply;
using DSWeb.MvcContainer.DAL.MsOpCtnApply;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
using System.Text;
using DSWeb.Areas.CommMng.Models;
using System.Data;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcContainer.Models.MsOpCtnBsCard;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.TruckMng.Helper.Repository;
using DSWeb.MvcShipping.DAL.MsOpSeaeDAL;
using DSWeb.MvcShipping.Models.MsOpSeae;
using DSWeb.MvcContainer.DAL.MsCodeCtnTk;
using DSWeb.MvcContainer.DAL.MsOpCtnBsCard;
namespace DSWeb.MvcContainer.Controllers
{
[JsonRequestBehavior]
public class MsOpCtnApplyController : Controller
{
//
// GET:
public ActionResult SalesIndex()
{
return View();
}
//
// GET: /
public ActionResult SalesEdit()
{
return View();
}
public ActionResult SalesAudit()
{
return View();
}
public ActionResult GoodsAudit()
{
return View();
}
public ActionResult GoodsAuditEdit()
{
return View();
}
public ActionResult CostIndex()
{
return View();
}
public ActionResult CostEdit()
{
return View();
}
public ActionResult CostAudit()
{
return View();
}
public ActionResult CostHistryIndex()
{
return View();
}
public ActionResult CostMdAudit()
{
return View();
}
public ActionResult CostAuditEdit()
{
return View();
}
public ActionResult AddCtn()
{
return View();
}
public ActionResult AddCtnEdit()
{
return View();
}
//
// GET
public ContentResult GetDataList(int start, int limit, string sort, string condition, string pricetype)
{
var dataList = MsOpCtnApplyDAL.GetDataList(start, limit,condition, pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), sort);
int count = MsOpCtnApplyDAL.getTotalCount(condition, pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetAddCtnDataList(int start, int limit, string sort, string condition, string pricetype)
{
var dataList = MsOpCtnApplyDAL.GetAddCtnDataList(start, limit, condition, pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), sort);
int count = MsOpCtnApplyDAL.getTotalCount(condition, pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataListStr(string sort, string condition, string pricetype)
{
var dataListStr = MsOpCtnApplyDAL.GetDataListStr(condition, pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition,string pricetype="")
{
OpCtnApply head = null;
if (handle == "edit")
{
head = MsOpCtnApplyDAL.GetData(condition, pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (head == null)
{
head = new OpCtnApply();
head.COMPANYID = Convert.ToString(Session["COMPANYID"]);
head.SALE = Convert.ToString(Session["SHOWNAME"]);
head.OP = Convert.ToString(Session["SHOWNAME"]);
head.INPUTBYREF = Convert.ToString(Session["SHOWNAME"]);
head.INPUTBY = Convert.ToString(Session["USERID"]);
head.CURRENCY = "USD";
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string body)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data);
var bodyList = JsonConvert.Deserialize<List<OpCtnApplySaleitems>>(body);
var errorstr = "";
var isPost = true;
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.COMPANYID = Convert.ToString(Session["COMPANYID"]);
headData.INPUTBY = Convert.ToString(Session["USERID"]);
headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.BSDATE = DateTime.Now.ToString("yyyy-MM-dd");
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='放箱审批'", Convert.ToString(Session["COMPANYID"]));
if (billnoset.BILLTYPE != "")
headData.BSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.BSDATE.ToString().Trim(), headData.BSDATE.ToString().Trim());
else
{
errorstr = "放箱审批的申请编号规则未设置,请先设置编号生成规则!";
isPost = false;
}
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (headData.BSNO == null || headData.BSNO.Trim() == "") {
errorstr = "申请单号不能为空!";
isPost = false;
}
if (headData.PLANCTNDATE == "") headData.PLANCTNDATE = null;
if (!string.IsNullOrEmpty(headData.COSTTRANSTYPE)) headData.COSTTRANSTYPE = headData.TRANSTYPE;
var GID = headData.GID;
if (isPost)
{
var modb = new ModelObjectDB();
var result = modb.Save(headData);
if (result.Success == true)
{
MsOpCtnApplyDAL.SaveCtnApplySaleItems(bodyList, GID, Convert.ToString(Session["USERID"]));
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var updatestr = "'" + headData.PLANCTNDATE + "'";
if (headData.PLANCTNDATE == null) {
updatestr = "NULL";
}
string blUpSQL = "update op_ctnbscard set AGENTNAME='" + headData.AGENTNAME + "',PRE_CNT_TIME=" + updatestr + " where APPLYNO='" + headData.BSNO + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
5 months ago
//MsOpCtnApplyDAL.SaveApplyFee(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
11 months ago
5 months ago
//var OP = T_ALL_DA.GetStrSQL("USERID", "select top 1 USERID from VW_user where SHOWNAME='" + headData.OP + "'");
//MsOpCtnApplyDAL.SaveFeeDR(headData.CTN_PRICE, headData.CURRENCY, GID, Convert.ToString(Session["USERID"]), Convert.ToInt16(headData.CTNNUM), headData.OWNERCTN, OP);
}
11 months ago
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpCtnApplyDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
var jsonRespose = new JsonResponse { Success = false, Message = errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnApply>>(data);
var isdelete = true;
var errmsg = "";
if (headData != null)
{
foreach (var enumValue in headData)
{
var vct = MsOpCtnBsCardDAL.GetRdCount("APPLYNO='" + enumValue.BSNO+"'");
if (vct != 0) {
isdelete = false;
errmsg = errmsg + "申请单号:"+ enumValue.BSNO+",存在业务卡。";
}
var dataList = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList("B.LINKGID='" + enumValue.GID + "'", "");
if (dataList != null && dataList.Count > 0) {
isdelete = false;
errmsg = errmsg + "申请单号:" + enumValue.BSNO + "存在配箱明细,不允许删除!";
}
}
}
if (!isdelete)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = errmsg };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
else
{
DBResult result = MsOpCtnApplyDAL.DeleteOpCtnApply(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult GetModifyData(string handle, string condition)
{
OpCtnApplyModify head = null;
if (handle == "edit")
{
head = MsOpCtnApplyDAL.GetModifyData(condition, Convert.ToString(Session["SHOWNAME"]));
}
if (head == null)
{
head = new OpCtnApplyModify();
head.INPUTBYREF = Convert.ToString(Session["SHOWNAME"]);
head.INPUTBY = Convert.ToString(Session["USERID"]);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult ShenModifyDel(string data,string type)
{
var headData = JsonConvert.Deserialize<OpCtnApplyModify>(data);
var errorstr = "";
var isPost = true;
var GID = headData.GID;
headData.DbOperationType = DbOperationType.DbotIns;
headData.GID = Guid.NewGuid().ToString();
headData.APPLYID = GID;
headData.INPUTBY = Convert.ToString(Session["USERID"]);
headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.BSDATE = DateTime.Now.ToString("yyyy-MM-dd");
if (headData.PLANCTNDATE == "") headData.PLANCTNDATE = null;
headData.MODIFYTYPE = type;
headData.MDSTATUS = "1";
var msgstr = "";
if (isPost)
{
var modb = new ModelObjectDB();
var result = modb.Save(headData);
if (result.Success == true) {
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (type == "4")
{
msgstr = "放箱申请-申请删除";
string blUpSQL = "update op_ctnapply set AUDITSTATUS='申请删除',BSSTATUS='销售申请删除' where GID='" + GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}else if (type == "7")
{
msgstr = "放箱申请-罐箱费申请修改";
string blUpSQL = "update op_ctnapply set CTNPRICESTATUS='申请修改' where GID='" + GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
else
{
msgstr = "放箱申请-申请修改";
string blUpSQL = "update op_ctnapply set AUDITSTATUS='申请修改',BSSTATUS='销售申请修改' where GID='" + GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var strSql = new StringBuilder();
strSql.Append("SELECT USERID FROM ");
strSql.Append(" user_action WHERE ACTIONID in (select GID from action where [NAME]='modOpCtnApplySaleAudit') ");
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLYMODIFY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT =msgstr+" 单号:" + headData.BSNO;
Msgdata.RECEIVER = Convert.ToString(reader["USERID"]);
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
reader.Close();
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpCtnApplyDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult ShenModifyAudit(string data, string type, string reasean="")
{
var headData = JsonConvert.Deserialize<List<OpCtnApply>>(data);
var errorstr = "";
var isPost = true;
var result = new DBResult();
result.Success = true;
result.Message = "审核成功!";
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var isdelete = true;
var errmsg = "";
if (headData != null)
{
foreach (var enumValue in headData)
{
if ((type == "1")&&(enumValue.AUDITSTATUS == "申请删除"))
{
var vct = MsOpCtnBsCardDAL.GetRdCount("APPLYNO='" + enumValue.BSNO + "'");
if (vct != 0)
{
isdelete = false;
errmsg = errmsg + "申请单号:" + enumValue.BSNO + ",存在业务卡不允许删除。";
}
}
}
}
if (!isdelete)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = errmsg };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
if (headData != null)
{
foreach (var enumValue in headData)
{
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLYMODIFY";
Msgdata.RECEIVER = enumValue.INPUTBY;
if (type == "0")
{
if (enumValue.AUDITSTATUS == "申请删除") {
Msgdata.NAME = "放箱申请-驳回申请删除";
Msgdata.MESSAGECONTENT = "放箱申请-驳回申请删除 单号:"+enumValue.BSNO;
string blUpSQL = "update op_ctnapply_modify set MDSTATUS='3' where MDSTATUS='1' and MODIFYTYPE='4' AND APPLYID='" + enumValue.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "update op_ctnapply set AUDITSTATUS='驳回申请删除',BSSTATUS='驳回销售申请删除',AUDITRESULT='"+reasean+"' where GID='" + enumValue.GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
if (enumValue.AUDITSTATUS == "申请修改")
{
Msgdata.NAME = "放箱申请-驳回申请修改";
Msgdata.MESSAGECONTENT = "放箱申请-驳回申请修改 单号:" + enumValue.BSNO;
string blUpSQL = "update op_ctnapply_modify set MDSTATUS='3' where MDSTATUS='1' and MODIFYTYPE='1' AND APPLYID='" + enumValue.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "update op_ctnapply set AUDITSTATUS='审核通过',BSSTATUS='驳回销售申请修改',AUDITRESULT='" + reasean + "' where GID='" + enumValue.GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
}
else if (type == "1")
{
if (enumValue.AUDITSTATUS == "申请删除") {
Msgdata.NAME = "放箱申请-批准申请删除";
Msgdata.MESSAGECONTENT = "放箱申请-批准申请删除 单号:" + enumValue.BSNO;
string blUpSQL = "delete from op_ctnapply where GID='" + enumValue.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "delete from op_ctnapply_modify where APPLYID='" + enumValue.GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
if (enumValue.AUDITSTATUS == "申请修改")
{
Msgdata.NAME = "放箱申请-批准申请修改";
Msgdata.MESSAGECONTENT = "放箱申请-批准申请修改 单号:" + enumValue.BSNO;
var head = MsOpCtnApplyDAL.GetModifyData("APPLYID='" + enumValue.GID + "' AND MDSTATUS='1' AND MODIFYTYPE='1' ", Convert.ToString(Session["SHOWNAME"]));
if (head.BSNO != "")
{
OpCtnApplyModify opapplymodify = new OpCtnApplyModify();
opapplymodify.DbOperationType = DbOperationType.DbotIns;
opapplymodify.GID = Guid.NewGuid().ToString();
opapplymodify.APPLYID = enumValue.GID;
opapplymodify.INPUTBY = Convert.ToString(Session["USERID"]);
opapplymodify.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
opapplymodify.BSDATE = DateTime.Now.ToString("yyyy-MM-dd");
if (opapplymodify.PLANCTNDATE == "") opapplymodify.PLANCTNDATE = null;
opapplymodify.MODIFYTYPE ="2";
opapplymodify.MDSTATUS = "2";
opapplymodify.SALE = enumValue.SALE;
opapplymodify.OP = enumValue.OP;
opapplymodify.CUSTOMERNAME = enumValue.CUSTOMERNAME;
opapplymodify.GOODSNAME = enumValue.GOODSNAME;
opapplymodify.GOODTYPE = enumValue.GOODTYPE;
opapplymodify.PORTLOAD = enumValue.PORTLOAD;
opapplymodify.PORTDISCHARGE = enumValue.PORTDISCHARGE;
opapplymodify.ISOWNERBOOKING = enumValue.ISOWNERBOOKING;
opapplymodify.CTNALL = enumValue.CTNALL;
opapplymodify.CTNNUM = enumValue.CTNNUM;
opapplymodify.FACTORYNAME = enumValue.FACTORYNAME;
opapplymodify.PLANCTNDATE = enumValue.PLANCTNDATE;
opapplymodify.FACTORYADDR = enumValue.FACTORYADDR;
opapplymodify.SLOAD_FREE_USECTNE_DAY = enumValue.SLOAD_FREE_USECTNE_DAY;
opapplymodify.SLOAD_OVER_USECTNE_RATE = enumValue.SLOAD_OVER_USECTNE_RATE;
opapplymodify.SDEST_FREE_USECTNE_DAY = enumValue.SDEST_FREE_USECTNE_DAY;
opapplymodify.SDEST_OVER_USECTNE_RATE = enumValue.SDEST_OVER_USECTNE_RATE;
opapplymodify.AGENTNAME = enumValue.AGENTNAME;
opapplymodify.REMARKS = enumValue.REMARKS;
opapplymodify.ISPORTLOADDATE = enumValue.ISPORTLOADDATE;
opapplymodify.SERVICE = enumValue.SERVICE;
opapplymodify.NEEDBEHEATED = enumValue.NEEDBEHEATED;
opapplymodify.WEIGHT = enumValue.WEIGHT;
opapplymodify.EMPTYCTNALLOCATION = enumValue.EMPTYCTNALLOCATION;
opapplymodify.PREI_ETD = enumValue.PREI_ETD;
opapplymodify.SLOAD_OVER_USECTNE_RATE = enumValue.SLOAD_OVER_USECTNE_RATE;
opapplymodify.ISRETURNDOMESTIC = enumValue.ISRETURNDOMESTIC;
opapplymodify.ISSHORTRENTCTN = enumValue.ISSHORTRENTCTN;
opapplymodify.GOODSTYPE = enumValue.GOODSTYPE;
enumValue.TRANSTYPE = enumValue.TRANSTYPE;
var ismodifyctn = false;
if (enumValue.CTNNUM != head.CTNNUM|| enumValue.CTNALL != head.CTNALL) {
ismodifyctn = true;
}
enumValue.SALE = head.SALE;
enumValue.OP = head.OP;
enumValue.CUSTOMERNAME = head.CUSTOMERNAME;
enumValue.GOODSNAME = head.GOODSNAME;
enumValue.GOODTYPE = head.GOODTYPE;
enumValue.PORTLOAD = head.PORTLOAD;
enumValue.PORTDISCHARGE = head.PORTDISCHARGE;
enumValue.ISOWNERBOOKING = head.ISOWNERBOOKING;
enumValue.CTNALL = head.CTNALL;
enumValue.CTNNUM = head.CTNNUM;
enumValue.PLANCTNDATE = head.PLANCTNDATE;
enumValue.FACTORYNAME = head.FACTORYNAME;
enumValue.FACTORYADDR = head.FACTORYADDR;
enumValue.SLOAD_FREE_USECTNE_DAY = head.SLOAD_FREE_USECTNE_DAY;
enumValue.SLOAD_OVER_USECTNE_RATE = head.SLOAD_OVER_USECTNE_RATE;
enumValue.SDEST_FREE_USECTNE_DAY = head.SDEST_FREE_USECTNE_DAY;
enumValue.SDEST_OVER_USECTNE_RATE = head.SDEST_OVER_USECTNE_RATE;
enumValue.AGENTNAME = head.AGENTNAME;
enumValue.REMARKS = head.REMARKS;
enumValue.ISPORTLOADDATE = head.ISPORTLOADDATE;
if (enumValue.PLANCTNDATE == "") enumValue.PLANCTNDATE = null;
enumValue.SERVICE = head.SERVICE;
enumValue.NEEDBEHEATED = head.NEEDBEHEATED;
enumValue.WEIGHT = head.WEIGHT;
enumValue.EMPTYCTNALLOCATION = head.EMPTYCTNALLOCATION;
enumValue.PREI_ETD = head.PREI_ETD;
enumValue.ISRETURNDOMESTIC = head.ISRETURNDOMESTIC;
enumValue.ISSHORTRENTCTN = head.ISSHORTRENTCTN;
enumValue.TRANSTYPE = head.TRANSTYPE;
enumValue.GOODSTYPE = head.GOODSTYPE;
enumValue.DbOperationType = DbOperationType.DbotUpd;
enumValue.ModelUIStatus = "E";
var modb = new ModelObjectDB();
result = modb.Save(enumValue);
if (result.Success == true)
{
modb.Save(opapplymodify);
string blUpSQL = "update op_ctnapply_modify set MDSTATUS='2' where MDSTATUS='1' and MODIFYTYPE='1' AND APPLYID='" + enumValue.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
var updatestr = "'" + head.PLANCTNDATE + "'";
if (head.PLANCTNDATE == null)
{
updatestr = "NULL";
}
if (string.IsNullOrEmpty(head.CUSTOMERNAME))
{
blUpSQL = "update op_ctnbscard set AGENTNAME='" + head.AGENTNAME + "',PORTLOAD='" + head.PORTLOAD + "',DESTPORT='" + head.PORTDISCHARGE + "',PRE_CNT_TIME=" + updatestr + " where APPLYNO='" + enumValue.BSNO + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
else
{
blUpSQL = "update op_ctnbscard set CUSTOMERNAME='" + head.CUSTOMERNAME + "',AGENTNAME='" + head.AGENTNAME + "',PORTLOAD='" + head.PORTLOAD + "',DESTPORT='" + head.PORTDISCHARGE + "',PRE_CNT_TIME=" + updatestr + " where APPLYNO='" + enumValue.BSNO + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
blUpSQL = "update op_ctnapply set AUDITSTATUS='审核通过',BSSTATUS='批准销售修改' where GID='" + enumValue.GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
if(ismodifyctn)
MsOpCtnApplyDAL.SaveApplyFee(enumValue, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
}
}
}
}
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD ="0";
Msgdata.READCOUNT ="0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = enumValue.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data =""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult ShenModifyCost(string data, string type)
{
var headData = JsonConvert.Deserialize<OpCtnApplyModify>(data);
var errorstr = "";
var isPost = true;
var GID = headData.GID;
headData.DbOperationType = DbOperationType.DbotIns;
headData.GID = Guid.NewGuid().ToString();
headData.APPLYID = GID;
headData.INPUTBY = Convert.ToString(Session["USERID"]);
headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.BSDATE = DateTime.Now.ToString("yyyy-MM-dd");
if (headData.PLANCTNDATE == "") headData.PLANCTNDATE = null;
headData.MODIFYTYPE = type;
headData.MDSTATUS = "1";
var msgstr = "";
if (isPost)
{
var modb = new ModelObjectDB();
var result = modb.Save(headData);
if (result.Success == true)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string blUpSQL = "update op_ctnapply set COSTAUDITSTATUS='申请修改',BSSTATUS='成本申请修改' where GID='" + GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
msgstr = "放箱申请-成本核算申请修改";
var strSql = new StringBuilder();
strSql.Append("SELECT USERID FROM ");
strSql.Append(" user_action WHERE ACTIONID in (select GID from action where [NAME]='modOpCtnApplyCostMdAudit') ");
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLYMODIFY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = Convert.ToString(reader["USERID"]);
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
reader.Close();
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpCtnApplyDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult ShenModifyCostAudit(string data, string type, string reasean = "")
{
var headData = JsonConvert.Deserialize<List<OpCtnApply>>(data);
var result = new DBResult();
result.Success = true;
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (headData != null)
{
foreach (var enumValue in headData)
{
if (type == "0")
{
if (enumValue.COSTAUDITSTATUS == "申请修改")
{
string blUpSQL = "update op_ctnapply_modify set MDSTATUS='3' where MDSTATUS='1' and MODIFYTYPE='5' AND APPLYID='" + enumValue.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "update op_ctnapply set COSTAUDITSTATUS='驳回申请修改',BSSTATUS='驳回成本申请修改',COSTAUDITRESULT='" + reasean + "' where GID='" + enumValue.GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
result.Message = "驳回成功!";
}
if (enumValue.CTNPRICESTATUS == "申请修改") {
string blUpSQL = "update op_ctnapply_modify set MDSTATUS='3' where MDSTATUS='1' and MODIFYTYPE='7' AND APPLYID='" + enumValue.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "update op_ctnapply set CTNPRICESTATUS='驳回申请修改',CTNPRICESTATUSRESULT='" + reasean + "' where GID='" + enumValue.GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
result.Message = "驳回成功!";
}
}
else if (type == "1")
{
if (enumValue.COSTAUDITSTATUS == "申请修改")
{
var head = MsOpCtnApplyDAL.GetModifyData("APPLYID='" + enumValue.GID + "' AND MDSTATUS='1' AND MODIFYTYPE='5' ", Convert.ToString(Session["SHOWNAME"]));
if (head.BSNO != "")
{
OpCtnApplyModify opapplymodify = new OpCtnApplyModify();
opapplymodify.DbOperationType = DbOperationType.DbotIns;
opapplymodify.GID = Guid.NewGuid().ToString();
opapplymodify.APPLYID = enumValue.GID;
opapplymodify.INPUTBY = Convert.ToString(Session["USERID"]);
opapplymodify.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
opapplymodify.BSDATE = DateTime.Now.ToString("yyyy-MM-dd");
if (opapplymodify.PLANCTNDATE == "") opapplymodify.PLANCTNDATE = null;
opapplymodify.MODIFYTYPE = "6";
opapplymodify.MDSTATUS = "2";
opapplymodify.AGENTINPUTBY = enumValue.AGENTINPUTBY;
opapplymodify.CYCLEDAYS = enumValue.CYCLEDAYS;
opapplymodify.CHANGERATE = enumValue.CHANGERATE;
opapplymodify.FULL_CTN_FREE_STORAGE_DAY = enumValue.FULL_CTN_FREE_STORAGE_DAY;
opapplymodify.FULL_CTN_OVER_STORAGE_RATE = enumValue.FULL_CTN_OVER_STORAGE_RATE;
opapplymodify.CLEAR_CTN_FREE_STORAGE_DAY = enumValue.CLEAR_CTN_FREE_STORAGE_DAY;
opapplymodify.CLEAR_CTN_OVER_STORAGE_RATE = enumValue.CLEAR_CTN_OVER_STORAGE_RATE;
opapplymodify.NO_CLEAR_CTN_FREE_STORAGE_DAY = enumValue.NO_CLEAR_CTN_FREE_STORAGE_DAY;
opapplymodify.NO_CLEAR_CTN_OVER_STORAGE_RATE = enumValue.NO_CLEAR_CTN_OVER_STORAGE_RATE;
opapplymodify.CTN_PRICE = enumValue.CTN_PRICE;
opapplymodify.CURRENCY = enumValue.CURRENCY;
opapplymodify.AGENTNAME = enumValue.AGENTNAME;
opapplymodify.LOAD_FREE_USECTNE_DAY = enumValue.LOAD_FREE_USECTNE_DAY;
opapplymodify.LOAD_OVER_USECTNE_RATE = enumValue.LOAD_OVER_USECTNE_RATE;
opapplymodify.DEST_FREE_USECTNE_DAY = enumValue.DEST_FREE_USECTNE_DAY;
opapplymodify.DEST_OVER_USECTNE_RATE = enumValue.DEST_OVER_USECTNE_RATE;
opapplymodify.DESTPORT_STATOIN = enumValue.DESTPORT_STATOIN;
opapplymodify.ISRETURNDOMESTIC = enumValue.ISRETURNDOMESTIC;
enumValue.AGENTINPUTBY = head.AGENTINPUTBY;
enumValue.CYCLEDAYS = head.CYCLEDAYS;
enumValue.CHANGERATE = head.CHANGERATE;
enumValue.FULL_CTN_FREE_STORAGE_DAY = head.FULL_CTN_FREE_STORAGE_DAY;
enumValue.FULL_CTN_OVER_STORAGE_RATE = head.FULL_CTN_OVER_STORAGE_RATE;
enumValue.CLEAR_CTN_FREE_STORAGE_DAY = head.CLEAR_CTN_FREE_STORAGE_DAY;
enumValue.CLEAR_CTN_OVER_STORAGE_RATE = head.CLEAR_CTN_OVER_STORAGE_RATE;
enumValue.NO_CLEAR_CTN_FREE_STORAGE_DAY = head.NO_CLEAR_CTN_FREE_STORAGE_DAY;
enumValue.NO_CLEAR_CTN_OVER_STORAGE_RATE = head.NO_CLEAR_CTN_OVER_STORAGE_RATE;
enumValue.CTN_PRICE = head.CTN_PRICE;
enumValue.CURRENCY = head.CURRENCY;
enumValue.AGENTNAME = head.AGENTNAME;
enumValue.LOAD_FREE_USECTNE_DAY = head.LOAD_FREE_USECTNE_DAY;
enumValue.LOAD_OVER_USECTNE_RATE = head.LOAD_OVER_USECTNE_RATE;
enumValue.DEST_FREE_USECTNE_DAY = head.DEST_FREE_USECTNE_DAY;
enumValue.DEST_OVER_USECTNE_RATE = head.DEST_OVER_USECTNE_RATE;
enumValue.DESTPORT_STATOIN = head.DESTPORT_STATOIN;
if (!string.IsNullOrEmpty(head.OWNERCTN)) enumValue.OWNERCTN = head.OWNERCTN;
enumValue.COSTAUDITSTATUS ="审核通过";
enumValue.BSSTATUS = "批准成本修改";
enumValue.ISRETURNDOMESTIC = head.ISRETURNDOMESTIC;
result = MsOpCtnApplyDAL.SaveCost(enumValue);
result.Message = "审核成功!";
if (result.Success == true)
{
var modb = new ModelObjectDB();
modb.Save(opapplymodify);
MsOpCtnApplyDAL.SaveApplyFee(enumValue, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
// MsOpCtnApplyDAL.SaveApplySeaiFee(enumValue, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
string blUpSQL = "update op_ctnapply_modify set MDSTATUS='2' where MDSTATUS='1' and MODIFYTYPE='5' AND APPLYID='" + enumValue.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
var updatestr = "'" + head.PLANCTNDATE + "'";
if (head.PLANCTNDATE == null)
{
updatestr = "NULL";
}
if (string.IsNullOrEmpty(head.CUSTOMERNAME))
{
blUpSQL = "update op_ctnbscard set AGENTNAME='" + head.AGENTNAME + "',PORTLOAD='" + head.PORTLOAD + "',DESTPORT='" + head.PORTDISCHARGE + "',PRE_CNT_TIME=" + updatestr + " where APPLYNO='" + enumValue.BSNO + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "update op_ctnbscard set AGENTNAME='" + head.AGENTNAME + "',DESTPORT='" + head.PORTDISCHARGE + "',PORTLOAD_FREE_DAYS=" + head.LOAD_FREE_USECTNE_DAY + ",PORTLOAD_OVER_DAYS_FEE=" + head.LOAD_OVER_USECTNE_RATE + ",DESTPORT_FREE_DAYS=" + head.DEST_FREE_USECTNE_DAY + ",DESTPORT_OVER_DAYS_FEE=" + head.DEST_OVER_USECTNE_RATE + ",PRE_CNT_TIME=" + updatestr + " where APPLYNO='" + enumValue.BSNO + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
else
{
blUpSQL = "update op_ctnbscard set CUSTOMERNAME='" + head.CUSTOMERNAME + "',AGENTNAME='" + head.AGENTNAME + "',PORTLOAD='" + head.PORTLOAD + "',DESTPORT='" + head.PORTDISCHARGE + "',PRE_CNT_TIME=" + updatestr + " where APPLYNO='" + enumValue.BSNO + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "update op_ctnbscard set CUSTOMERNAME='" + head.CUSTOMERNAME + "',AGENTNAME='" + head.AGENTNAME + "',DESTPORT='" + head.PORTDISCHARGE + "',PORTLOAD_FREE_DAYS=" + head.LOAD_FREE_USECTNE_DAY + ",PORTLOAD_OVER_DAYS_FEE=" + head.LOAD_OVER_USECTNE_RATE + ",DESTPORT_FREE_DAYS=" + head.DEST_FREE_USECTNE_DAY + ",DESTPORT_OVER_DAYS_FEE=" + head.DEST_OVER_USECTNE_RATE + ",PRE_CNT_TIME=" + updatestr + " where APPLYNO='" + enumValue.BSNO + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
}
}
}
if (enumValue.CTNPRICESTATUS == "申请修改")
{
var head = MsOpCtnApplyDAL.GetModifyData("APPLYID='" + enumValue.GID + "' AND MDSTATUS='1' AND MODIFYTYPE='7' ", Convert.ToString(Session["SHOWNAME"]));
if (head.BSNO != "")
{
OpCtnApplyModify opapplymodify = new OpCtnApplyModify();
opapplymodify.DbOperationType = DbOperationType.DbotIns;
opapplymodify.GID = Guid.NewGuid().ToString();
opapplymodify.APPLYID = enumValue.GID;
opapplymodify.INPUTBY = Convert.ToString(Session["USERID"]);
opapplymodify.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
opapplymodify.BSDATE = DateTime.Now.ToString("yyyy-MM-dd");
if (opapplymodify.PLANCTNDATE == "") opapplymodify.PLANCTNDATE = null;
opapplymodify.MODIFYTYPE = "8";
opapplymodify.MDSTATUS = "2";
opapplymodify.CTN_PRICE = enumValue.CTN_PRICE;
opapplymodify.CURRENCY = enumValue.CURRENCY;
if (!string.IsNullOrEmpty(head.OWNERCTN)) opapplymodify.OWNERCTN = head.OWNERCTN;
var modb = new ModelObjectDB();
modb.Save(opapplymodify);
enumValue.CTN_PRICE = head.CTN_PRICE;
enumValue.CURRENCY = head.CURRENCY;
enumValue.REMARKS = head.REMARKS;
if (!string.IsNullOrEmpty(head.OWNERCTN)) enumValue.OWNERCTN = head.OWNERCTN;
result = MsOpCtnApplyDAL.SaveCost(enumValue);
result.Message = "审核成功!";
if (result.Success == true)
{
MsOpCtnApplyDAL.SaveApplyFee(enumValue, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
string blUpSQL = "update op_ctnapply_modify set MDSTATUS='2' where MDSTATUS='1' and MODIFYTYPE='7' AND APPLYID='" + enumValue.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
string blUpSQL2 = "update op_ctnapply set CTNPRICESTATUS='审核通过' where GID='" + enumValue.GID + "'";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
}
}
}
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult ShenModifyDelCancel(string GID,string type)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (type == "0")
{
string blUpSQL = "update op_ctnapply set AUDITSTATUS='审核通过',BSSTATUS='销售撤销申请修改' where GID='" + GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "delete from op_ctnapply_modify where MDSTATUS='1' and MODIFYTYPE='1' AND APPLYID='" + GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
if (type == "3")
{
string blUpSQL = "update op_ctnapply set AUDITSTATUS='审核通过',BSSTATUS='销售撤销申请删除' where GID='" + GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "delete from op_ctnapply_modify where MDSTATUS='1' and MODIFYTYPE='4' AND APPLYID='" + GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
if (type == "7")
{
string blUpSQL = "update op_ctnapply set CTNPRICESTATUS='销售撤销申请修改' where GID='" + GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "delete from op_ctnapply_modify where MDSTATUS='1' and MODIFYTYPE='7' AND APPLYID='" + GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var jsonRespose = new JsonResponse
{
Success =true,
Message ="提交成功!",
Data = MsOpCtnApplyDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult ShenModifyCostCancel(string GID, string type)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (type == "6")
{
string blUpSQL = "update op_ctnapply set COSTAUDITSTATUS='审核通过',BSSTATUS='成本撤销申请修改' where GID='" + GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
blUpSQL = "delete from op_ctnapply_modify where MDSTATUS='1' and MODIFYTYPE='5' AND APPLYID='" + GID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var jsonRespose = new JsonResponse
{
Success = true,
Message = "提交成功!",
Data = MsOpCtnApplyDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SubmitGoodsAudit(string bill)
{
DBResult result = MsOpCtnApplyDAL.SubmitGoodsAudit(bill, Convert.ToString(Session["USERID"]),Convert.ToString(Session["COMPANYID"]));
if (result.Success) {
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var strBSNO = T_ALL_DA.GetStrSQL("BSNO", "select top 1 BSNO from op_ctnapply where GID='" + bill + "'");
var msgstr = "放箱申请-提交适货审核";
var strSql = new StringBuilder();
strSql.Append("SELECT USERID FROM ");
strSql.Append(" user_action WHERE ACTIONID in (select GID from action where [NAME]='modCtnApplyGoodsAudit') ");
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + strBSNO;
Msgdata.RECEIVER = Convert.ToString(reader["USERID"]);
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = strBSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
reader.Close();
}
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SubmitGoodsAuditBack(string bill)
{
DBResult result = MsOpCtnApplyDAL.SubmitGoodsAuditBack(bill);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SaveAuditGoods(string data, string data2)
{
var billData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", ""));
DBResult result = MsOpCtnApplyDAL.AuditGoods(billData, Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AuditGoodsPass(string data, string data2)
{
var billData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", ""));
billData.AUDITSTATUS = "审核通过";
billData.BSSTATUS = "适货审核通过";
DBResult result = MsOpCtnApplyDAL.AuditGoods(billData, Convert.ToString(Session["USERID"]));
if (result.Success)
{
var msgstr = "放箱申请-适货审核通过";
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + billData.BSNO;
Msgdata.RECEIVER = billData.INPUTBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = billData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AuditGoodsBack(string data, string data2)
{
var billData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", ""));
billData.AUDITSTATUS = "驳回提交";
billData.BSSTATUS = "适货审核驳回";
DBResult result = MsOpCtnApplyDAL.AuditGoods(billData, Convert.ToString(Session["USERID"]));
if (result.Success)
{
var msgstr = "放箱申请-适货审核驳回";
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + billData.BSNO;
Msgdata.RECEIVER = billData.INPUTBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = billData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SaveCost(string data, string data2, string data3, string body)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
var bodyList = JsonConvert.Deserialize<List<OpCtnApplyCostitems>>(body);
var errorstr = "";
var isPost = true;
if (bodyList!=null&&bodyList.Count!=0) {
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var custstr = "";
var feestr = "";
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
var BLCOUNT2 = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from info_client WHERE ISNULL(ISSTOP,0)=0 AND SHORTNAME='" + enumValue.CUSTOMERNAME + "'");
if (BLCOUNT2 == "0")
{
if (custstr == "") custstr = enumValue.CUSTOMERNAME;
else custstr = custstr + "," + enumValue.CUSTOMERNAME;
}
var BLCOUNT3 = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from code_fee WHERE [NAME]='" + enumValue.FEENAME + "'");
if (BLCOUNT3 == "0")
{
if (feestr == "") feestr = enumValue.FEENAME;
else feestr = feestr + "," + enumValue.FEENAME;
}
}
}
if (custstr != "")
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "客户名称:" + custstr + " ,系统中不存在,请检查!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
if (feestr != "")
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "费用名称:" + custstr + " ,系统中不存在,请检查!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
var GID = headData.GID;
if (isPost)
{
var modb = new ModelObjectDB();
var result = MsOpCtnApplyDAL.SaveCost(headData);
if (result.Success == true)
{
MsOpCtnApplyDAL.SaveCtnApplyCostItems(bodyList, GID, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpCtnApplyDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult SubmitCostAudit(string data, string data2, string data3, string body, bool Audit)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
var bodyList = JsonConvert.Deserialize<List<OpCtnApplyCostitems>>(body);
var errorstr = "";
var isPost = true;
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var GID = headData.GID;
if (Audit)
{
headData.COSTAUDITSTATUS = "提交审核";
headData.BSSTATUS = "提交成本审核";
string blUpSQL = "update op_ctnapply set COSTSUBMITBY='" + Convert.ToString(Session["USERID"]) + "',COSTSUBMITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where GID='" + headData.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
var msgstr = "放箱申请-提交成本审核";
var strSql = new StringBuilder();
strSql.Append("SELECT USERID FROM ");
strSql.Append(" user_action WHERE ACTIONID in (select GID from action where [NAME]='modCtnApplyCostAudit') ");
strSql.Append(" and USERID not in (SELECT USERID FROM user_action where ACTIONID in (select GID from action where [NAME]='APPLYMNGAUDIT')) ");
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = Convert.ToString(reader["USERID"]);
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
reader.Close();
}
}
else
{
headData.COSTAUDITSTATUS = "未提交";
string blUpSQL2 = "update op_ctnapply set COSTSUBMITBY='',COSTSUBMITTIME=null where GID='" + headData.GID + "'";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (isPost)
{
var modb = new ModelObjectDB();
var result = MsOpCtnApplyDAL.SaveCost(headData);
if (result.Success == true)
{
MsOpCtnApplyDAL.SaveCtnApplyCostItems(bodyList, GID, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpCtnApplyDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult SubmitOpAudit(string data, string data2, string data3, string body)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
var bodyList = JsonConvert.Deserialize<List<OpCtnApplyCostitems>>(body);
var errorstr = "";
var isPost = true;
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var GID = headData.GID;
headData.BSSTATUS = "操作录入完成";
if (isPost)
{
var modb = new ModelObjectDB();
var result = MsOpCtnApplyDAL.SaveCost(headData);
if (result.Success == true)
{
MsOpCtnApplyDAL.SaveCtnApplyCostItems(bodyList, GID, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpCtnApplyDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult SubmitCostAuditBack(string bill)
{
DBResult result = MsOpCtnApplyDAL.SubmitCostAuditBack(bill);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SaveAuditCost(string data, string data2, string data3)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
DBResult result = MsOpCtnApplyDAL.AuditCost(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]),false);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AccAudit(string data, string data2, string data3,string type)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
if (type == "1")
{
headData.ACCAUDITSTATUS = "审核通过";
headData.BSSTATUS = "操作审核通过";
headData.ACCAUDITBY = Convert.ToString(Session["USERID"]);
headData.ACCAUDITTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
else {
headData.ACCAUDITSTATUS = "未审核";
headData.BSSTATUS = "操作审核驳回";
headData.ACCAUDITBY ="";
headData.ACCAUDITTIME =null;
}
DBResult result = MsOpCtnApplyDAL.AccAudit(headData);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult BsAudit(string data, string data2, string data3, string type)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
if (type == "1")
{
headData.BSAUDITSTATUS = "审核通过";
headData.BSSTATUS = "业务审核通过";
headData.BSAUDITBY = Convert.ToString(Session["USERID"]);
headData.BSAUDITTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
else
{
headData.BSAUDITSTATUS = "未审核";
headData.BSSTATUS = "业务审核驳回";
headData.BSAUDITBY = "";
headData.BSAUDITTIME = null;
}
DBResult result = MsOpCtnApplyDAL.BsAudit(headData);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AuditCostPass(string data, string data2, string data3)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
headData.COSTAUDITSTATUS = "审核通过";
headData.BSSTATUS = "成本审核通过";
headData.MNGAUDITSTATUS = "提交审核";
DBResult result = MsOpCtnApplyDAL.AuditCost(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), false);
if (result.Success)
{
var msgstr = "放箱申请-成本(方案)审核通过";
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = headData.COSTSUBMITBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
var strSql = new StringBuilder();
strSql.Append("SELECT USERID FROM ");
strSql.Append(" user_action WHERE ACTIONID in (select GID from action where [NAME]='APPLYMNGAUDIT') ");
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = Convert.ToString(reader["USERID"]);
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb2 = new ModelObjectRepository();
Msgmodb2.Save(Msgdata);
}
reader.Close();
}
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AuditCostBack(string data, string data2, string data3)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
headData.COSTAUDITSTATUS = "驳回提交";
headData.BSSTATUS = "成本审核驳回";
headData.MNGAUDITSTATUS = "未提交";
DBResult result = MsOpCtnApplyDAL.AuditCost(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), true);
if (result.Success)
{
var msgstr = "放箱申请-方案审批驳回";
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = headData.COSTSUBMITBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = headData.INPUTBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AuditCostBackList(string data,string reason="")
{
var headList = JsonConvert.Deserialize<List<OpCtnApply>>(data);
DBResult result = new DBResult();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
foreach (var headData in headList) {
headData.COSTAUDITSTATUS = "驳回提交";
headData.BSSTATUS = "成本审核驳回";
headData.MNGAUDITSTATUS = "未提交";
headData.COSTAUDITRESULT = reason;
result = MsOpCtnApplyDAL.AuditCost(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), true, reason);
if (result.Success)
{
var msgstr = "放箱申请-方案审批驳回";
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = headData.COSTSUBMITBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = headData.INPUTBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
var cmdUpdateBL =@"INSERT INTO [op_task] (GID,[TASKNO] ,[PTASKNO],[TASKTYPE],[TASKSOURCE],[TASKSTATUS],[TASKTITLE] "
+ ",[CREATEUSER] ,[CREATETIME] ,[TASKBEGINDATE] ,[COMPLETETYPE] ,[COMPLETETIME] ,[KPI],[MBLNO],[FILENO],[MAILNO],[FILEPATH],[ISPUBLIC],[OP],[BSNO],ISCOMPLETE)"
10 months ago
+ " SELECT NEWID(),'"+headData.GID+"' as [任务编号],null as [上级任务号], '方案审批驳回' as [任务类型], '放箱申请' as [任务来源], '未开始' as [任务状态], '驳回原因:"+reason + headData.COSTAUDITRESULT + "' as [任务说明],"
11 months ago
+ "'" + Convert.ToString(Session["SHOWNAME"]) + "' as [发起人],GETDATE() as [录入日期],GETDATE() as[任务开始时间], '手动' as [完成方式],null as [完成时间] ,null as [KPI值] , '"+headData.BSNO+"' as [提单号], "
+ " null as [文件编号], '' as [邮件编号], '' as [电子档案路径], 0 as 是否公共,'" + headData.SALE + "','"+ headData.GID + "',0";
bool bl = T_ALL_DA.GetExecuteSqlCommand(cmdUpdateBL);
}
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult MNGAuditPass(string data, string data2, string data3)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
headData.MNGAUDITSTATUS = "审核通过";
headData.BSSTATUS = "总经理审核通过";
DBResult result = MsOpCtnApplyDAL.MNGAudit(headData, Convert.ToString(Session["USERID"]));
if (result.Success)
{
MsOpCtnApplyDAL.SaveApplyFee(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var msgstr = "放箱申请-总经理审核通过";
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = headData.COSTSUBMITBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = headData.INPUTBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult MNGAuditBack(string data, string data2, string data3)
{
var headData = JsonConvert.Deserialize<OpCtnApply>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
headData.BSSTATUS = "总经理审核驳回";
headData.MNGAUDITSTATUS = "驳回提交";
headData.ACCAUDITSTATUS = "驳回提交";
DBResult result = MsOpCtnApplyDAL.MNGAudit(headData, Convert.ToString(Session["USERID"]));
if (result.Success)
{
MsOpCtnApplyDAL.SaveApplyFee(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]),true);
var msgstr = "放箱申请-总经理审核驳回";
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + headData.BSNO;
Msgdata.RECEIVER = headData.COSTSUBMITBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = headData.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SubmitAddCtn(string bill)
{
DBResult result = MsOpCtnApplyDAL.SubmitAddCtn(bill,"配箱完成");
if (result.Success)
{
var head = MsOpCtnApplyDAL.GetData("GID='"+bill+"'", Convert.ToString(Session["SHOWNAME"]));
var headseae= MsOpSeaeDAL.GetData("APPLYNO='"+ head.BSNO+ "' and ISNULL(BSSTATUS,0)<>1 ", CookieConfig.GetCookie_UserId(Request));
if (!string.IsNullOrEmpty(headseae.CUSTNO)) {
var ctnList = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList("B.LINKGID='" + head.GID + "'");
var bodyList = MsOpSeaeDAL.GetBodyList("BSNO='"+headseae.BSNO+"'");
if (ctnList.Count != 0) {
foreach (var applyctn in ctnList)
{
if (bodyList.FindAll(x => x.CNTRNO == applyctn.CTNNO).Count == 0)
{
var ctn = new MsOpSeaeDetail();
ctn.BSNO = "*";
ctn.CNTRNO = applyctn.CTNNO;
ctn.CTNALL = "20TK";
ctn.CTNNUM = 1;
ctn.CTNSTATUS = "F";
ctn.KINDPKGS = "TANK";
ctn.PKGS = 1;
ctn.CTN_ID = Guid.NewGuid().ToString();
bodyList.Add(ctn);
}
}
MsOpSeaeDAL.SaveDetail(headseae.BSNO, bodyList, CookieConfig.GetCookie_UserId(Request), true);
}
}
var msgstr = "放箱申请-配箱完成";
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + head.BSNO;
Msgdata.RECEIVER = head.INPUTBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = head.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SubmitBackAddCtn(string bill)
{
DBResult result = MsOpCtnApplyDAL.SubmitAddCtn(bill, "总经理审核通过");
if (result.Success)
{
var head = MsOpCtnApplyDAL.GetData("GID='" + bill + "'", Convert.ToString(Session["SHOWNAME"]));
var headseae = MsOpSeaeDAL.GetData("APPLYNO='" + head.BSNO + "' and ISNULL(BSSTATUS,0)<>1", CookieConfig.GetCookie_UserId(Request));
if (!string.IsNullOrEmpty(headseae.CUSTNO))
{
var ctnList = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList("B.LINKGID='" + head.GID + "'");
var bodyList = MsOpSeaeDAL.GetBodyList("BSNO='" + headseae.BSNO + "'");
if (ctnList.Count != 0)
{
foreach (var applyctn in ctnList)
{
bodyList.ForEach(i =>
{
if (i.CNTRNO == applyctn.CTNNO)
{
MsOpSeaeDAL.DeleteDetail2(i, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
}
});
}
}
}
var msgstr = "放箱申请-撤销配箱完成";
var Msgdata = new SYSMessagemb();
Msgdata.GID = Guid.NewGuid().ToString();
Msgdata.NAME = "CTNAPPLY";
Msgdata.DESCRIPTION = msgstr;
Msgdata.MESSAGECONTENT = Convert.ToString(Session["SHOWNAME"]) + " " + msgstr + " 单号:" + head.BSNO;
Msgdata.RECEIVER = head.INPUTBY;
Msgdata.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Msgdata.ISREAD = "0";
Msgdata.READCOUNT = "0";
Msgdata.TYPE = "0";
Msgdata.TASKURL = "";
Msgdata.TASKID = head.BSNO;
Msgdata.NUMBER = "0";
Msgdata.RECVTYPE = "2";
Msgdata.DbOperationType = DbOperationType.DbotIns;
Msgdata.ModelUIStatus = "I";
var Msgmodb = new ModelObjectRepository();
Msgmodb.Save(Msgdata);
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult GetCtnApplySaleItemsList(string condition, string sort)
{
var dataList = MsOpCtnApplyDAL.GetCtnApplySaleItemsList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetCtnApplyCostItemsList(string condition, string sort)
{
var dataList = MsOpCtnApplyDAL.GetCtnApplyCostItemsList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetCtnApplyCostSum(string condition, string sort, string printstr = "false")
{
var strSql = new StringBuilder();
strSql.Append("select CURRENCY,sum(AMOUNT) AMOUNT from op_ctnapplycostitems");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" group by CURRENCY");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring + " '");
}
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
{
var jsonRespose = new JsonResponse
{
Success = true,
Message = "完成",
Data = strSql.ToString()
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var dbparams = new List<CustomDbParamter>();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(0, 100, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
}
public ContentResult GetCtnApplyCtnItemsList(string condition, string sort)
{
var dataList = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult SaveCtnApplyCostItems(string body, string PID)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnApplyCostitems>>(body);
DBResult result = MsOpCtnApplyDAL.SaveCtnApplyCostItems(bodyList, PID, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveCtnApplyCtnItems(string body, string PID)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnApplyCtnitems>>(body);
10 months ago
DBResult result = MsOpCtnApplyDAL.SaveCtnApplyCtnItems(bodyList, PID, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
11 months ago
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteOpCtnApplySaleItems(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnApplySaleitems>>(data);
DBResult result = MsOpCtnApplyDAL.DeleteOpCtnApplySaleItems(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteOpCtnApplyCostItems(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnApplyCostitems>>(data);
DBResult result = MsOpCtnApplyDAL.DeleteOpCtnApplyCostItems(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteOpCtnApplyCtnItems(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnApplyCtnitems>>(data);
DBResult result = MsOpCtnApplyDAL.DeleteOpCtnApplyCtnItems(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult CtnCreateAppySaleItemsFee(string PID)
{
var headData = MsOpCtnApplyDAL.GetData("GID='" + PID + "'", Convert.ToString(Session["USERID"]));
var ctnList = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList("B.LINKGID='" + PID + "'");
DBResult result = MsOpCtnApplyDAL.SaveAppySaleItemsFee(headData, ctnList,Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]),Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult CtnCreateBill(string data, string PID)
{
var headData = MsOpCtnApplyDAL.GetData("GID='" + PID + "'", Convert.ToString(Session["USERID"]));
var ctnList = MsOpCtnApplyDAL.GetCtnApplyCtnItemsList("B.LINKGID='" + PID + "' AND B.AUDITSTATUS='生成业务卡'");
var BodyData = JsonConvert.Deserialize<List<OpCtnApplyCtnitems>>(data);
10 months ago
MsOpCtnApplyDAL.SaveCtnApplyCtnItems(BodyData, PID, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
11 months ago
var SaleData = MsOpCtnApplyDAL.GetCtnApplySaleItemsList("LINKGID='" + PID + "'");
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var strYARDNAME = T_ALL_DA.GetStrSQL("CUSTOMERNAME", "select top 1 CUSTOMERNAME from op_ctnapplycostitems where FEENAME='清洗费' and LINKGID='" + PID.Trim() + "'");
var headList = new List<OpCtnBsCard>();
DBResult result = new DBResult();
var iscr = true;
if (headData != null && BodyData != null)
{
foreach (var enumValue in BodyData)
{
var head = new OpCtnBsCard();
var GID=Guid.NewGuid().ToString();
head.GID=GID;
head.COMPANYID = Convert.ToString(Session["COMPANYID"]);
head.OP =headData.OP;
head.INPUTBYREF = Convert.ToString(Session["SHOWNAME"]);
head.INPUTBY = Convert.ToString(Session["USERID"]);
head.CTNNO = enumValue.CTNNO;
head.CTNPROP = enumValue.CTNPROP;
head.SALE = headData.SALE;
var codectn = MsCodeCtnTkDAL.GetData("c.CTNNO='"+ enumValue.CTNNO + "'", Convert.ToString(Session["COMPANYID"]));
head.CTNGID = codectn.GID;
head.GOODSNAME = headData.GOODSNAME;
head.PREGOODSNAME = headData.PREGOODSNAME;
head.PORTLOAD = headData.PORTLOAD;
head.DESTPORT = headData.PORTDISCHARGE;
head.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.CUSTOMERNAME = headData.CUSTOMERNAME;
head.AGENTNAME = headData.AGENTNAME;
head.LOADFACTORY = headData.FACTORYNAME;
head.PRE_CNT_TIME = headData.PLANCTNDATE;
head.GOODSTYPE = headData.GOODSTYPE;
string lsSQL = "SELECT TOP 1 VDESTPORT_STATOIN FROM v_top_opctnbscard WHERE CTNNO='" + enumValue.CTNNO + "' ";
DataSet dsHSCODE = T_ALL_DA.GetAllSQL(lsSQL);
if (dsHSCODE != null)
{
if (dsHSCODE.Tables[0].Rows.Count > 0)
{
head.PORTLOAD_STATOIN = dsHSCODE.Tables[0].Rows[0]["VDESTPORT_STATOIN"].ToString();
}
}
head.DESTPORT_STATOIN = strYARDNAME;
//var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='罐箱业务卡'", Convert.ToString(Session["COMPANYID"]));
//if (billnoset.BILLTYPE != "")
// head.BSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.INPUTTIME.ToString().Trim(), headData.INPUTTIME.ToString().Trim());
head.APPLYNO = headData.BSNO;
head.BSNO = MsOpCtnApplyDAL.GetBillBsNo(headData.BSNO + "-" + headData.CTNNUM + "-");
head.DbOperationType = DbOperationType.DbotIns;
head.PORTLOAD_FREE_DAYS = headData.LOAD_FREE_USECTNE_DAY;
head.PORTLOAD_OVER_DAYS_FEE = headData.LOAD_OVER_USECTNE_RATE;
head.DESTPORT_FREE_DAYS = headData.DEST_FREE_USECTNE_DAY;
head.DESTPORT_OVER_DAYS_FEE = headData.DEST_OVER_USECTNE_RATE;
head.TRANSTYPE = headData.COSTTRANSTYPE;
head.ISRETURNDOMESTIC = headData.ISRETURNDOMESTIC;
head.ISSHORTRENTCTN = headData.ISSHORTRENTCTN;
if (head.ETD == "") head.ETD = null;
if (head.ETA == "") head.ETA = null;
if (head.PREETA == "") head.PREETA = null;
if (head.I_ETD == "") head.I_ETD = null;
if (head.I_ETA == "") head.I_ETA = null;
if (head.PREI_ETA == "") head.PREI_ETA = null;
if (head.PORTLOADDATE == "") head.PORTLOADDATE = null;
if (head.I_ARRIVALDATE == "") head.I_ARRIVALDATE = null;
if (head.I_DEST_CNT_TIME == "") head.I_DEST_CNT_TIME = null;
if (head.I_DEST_RTCNT_TIME == "") head.I_DEST_RTCNT_TIME = null;
if (head.I_PORTLOAD_CNT_TIME == "") head.I_PORTLOAD_CNT_TIME = null;
if (head.PORTLOAD_CNT_TIME == "") head.PORTLOAD_CNT_TIME = null;
if (head.ARRIVALDATE == "") head.ARRIVALDATE = null;
if (head.DEST_CNT_TIME == "") head.DEST_CNT_TIME = null;
if (head.DEST_RTCNT_TIME == "") head.DEST_RTCNT_TIME = null;
if (head.PRE_CNT_TIME == "") head.PRE_CNT_TIME = null;
if (head.D_ARRIVALDATE == "") head.D_ARRIVALDATE = null;
if (head.D_DEST_CNT_TIME == "") head.D_DEST_CNT_TIME = null;
if (head.D_DEST_RTCNT_TIME == "") head.D_DEST_RTCNT_TIME = null;
if (head.D_PORTLOAD_CNT_TIME == "") head.D_PORTLOAD_CNT_TIME = null;
if (head.D_ETD == "") head.D_ETD = null;
if (head.D_ETA == "") head.D_ETA = null;
if (head.CLEARNTIME == "") head.CLEARNTIME = null;
if (head.I_CLEARNTIME == "") head.I_CLEARNTIME = null;
if (head.D_CLEARNTIME == "") head.D_CLEARNTIME = null;
if (head.PREETD == "") head.PREETD = null;
head.DESTPORT_STATOIN = headData.DESTPORT_STATOIN;
head.SERVICE = headData.SERVICE;
head.NEEDBEHEATED = headData.NEEDBEHEATED;
head.AGENTINPUTBY = headData.AGENTINPUTBY;
head.EMPTYCTNALLOCATION = headData.EMPTYCTNALLOCATION;
//var codectntk = MsCodeCtnTkDAL.GetData("C.CTNNO='"+enumValue.CTNNO+"'", Convert.ToString(Session["COMPANYID"]));
if (!string.IsNullOrEmpty(codectn.CTNNO)) {
head.TOPVALVE = codectn.TOPVALVE;
head.EXSITSIPHONPIPE = codectn.EXSITSIPHONPIPE;
head.EXSITPRESSUREGAUGE = codectn.EXSITPRESSUREGAUGE;
head.EXSITTOPOVERFLOWBOX = codectn.EXSITTOPOVERFLOWBOX;
head.EXSITINTOOVERFLOWBOX = codectn.EXSITINTOOVERFLOWBOX;
head.EXSITBOTTONVALVEDUSTCOVER = codectn.EXSITBOTTONVALVEDUSTCOVER;
}
var modb = new ModelObjectDB();
result = modb.Save(head);
if (result.Success == true)
{
headList.Add(head);
MsOpCtnApplyDAL.SaveSaleToOpCtnRepair(SaleData, GID, Convert.ToString(Session["USERID"]));
MsOpCtnApplyDAL.UpOpCtnApplyCtnItems(enumValue.GID, Convert.ToString(Session["USERID"]));
10 months ago
var OP = T_ALL_DA.GetStrSQL("USERID", "select top 1 USERID from VW_user where SHOWNAME='" + headData.OP + "'");
11 months ago
10 months ago
MsOpCtnApplyDAL.SaveFeeDR(headData.CTN_PRICE,headData.CURRENCY, GID, Convert.ToString(Session["USERID"]), Convert.ToInt16(headData.CTNNUM),headData.OWNERCTN, OP);
11 months ago
// MsOpCtnApplyDAL.SaveFee(CostData, GID, Convert.ToString(Session["USERID"]), Convert.ToInt16(headData.CTNNUM),head);
}
else iscr = false;
}
}
if (result.Success == true)
{
if (headList != null && headList.Count != 0)
{
var CostData = MsOpCtnApplyDAL.GetCtnApplyCostItemsList("LINKGID='" + PID + "'");
MsOpCtnApplyDAL.SaveFeeList(CostData, headList,headData.CTNNUM, ctnList.Count,Convert.ToString(Session["USERID"]));
}
}
if (iscr)
{
var jsonRespose = new JsonResponse { Success =true, Message ="生成成功!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
var jsonRespose = new JsonResponse { Success = false, Message = "生成过程中出现错误!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult UpdateOpStatus(string data, string opstatus)
{
var headList = JsonConvert.Deserialize<List<OpCtnApply>>(data);
var errorstr = "";
var isPost = true;
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
foreach (var headData in headList) {
string blUpSQL = "update op_ctnapply set OPSTATUS='" + opstatus + "'"+ " where GID='" + headData.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var jsonRespose = new JsonResponse { Success = true, Message ="更新完成" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
}
}