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.
DS7/DSWeb/Areas/MvcShipping/Controllers/MsOpSeaePreController.cs

532 lines
21 KiB
C#

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsOpSeaePreDAL;
using DSWeb.MvcShipping.Models.MsOpSeaePre;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.EntityDA;
using DSWeb.Models;
//using DSWeb.Attributes;
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsCodeServiceFeeTemplate;
using System.IO;
using System.Data;
using System.Data.OleDb;
using DSWeb.MvcShipping.DAL.MsInfoClient;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using System.Web.Configuration;
using DSWeb.MvcShipping.DAL.MsCodeOpServiceDAL;
using System.Text;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpSeaePreController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ActionResult ModifyEdit()
{
return View();
}
public ActionResult ModifyHisEdit()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = MsOpSeaePreDAL.GetDataList(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 GetDataListStr(string sort, string condition)
{
var dataListStr = MsOpSeaePreDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
//public ContentResult GetDataListSum(int start, int limit, string sort, string condition)
//{
// var dataList = MsOpSeaePreDAL.GetDataListSum(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 GetData(string handle, string condition)
{
MsOpSeaePre head = null;
if (handle == "edit")
{
head = MsOpSeaePreDAL.GetData(condition);
}
if (head == null)
{
head = new MsOpSeaePre();
// head.OP = Convert.ToString(Session["SHOWNAME"]);
// head.CREATEUSER
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetCopyData(string condition)
{
MsOpSeaePre head = null;
var oldhead = MsOpSeaePreDAL.GetData(condition);
head = oldhead;
head.BSNO = "topseaepre" + Guid.NewGuid().ToString();
head.OP ="";
head.CUSTOMERNAME= "";
head.BSSTATUS = "";
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, 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) };
}
//
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var headData = JsonConvert.Deserialize<MsOpSeaePre>(data);
var isPost = true;
var errorstr = "";
var iscreatecustno = false;
////分公司代码
//if (headData.CORPID == "" || headData.CORPID == null)
//{
// headData.CORPID = Convert.ToString(Session["COMPANYID"]);
//}
//分公司代码
if (headData.BSNO == "" || headData.BSNO == null)
{
headData.BSNO = "topseaepre" + Guid.NewGuid().ToString().Replace("-","");
}
//
if (headData.ETD == "") headData.ETD = null;
if (headData.CLOSINGDATE == "") headData.CLOSINGDATE = null;
if (headData.CLOSEDOCDATE == "") headData.CLOSEDOCDATE = null;
string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq");
//
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
//
headData.BSSTATUS ="";//业务状态
headData.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人
headData.CREATETIME = DateTime.Parse(rq);//创建时间
headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次操作人
headData.MODIFIEDTIME = DateTime.Parse(rq);//最后一次操作时间
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
//
headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次操作人
headData.MODIFIEDTIME = DateTime.Parse(rq);//最后一次操作时间
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
//if (headData.CTNNUM == null) { headData.CTNNUM = 0; }
var ctndataList = MsCodeOpServiceDAL.GetDataCtnList("OPTYPE='1'");
var ctnstr = "";
if (headData.CNTR1 != 0) {
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == ""&&ctncode.OPField == "CNTR1")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR1.ToString();
else
ctnstr = ctnstr+" " + ctncode.SERVICENAME + "*" + headData.CNTR1.ToString();
}
}
}
if (headData.CNTR2 != 0)
{
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR2")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR2.ToString();
else
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR2.ToString();
}
}
}
if (headData.CNTR3 != 0)
{
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR3")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR3.ToString();
else
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR3.ToString();
}
}
}
if (headData.CNTR4 != 0)
{
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR4")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR4.ToString();
else
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR4.ToString();
}
}
}
if (headData.CNTR5 != 0)
{
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR5")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR5.ToString();
else
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR5.ToString();
}
}
}
if (headData.CNTR6 != 0)
{
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR6")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR6.ToString();
else
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR6.ToString();
}
}
}
if (headData.CNTR7!= 0)
{
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR7")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR7.ToString();
else
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR7.ToString();
}
}
}
if (headData.CNTR8 != 0)
{
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR8")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR8.ToString();
else
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR8.ToString();
}
}
}
if (headData.CNTR9 != 0)
{
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR9")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR9.ToString();
else
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR9.ToString();
}
}
}
if (headData.CNTR10 != 0)
{
foreach (var ctncode in ctndataList)
{
if (ctncode.OPTYPE == "" && ctncode.OPField == "CNTR10")
{
if (string.IsNullOrEmpty(ctnstr))
ctnstr = ctnstr + ctncode.SERVICENAME + "*" + headData.CNTR10.ToString();
else
ctnstr = ctnstr + " " + ctncode.SERVICENAME + "*" + headData.CNTR10.ToString();
}
}
}
headData.CNTRTOTAL = ctnstr;
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
var BSNO = headData.BSNO;
if (result.Success)
{
var SEAEPREAUTOLOCK = MsSysParamSetDAL.GetData("PARAMNAME='SEAEPREAUTOLOCK'").PARAMVALUE;
if (SEAEPREAUTOLOCK == "1")
{
if (!string.IsNullOrEmpty(headData.BSSTATUS))
{
var blUpBL = "update op_seae_pre set BSLOCK=1 where BSNO='" + headData.BSNO + "'";
bool blBL = T_ALL_DA.GetExecuteSqlCommand(blUpBL);
}
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpSeaePreDAL.GetData("BSNO='" + BSNO + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
var jsonRespose = new JsonResponse { Success = false, Message =errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#region 订舱修改历史
public ContentResult GetHisDataList(int start, int limit, string sort, string condition)
{
var dataList = MsOpSeaePreDAL.GetHisDataList(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 GetHisDataListStr(string sort, string condition)
{
var dataListStr = MsOpSeaePreDAL.GetHisDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetHisData(string handle, string condition)
{
MsOpSeaePre head = null;
if (handle == "edit")
{
head = MsOpSeaePreDAL.GetHisData(condition);
}
if (head == null)
{
head = new MsOpSeaePre();
// head.OP = Convert.ToString(Session["SHOWNAME"]);
// head.CREATEUSER
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
#endregion
public ContentResult Delete(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 head = JsonConvert.Deserialize<MsOpSeaePre>(data);
var BSNO = head.BSNO;
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//
public ContentResult GetDataListSum(string condition)
{
//var rangstr = MsOpSeaeDAL.GetRangDAStr("index", CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
//if (!string.IsNullOrEmpty(rangstr))
//{
// if (!string.IsNullOrEmpty(condition))
// {
// condition = condition + " and " + rangstr;
// }
// else
// {
// condition = rangstr;
// }
//}
// condition = condition.Replace("'", "''");
var strSql = new StringBuilder();
strSql.Append(" SELECT COUNT(1) NOBILL,SUM(CNTR1) CNTR1,SUM(CNTR2) CNTR2,SUM(CNTR3) CNTR3,SUM(CNTR4) CNTR4,SUM(CNTR5) CNTR5");
strSql.Append(" ,SUM(CNTR6) CNTR6,SUM(CNTR7) CNTR7,SUM(CNTR8) CNTR8,SUM(CNTR9) CNTR9,SUM(CNTR10) CNTR10 from op_seae_pre");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" where 1=1 AND " + condition);
}
else
{
// strSql.Append(" Where B.ISCANCEL<>''1'' AND B.MASTERNO=B.BSNO ");
}
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, 1, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
#region 批量修改窗体
public ContentResult modify(string data, string modifydata)
{
var bodyList = JsonConvert.Deserialize<List<MsOpSeaePre>>(data);
var amodifydata = JsonConvert.Deserialize<MsOpSeaePre>(modifydata);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpSeaePreDAL.Modify(bodyList, amodifydata, Convert.ToString(Session["COMPANYID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult UnBslock(string data)
{
var bodyList = JsonConvert.Deserialize<List<MsOpSeaePre>>(data);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpSeaePreDAL.UnBsLock(bodyList,Convert.ToString(Session["COMPANYID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
public ContentResult shenmodify(string olddata, string newdata)
{
var bodyList = JsonConvert.Deserialize<MsOpSeaePre>(olddata);
var amodifydata = JsonConvert.Deserialize<MsOpSeaePre>(newdata);
var result = new DBResult();
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq");
//
if (bodyList != null)
{
result = MsOpSeaePreDAL.ShenModify(bodyList, amodifydata, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]), rq);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpSeaePreDAL.GetData("BSNO='" + bodyList.BSNO + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
}