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/MsOp_SuperVision_TruckContr...

262 lines
11 KiB
C#

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsOpOtherDAL;
using DSWeb.MvcShipping.Models.MsOpOther;
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.SoftMng.DAL.SoftSysTable;
using DSWeb.Areas.SysMng.DAL.SysUser;
using DSWeb.MvcShipping.DAL.MsCodeOpTemplate;
using DSWeb.MvcShipping.DAL.ChMonthCloseDAL;
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
using DSWeb.Areas.Dispatch.DB;
using javax.xml.crypto;
using DSWeb.Common.DB;
using System.Data.Entity.Migrations;
using DSWeb.Areas.CommMng.DAL;
using CommonDataContext = DSWeb.Common.DB.CommonDataContext;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOp_SuperVision_TruckController : Controller
{
//
// GET: /CommMng/Print/
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition, string CODENAME = "")
{
var count = 0;
//var userid = Convert.ToString(Session["USERID"]);
//var uid = Session["USERID"].ToString();
//var corpid = Session["COMPANYID"].ToString();
var dataList = MsOp_SuperVision_TruckDAL.GetDataList(start, limit, sort, condition, ref count);
//var dataList = MsChDuiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request), sort);
//int count = MsChDuiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string GID)
{
if (GID == "*" || string.IsNullOrWhiteSpace(GID))
{
var nulllist = new List<OP_SuperVision_Truck_md>();
var newrec = new OP_SuperVision_Truck_md();
//nulllist.Add(newrec);
var jsonnull = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 1, data = newrec });
return new ContentResult() { Content = jsonnull };
}
var count = 0;
//var userid = Convert.ToString(Session["USERID"]);
//var uid = Session["USERID"].ToString();
//var corpid = Session["COMPANYID"].ToString();
var dataList = MsOp_SuperVision_TruckDAL.GetDataList(0, 1, "", "{GID:\"" + GID + "\"}", ref count);
//var dataList = MsChDuiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request), sort);
//int count = MsChDuiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request));
if (dataList.Count == 0 || GID == "*")
{
var newrec = new OP_SuperVision_Truck_md();
dataList.Add(newrec);
}
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList[0] });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string data2, string body)
{
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
data = data.Replace("❥", "<");
var headData = JsonConvert.Deserialize<OP_SuperVision_Truck_md>(data);//(data.Replace("}", ",") + data2.Replace("{", "")
var isPost = true;
var errorstr = "";
#region 判断字段长度
if (isPost)
{
var seaefield = MsSoftSysTableDAL.GetDefTableDetailList("info_client");
foreach (var enumValue in seaefield)
{
//if (enumValue.FIELDNAME == "CODENAME" && headData.CODENAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户代码超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "SHORTNAME" && headData.SHORTNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户简称超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "DESCRIPTION" && headData.DESCRIPTION.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户全称超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "ENFULLNAME" && headData.EnFullName.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "英文全称超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "ADDR" && headData.ADDR.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "地址超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "EMAIL" && headData.EMAIL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "邮件地址超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "WEB" && headData.WEB.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "网址超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "TEL" && headData.TEL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "TEL超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "ADDR" && headData.NAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "英文地址超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "CHIEF" && headData.CHIEF.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "负责人超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "PROVINCE" && headData.PROVINCE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "省超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "CITY" && headData.CITY.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "城市超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "BILLRISES1" && headData.BillRises1.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "发票抬头超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "RMBBILLRISES" && headData.RMBBillRises.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "人民币支票抬头超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "USDBILLRISES" && headData.USDBillRises.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "美元支票抬头超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "REMARK" && headData.REMARK.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "备注超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "QQ" && headData.QQ.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "QQ超长,字段长度限制" + enumValue.FIELDLEN; }
//if (enumValue.FIELDNAME == "TAXNO" && headData.TAXNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "税号超长,字段长度限制" + enumValue.FIELDLEN; }
}
}
#endregion
var cdc = new CommonDataContext();
if (isPost)
{
if (opstatus == "add")
{
var uid = Session["USERID"].ToString();
//var compid = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == uid).COMPANYID;
headData.GID = Guid.NewGuid().ToString();
//headData.COMPANYID = compid;
cdc.OP_SuperVision_Truck.Add(headData);
}
else if (opstatus == "edit")
{
//var oldheaddata = cdc.OP_SuperVision_Truck.First(x => x.GID == headData.GID);
//oldheaddata.SaveCopy(headData);
cdc.OP_SuperVision_Truck.AddOrUpdate(headData);
}
cdc.SaveChanges();
var jsonRespose = new JsonResponse
{
Success = true,
Message = "",
Data = headData
};
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 DelDetail(string GID)
//{
// var bd = new BookingDB();
// var GIDList = GID.Split(',').ToList();
// var olddetail = bd.Contacts.Where(x => GIDList.Contains(x.GID)).ToList();
// var jsonRespose = new JsonResponse
// {
// Success = true,
// Message = "",
// Data = ""
// };
// if (olddetail != null)
// {
// bd.Contacts.RemoveRange(olddetail);
// bd.SaveChanges();
// }
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//}
//public ContentResult DelHead(string GID)
//{
// var cdc = new CommonDataContext();
// var oldhead = cdc.Sys_Role_Task_Query.Where(x => x.GID == new Guid(GID)).ToList();
// var jsonRespose = new JsonResponse
// {
// Success = true,
// Message = "删除成功!",
// Data = ""
// };
// if (oldhead != null)
// {
// cdc.Sys_Role_Task_Query.RemoveRange(oldhead);
// cdc.SaveChanges();
// }
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//}
}
}