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.

969 lines
45 KiB
C#

10 months ago
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.CommMng.DAL;
using DSWeb.Areas.MvcShipping.DAL;
using DSWeb.MvcShipping.Models.MsOpLetter;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpOtherController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult HistryFeeIndex()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ActionResult EditView()
{
return View();
}
public ActionResult FeeEdit()
{
return View();
}
public ActionResult OtherFeeView()
{
return View();
}
public ActionResult FeeAmendEdit()
{
return View();
}
public ActionResult ReceiptEdit()
{
return View();
}
public ActionResult PiLiangFeeEdit()
{
return View();
}
public ActionResult PiLiangServiceFeeEdit()
{
return View();
9 months ago
}
public ActionResult SaleEdit()
{
return View();
}
public ActionResult SaleIndex()
{
return View();
}
10 months ago
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = MsOpOtherDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
int count = MsOpOtherDAL.getTotalCount(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
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)
{
var dataListStr = MsOpOtherDAL.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 };
}
9 months ago
public ContentResult GetSaleDataList(int start, int limit, string sort, string condition)
{
var dataList = MsOpOtherDAL.GetSaleDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
int count = MsOpOtherDAL.getSaleTotalCount(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetSaleDataListStr(string sort, string condition)
{
var dataListStr = MsOpOtherDAL.GetSaleDataListStr(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 };
}
10 months ago
public ContentResult GetDataListSum(int start, int limit, string sort, string condition)
{
var dataList = MsOpOtherDAL.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 };
}
9 months ago
public ContentResult GetSaleDataListSum(int start, int limit, string sort, string condition)
{
var dataList = MsOpOtherDAL.GetSaleDataListSum(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 };
}
10 months ago
public ContentResult GetData(string handle, string condition)
{
MsOpOtherEntity head = null;
if (handle == "edit")
{
head = MsOpOtherDAL.GetData(condition);
}
if (head == null)
{
head = new MsOpOtherEntity();
head.OP = Convert.ToString(Session["SHOWNAME"]);
var SALEORDERDEPTBYOP = MsSysParamSetDAL.GetData("PARAMNAME='SALEORDERDEPTBYOP'");
if (SALEORDERDEPTBYOP.PARAMVALUE == "1")
{
head.SALEDEPT = Convert.ToString(Session["DEPTNAME"]);
}
head.ETD = DateTime.Now.ToString("yyyy-MM-dd");
//head.BSTYPE = "2";
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetCopyData(string handle, string condition, string copyfee = "false")
{
MsOpOtherEntity head = null;
var oldhead = MsOpOtherDAL.GetData(condition);
var copyfieldlist = MsCodeOpTemplateDAL.GetCodeOpTemplateDetail(" LINKGID in (select top 1 GID from CODE_OP_TEMPLATE where BSTYPE='报关业务' and (op='" + CookieConfig.GetCookie_UserId(Request) + "' or ISPUBLIC='是') order by ISPUBLIC)");
if (copyfieldlist.Count == 0)
{
head = oldhead;
head.BSNO = "topother" + Guid.NewGuid().ToString();
head.CUSTNO = "";
head.OP = Convert.ToString(Session["SHOWNAME"]);
var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
{
head.ACCDATE = period.PERIOD;
}
else
{
head.ACCDATE = DateTime.Now.ToString("yyyy-MM");
}
head.BSSTATUS = false;
head.FEESTATUS = false;
head.BSSTATUSREF = "未锁定";
head.FEESTATUSREF = "未锁定";
var SALEORDERDEPTBYOP = MsSysParamSetDAL.GetData("PARAMNAME='SALEORDERDEPTBYOP'");
if (SALEORDERDEPTBYOP.PARAMVALUE == "1")
{
head.SALEDEPT = Convert.ToString(Session["DEPTNAME"]);
}
if (copyfee == "true")
{
var feelist = MsChFeeDAL.GetAllDataList(condition);
if (feelist != null)
{
for (int _i = 0; _i < feelist.Count; _i++)
{
feelist[_i].BsNo = "*";
}
MsChFeeDAL.SaveFee(feelist, head.BSNO, CookieConfig.GetCookie_UserId(Request));
}
}
}
else
{
if (head == null)
{
head = new MsOpOtherEntity();
head.BSNO = "topother" + Guid.NewGuid().ToString();
head.OP = Convert.ToString(Session["SHOWNAME"]);
var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
{
head.ACCDATE = period.PERIOD;
}
else
{
head.ACCDATE = DateTime.Now.ToString("yyyy-MM");
}
var SALEORDERDEPTBYOP = MsSysParamSetDAL.GetData("PARAMNAME='SALEORDERDEPTBYOP'");
if (SALEORDERDEPTBYOP.PARAMVALUE == "1")
{
head.SALEDEPT = Convert.ToString(Session["DEPTNAME"]);
}
var propArr = head.GetType().GetProperties();
foreach (var enumValue in copyfieldlist)
{
var prop = propArr.FirstOrDefault(p => p.Name.ToLower() == enumValue.FIELDNAME.ToLower());
if (prop != null)
{
prop.SetValue(head, oldhead.GetPropertyValue(enumValue.FIELDNAME));
}
}
if (copyfee == "true")
{
var feelist = MsChFeeDAL.GetAllDataList(condition);
if (feelist != null)
{
for (int _i = 0; _i < feelist.Count; _i++)
{
feelist[_i].BsNo = "*";
}
MsChFeeDAL.SaveFee(feelist, head.BSNO, CookieConfig.GetCookie_UserId(Request));
}
}
}
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string data2, string ctnbody)
{
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 dataall = data.Replace("}", ",") + data2.Replace("{", "");
var headData = JsonConvert.Deserialize<MsOpOtherEntity>(dataall);
var bodyctnData = JsonConvert.Deserialize<List<MsOpLetterTruckCtn>>(ctnbody);
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 = "topother" + Guid.NewGuid().ToString().Replace("-","");
}
if (bodyctnData != null && bodyctnData.Count != 0) {
foreach (var bodyctn in bodyctnData) {
headData.CTNALL = bodyctn.CTNALL;
headData.CTNNUM = (int)bodyctn.CTNNUM;
}
}
#region 委托编号规则
var isuse = false;
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='综合业务'", Convert.ToString(Session["COMPANYID"]));
if (billnoset.BILLTYPE != "")
isuse = true;
else
isuse = MsBaseInfoDAL.GetRuleUse("委托编号", "6");
if (headData.CUSTNO == "")
{
if (isuse)
{
if (billnoset.BILLTYPE != "")
{
var CUSTOMHEAD = "";
if (billnoset.CUSTOMHEAD != "")
{
var HBLCUSTOMHEAD = billnoset.CUSTOMHEAD;
if ((HBLCUSTOMHEAD.IndexOf("[SALE]") >= 0) && !string.IsNullOrEmpty(headData.SALE))
{
var user = SysUserDAL.GetData("u.SHOWNAME='" + headData.SALE + "'");
if (!string.IsNullOrEmpty(user.NOCODE))
HBLCUSTOMHEAD = HBLCUSTOMHEAD.Replace("[SALE]", user.NOCODE);
}
if ((HBLCUSTOMHEAD.IndexOf("[OP]") >= 0) && !string.IsNullOrEmpty(headData.OP))
{
var user = SysUserDAL.GetData("u.SHOWNAME='" + headData.OP + "'");
if (!string.IsNullOrEmpty(user.NOCODE))
HBLCUSTOMHEAD = HBLCUSTOMHEAD.Replace("[OP]", user.NOCODE);
}
CUSTOMHEAD = HBLCUSTOMHEAD;
var CUST = MsInfoClientDAL.GetData("SHORTNAME='" + headData.CUSTOMERNAME + "'");
CUSTOMHEAD = CUSTOMHEAD.Replace("[CUSTCODE]", CUST.CODENAME);
}
headData.CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.ETD.ToString().Trim(), headData.ACCDATE.ToString().Trim(), "", headData.OP, headData.SALECORPID, CUSTOMHEAD);
iscreatecustno = true;
}
else
headData.CUSTNO = MsOpOtherDAL.getCodeRule("委托编号", 6, "CUSTNO", headData.BSDATE.ToString().Trim(), headData.ACCDATE.ToString().Trim(), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
}
}
else {
//if (!isuse) {
var ct = MsOpOtherDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND CUSTNO='" + headData.CUSTNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
if (ct != 0)
{
isPost = false;
errorstr = "委托编号";
}
//}
}
#endregion
#region 主提单号规则
if (headData.MBLNO != "" && headData.MBLNO != null)
{
var OpOtherMblrepeat = MsSysParamSetDAL.GetData("PARAMNAME='OpOtherMblrepeat'");
if (OpOtherMblrepeat.PARAMVALUE == "1")
{
var ct = MsOpOtherDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND MBLNO='" + headData.MBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
if (ct != 0)
{
isPost = false;
errorstr = "主提单号重复,不允许保存!";
}
}
}
////先获取分公司默认主提单号是否允许重复
//AttributeCompanyEntity attributeCompanyEntity = (AttributeCompanyEntity)attributeManager.FindAttributeByName("refSubCompanyOtherMBLNO", AttributeType.COMPANYATTRIBUTE, Convert.ToString(Session["COMPANYID"])) as AttributeCompanyEntity;
//if (attributeCompanyEntity != null)
//{
// if (attributeCompanyEntity.GID != null)
// {
// if (attributeCompanyEntity.AttributeValue.ToString().Trim() == "false")
// {
// var ct = MsOpOtherDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND MBLNO='" + headData.MBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
// if (ct != 0)
// {
// isPost = false;
// errorstr = "主提单号重复,不允许保存!";
// }
// }
// }
// else
// {
// var ct = MsOpOtherDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND MBLNO='" + headData.MBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
// if (ct != 0)
// {
// isPost = false;
// errorstr = "主提单号编码规则未设置,请联系管理员!";
// }
// }
// }
// else
// {
// isPost = false;
// errorstr = "主提单号编码规则未设置,请联系管理员!";
// }
//}
//else
//{
// isPost = false;
// errorstr = "主提单号不允许为空!";
//}
#endregion
#region 分提单号规则
//if (headData.HBLNO != "" && headData.HBLNO != null)
//{
// //先获取分公司默认分提单号是否允许重复
// AttributeCompanyEntity attributeCompanyEntity_2 = (AttributeCompanyEntity)attributeManager.FindAttributeByName("refSubCompanyOtherHBLNO", AttributeType.COMPANYATTRIBUTE, Convert.ToString(Session["COMPANYID"])) as AttributeCompanyEntity;
// if (attributeCompanyEntity_2 != null)
// {
// if (attributeCompanyEntity_2.GID != null)
// {
// if (attributeCompanyEntity_2.AttributeValue.ToString().Trim() == "false")
// {
// var ct = MsOpOtherDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND HBLNO='" + headData.HBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
// if (ct != 0)
// {
// isPost = false;
// errorstr = "分提单号重复,不允许保存!";
// }
// }
// }
// else
// {
// var ct = MsOpOtherDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND HBLNO='" + headData.HBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
// if (ct != 0)
// {
// isPost = false;
// errorstr = "分提单号编码规则未设置,请联系管理员!";
// }
// }
// }
// else
// {
// var ct = MsOpOtherDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND HBLNO='" + headData.HBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
// if (ct != 0)
// {
// isPost = false;
// errorstr = "分提单号编码规则未设置,请联系管理员!";
// }
// }
//}
//else
//{
// isuse = MsBaseInfoDAL.GetRuleUse("分提单号", "6");
// if (isuse)
// {
// headData.HBLNO = MsOpOtherDAL.getCodeRule("分提单号", 6, "HBLNO", headData.BSDATE.ToString().Trim(), headData.ACCDATE.ToString().Trim(), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
// }
//}
#endregion
//
if (headData.ETD == "") headData.ETD = null;
if (headData.CLOSINGDATE == "") headData.CLOSINGDATE = null;
if (headData.CLOSEDOCDATE == "") headData.CLOSEDOCDATE = null;
if (headData.INVDATE == "") headData.INVDATE = null;
if (headData.ETD != "" && headData.CUSTOMERNAME != "")// headData.STLDATE == "" &&
{
//根据客户、开船日计算账期
var _dmb = MsInfoClientDAL.GetSTLDATE(headData.CUSTOMERNAME, "海运出口", headData.ETD, headData.SALE);
headData.STLNAME = _dmb.STLNAME;
headData.STLDATE = _dmb.STLDATE;
if (_dmb.STLNAME == "")
{
headData.STLNAME = "现结买单";
headData.STLDATE = headData.ETD;
}
if (_dmb.BSSOURCE != "") headData.BSSOURCE = _dmb.BSSOURCE;
}
string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq");
//
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
//
headData.OPLB="op_other";//业务类型
headData.OPLBNAME = "散杂运输";//业务类型名称
headData.BSSTATUS = false;//业务状态
headData.FEESTATUS = false;//费用状态
headData.ISVOU = false;//是否生成凭证
headData.VOUNO="";//凭证号
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; }
#region 判断字段长度
if (isPost)
{
var seaefield = MsSoftSysTableDAL.GetDefTableDetailList("OP_OTHER");
foreach (var enumValue in seaefield)
{
if (enumValue.FIELDNAME == "MBLNO" && headData.MBLNO != null && headData.MBLNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "主提单号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "HBLNO" && headData.HBLNO != null && headData.HBLNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "分提单号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "CUSTNO" && headData.CUSTNO != null && headData.CUSTNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "委托编号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "ORDERNO" && headData.ORDERNO != null && headData.ORDERNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "订舱编号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "VESSEL" && headData.VESSEL != null && headData.VESSEL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "船名超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "VOYNO" && headData.VOYNO != null && headData.VOYNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "航次超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PORTLOAD" && headData.PORTLOAD != null && headData.PORTLOAD.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "装货港超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PORTDISCHARGE" && headData.PORTDISCHARGE != null && headData.PORTDISCHARGE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "卸货港超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "GOODSNAME" && headData.GOODSNAME != null && headData.GOODSNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "品名超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "KINDPKGS" && headData.KINDPKGS != null && headData.KINDPKGS.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "包装超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "CONTRACTNO" && headData.CONTRACTNO != null && headData.CONTRACTNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "运费协议号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "REMARK" && headData.REMARK != null && headData.REMARK.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "备注超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "STLNAME" && headData.STLNAME != null && headData.STLNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "结算方式超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "ENTERP" && headData.ENTERP != null && headData.ENTERP.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "经营单位超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "BSSOURCE" && headData.BSSOURCE!=null && headData.BSSOURCE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "业务来源超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "BSSOURCEDETAIL" && headData.BSSOURCEDETAIL != null && headData.BSSOURCEDETAIL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "来源明细超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "BOOKNO" && headData.BOOKNO != null && headData.BOOKNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "手册号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "WAREHOUSE" && headData.WAREHOUSE != null && headData.WAREHOUSE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "仓库超长,字段长度限制" + enumValue.FIELDLEN; }
}
}
#endregion
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
var BSNO = headData.BSNO;
if (result.Success == true)
{
MsOpLetterDAL.SaveTruckCtn(headData.BSNO, bodyctnData); // MsWlPcDAL.SaveDetail(BSNO, fixBodyList, CookieConfig.GetCookie_UserId(Request));
MsOpOtherDAL.UpDateCtn(headData.BSNO, bodyctnData);
// result = MsOpOtherDAL.SaveDetail(headData, bodyList, Convert.ToString(Session["USERID"]));
//看装货港卸货港目前是否存在 如不存在则写入
BasicDataRefDAL.SaveOtherPort(headData.PORTLOAD);
BasicDataRefDAL.SaveOtherPort(headData.PORTDISCHARGE);
}
else
{
MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpOtherDAL.GetData("BSNO='" + BSNO + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
if (iscreatecustno == true)
MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
var jsonRespose = new JsonResponse { Success = false, Message =errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult PiliangServiceFee(string bill, string fee)
{
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 billList = JsonConvert.Deserialize<List<MsOpOtherEntity>>(bill);
var feeList = JsonConvert.Deserialize<List<MsCodeServiceFeeTemplateDetail>>(fee);
DBResult result = MsOpOtherDAL.PiliangServiceFee(billList, feeList, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetENTERPLIST()
{
var dataList = MsOpOtherDAL.GetENTERPLIST();
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult modify(string data, string modifydata)
{
var bodyList = JsonConvert.Deserialize<List<MsOpOtherEntity>>(data);
var amodifydata = JsonConvert.Deserialize<MsOpOtherEntity>(modifydata);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpOtherDAL.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 modifyInvDate(string data, string modifydata)
{
var bodyList = JsonConvert.Deserialize<List<MsOpOtherEntity>>(data);
var amodifydata = JsonConvert.Deserialize<MsOpOtherEntity>(modifydata);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpOtherDAL.modifyInvDate(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 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<MsOpOtherEntity>(data);
var isfee = MsOpOtherDAL.GetFeeCount(head.BSNO);
if (isfee)
{
var jsonRespose = new JsonResponse { Success = false, Message ="此票业务存在费用,请先删除费用才能删除此票业务!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
var BSNO = head.BSNO;
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head);
if (result.Success == true) { MsSysBillNoSetDAL.DeleteBsNo(head.CUSTNO); }
if (result.Success == true) {
//MsOpOtherDAL.DeleteDetail(head);
DBResult result2 = MsOpOtherDAL.setLog(head, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
//
#region EXCEL导入
[HttpPost]
public ContentResult ImportBl()
{
var jsonRespose = new JsonResponse { Success = false, Message = "" };
if (Request.Files.Count != 1)
{
jsonRespose.Success = false;
jsonRespose.Message = "请选择上传的文件";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var file = Request.Files["LoadExcel"];
if (file == null)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
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) };
}
string ext = Path.GetExtension(file.FileName).ToLower();
if (ext == ".asp" || ext == ".aspx")
{
jsonRespose.Success = false;
jsonRespose.Message = "不允许上传ASP或ASPX文件";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var path = Server.MapPath("../../UploadFiles/OpOther");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
var usercode = CookieConfig.GetCookie_UserCode(Request);
string filename = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
file.SaveAs(filename);
if (!System.IO.File.Exists(filename))
{
jsonRespose.Success = false;
jsonRespose.Message = "上传的Excel不包含数据01";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var ExcelExt = "";
try
{
ExcelExt = WebConfigurationManager.AppSettings["ExcelExt"].ToString();
}
catch
{
}
if (ExcelExt == "" || ExcelExt == null) ExcelExt = "Excel 8.0;HDR=Yes;IMEX=1";
List<string> sheets = ExcelSheetName(filename, ExcelExt);
if (sheets.Count == 0)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传的Excel不包含数据02";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
try
{
var sheetname = sheets[0];
string excelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename +
";Extended Properties="+ ExcelExt;
if (filename.ToLower().IndexOf(".xlsx") > 0)
{
excelConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename +
";Extended Properties=\"Excel 12.0 Xml;HDR=Yes\"";
}
OleDbDataAdapter oada = new OleDbDataAdapter("select * from [" + sheetname + "]", excelConn);
DataSet ds = new DataSet();
oada.Fill(ds);
if (ds.Tables.Count == 0)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传的Excel不包含数据03";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var table = ds.Tables[0];
if (table.Rows.Count == 0 || table.Rows.Count == 1)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传的Excel不包含数据04";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var message = string.Empty;
bool isSucess = false;
isSucess = MsOpOtherDAL.ImportBldata(Request, table, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_CompanyId(Request), out message, CookieConfig.GetCookie_UserName(Request));
if (!isSucess)
{
jsonRespose.Success = false;
jsonRespose.Message = message;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var json = JsonConvert.Serialize(new { success = true, Message = "上传成功" });
return new ContentResult() { Content = json };
}
catch (Exception)
{
jsonRespose.Success = false;
jsonRespose.Message = "读取Excel文件出错请确认文件正确性";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
[HttpPost]
public ContentResult ImportBlZh()
{
var jsonRespose = new JsonResponse { Success = false, Message = "" };
if (Request.Files.Count != 1)
{
jsonRespose.Success = false;
jsonRespose.Message = "请选择上传的文件";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var file = Request.Files["LoadExcel"];
if (file == null)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
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) };
}
string ext = Path.GetExtension(file.FileName).ToLower();
if (ext == ".asp" || ext == ".aspx")
{
jsonRespose.Success = false;
jsonRespose.Message = "不允许上传ASP或ASPX文件";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var path = Server.MapPath("../../UploadFiles/OpOther");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
var usercode = CookieConfig.GetCookie_UserCode(Request);
string filename = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
file.SaveAs(filename);
if (!System.IO.File.Exists(filename))
{
jsonRespose.Success = false;
jsonRespose.Message = "上传的Excel不包含数据01";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
try
{
if (ext != ".xls" && ext != ".xlsx")
{
jsonRespose.Success = false;
jsonRespose.Message = "上传的文件不是Excel文件";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var strMsg = "";
DataTable table = ExcelHelper.ExcelToDatatable(file.InputStream, ext, out strMsg);
if (!string.IsNullOrEmpty(strMsg))
{
jsonRespose.Success = false;
jsonRespose.Message = strMsg;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
if (table.Rows.Count > 0)
{
}
else
{
jsonRespose.Success = false;
jsonRespose.Message = "excel无数据";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var message = string.Empty;
bool isSucess = false;
isSucess = MsOpOtherDAL.ImportBlZhdata(Request, table, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_CompanyId(Request), out message, CookieConfig.GetCookie_UserName(Request));
if (!isSucess)
{
jsonRespose.Success = false;
jsonRespose.Message = message;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var json = JsonConvert.Serialize(new { success = true, Message = "上传成功" });
return new ContentResult() { Content = json };
}
catch (Exception)
{
jsonRespose.Success = false;
jsonRespose.Message = "读取Excel文件出错请确认文件正确性";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public List<string> ExcelSheetName(string filepath,string ExcelExt)
{
var al = new List<string>();
try
{
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties="+ ExcelExt;
if (filepath.ToLower().IndexOf(".xlsx") > 0 || filepath.ToLower().IndexOf(".xlsm") > 0)
{
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath +
";Extended Properties=\"Excel 12.0 Xml;HDR=Yes\"";
}
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
System.Data.DataTable sheetNames = conn.GetOleDbSchemaTable
(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
conn.Close();
foreach (DataRow dr in sheetNames.Rows)
{
al.Add(dr[2].ToString());
}
}
catch (Exception)
{
return new List<string>();
}
return al;
}
#endregion
}
}