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.
459 lines
20 KiB
C#
459 lines
20 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
using System.Collections.Generic;
|
|
using HcUtility.Comm;
|
|
using HcUtility.Core;
|
|
using DSWeb.TruckMng.Helper.Repository;
|
|
using DSWeb.Areas.MvcShipping.Helper;
|
|
using DSWeb.SoftMng.DAL.SoftSysTable;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using DSWeb.MvcShipping.DAL.BillCheckOut;
|
|
using DSWeb.Common.DB;
|
|
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
|
|
using System.Data.Entity.Migrations;
|
|
using MimeKit;
|
|
using org.junit.experimental.theories;
|
|
using DSWeb.SoftMng.Filter;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
[JsonRequestBehavior]
|
|
public class BillCheckOutController : Controller
|
|
{
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
//
|
|
// GET: /
|
|
public ActionResult Edit()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
|
|
#region 查询
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition, string CODENAME = "")
|
|
{
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
if (!canlogin.Success)
|
|
{
|
|
return (ContentResult)canlogin.Data;
|
|
}
|
|
|
|
var count = 0;
|
|
|
|
var userid = Convert.ToString(Session["USERID"]);
|
|
var username = Convert.ToString(Session["SHOWNAME"]);
|
|
var companyid= Convert.ToString(Session["COMPANYID"]);
|
|
|
|
var dataList = BillCheckOutDAL.GetDataList(start, limit, sort, condition, userid, username, companyid, ref count);
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetData(string handle,string condition)
|
|
{
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
if (!canlogin.Success)
|
|
{
|
|
return (ContentResult)canlogin.Data;
|
|
}
|
|
var count = 0;
|
|
var userid = Convert.ToString(Session["USERID"]);
|
|
var username = Convert.ToString(Session["SHOWNAME"]);
|
|
var companyid = Convert.ToString(Session["COMPANYID"]);
|
|
|
|
var data = new BillCheckOut_md();
|
|
var datalist = BillCheckOutDAL.GetDataList(0, 1, "", condition, userid, username, companyid, ref count);
|
|
|
|
if (handle=="add" || datalist == null || datalist.Count == 0)
|
|
{
|
|
//获取空白的新业务 设定默认值
|
|
data.INPUTBY = username;
|
|
data.CORPID = companyid;
|
|
|
|
var cdc = new CommonDataContext();
|
|
var sender = cdc.VW_user.FirstOrDefault(x => x.USERID == userid);
|
|
|
|
data.SENDEREMAIL = sender.EMAIL1;
|
|
}
|
|
else {
|
|
data = datalist[0];
|
|
}
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = data });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetBodyList(string GID,string sort)
|
|
{
|
|
|
|
var dataList = BillCheckOutDAL.GetBodyList(GID);
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 保存
|
|
public ContentResult Save(string opstatus, string data)
|
|
{
|
|
try {
|
|
data = data.Replace("❥", "<");
|
|
var headData = JsonConvert.Deserialize<BillCheckOut_md>( data);
|
|
var cdc = new CommonDataContext();
|
|
|
|
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 == "FAX" && headData.FAX.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "FAX超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// if (enumValue.FIELDNAME == "CHIEF" && headData.CHIEF.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "负责人超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "OP" && headData.OP.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "操作字段超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "COUNTRY" && headData.COUNTRY.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 == "BLCONTENT" && headData.BLCONTENT.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 == "LOGINNAME" && headData.LOGINNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "登陆名超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "LOGINPASSWORD" && headData.LOGINPASSWORD.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 == "FARCODE" && headData.FARCODE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "财务应收账款代码超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "FAPCODE" && headData.FAPCODE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "财务应付账款代码超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "REGISTRATIONNO" && headData.REGISTRATIONNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "企业备案号超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// if (enumValue.FIELDNAME == "TAXNO" && headData.TAXNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "税号超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "INSPECTIONNO" && headData.InspectionNo.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "商检备案号超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "EDICODE" && headData.EDICODE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "EDI代码超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "EDICODE2" && headData.EDICODE2.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "EDI代码2超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "EDICODE3" && headData.EDICODE3.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "EDI代码3超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "ORGANIZATIONCODE" && headData.ORGANIZATIONCODE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "组织机构代码超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
// //if (enumValue.FIELDNAME == "ORDERNO" && headData.ORDERNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "财务序号超长,字段长度限制" + enumValue.FIELDLEN; }
|
|
//}
|
|
|
|
}
|
|
#endregion
|
|
|
|
if (isPost)
|
|
{
|
|
var _r = BillCheckOutDAL.DoSave(opstatus, data, Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
return BasicDataRefDAL.GetContentResult(_r);
|
|
}
|
|
else
|
|
{
|
|
var jsonRespose = new JsonResponse { Success = false, Message = errorstr };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
}catch(Exception ex)
|
|
{
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = ex.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 添加明细
|
|
|
|
public ContentResult AddBill(string GID, string BSNOs)
|
|
{
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
if (!canlogin.Success)
|
|
{
|
|
return (ContentResult)canlogin.Data;
|
|
}
|
|
|
|
var result = new DBResult();
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
var BSNOList = BSNOs.Split(',').ToList();
|
|
|
|
var AddBillList = cdc.v_op_bs.Where(x => BSNOList.Contains(x.BSNO)).ToList();
|
|
|
|
var head = cdc.BillCheckOut.FirstOrDefault(x => x.GID == GID);
|
|
|
|
if (head == null)
|
|
{
|
|
var saveresult = BillCheckOutDAL.DoSave("add", "", Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
if (!saveresult.Success)
|
|
{
|
|
return BasicDataRefDAL.GetContentResult(saveresult);
|
|
}
|
|
else {
|
|
head = (BillCheckOut_md)saveresult.Data;
|
|
}
|
|
}
|
|
|
|
var currDetailList = cdc.BillCheckOut_Detail.Where(x => x.LINKGID == head.GID).ToList();
|
|
|
|
var needsave = false;
|
|
var _count = 0;
|
|
foreach (var item in AddBillList) {
|
|
if (currDetailList.Exists(x => x.BSNO == item.BSNO))
|
|
{
|
|
|
|
}
|
|
else {
|
|
|
|
//判断委托单位
|
|
if (string.IsNullOrWhiteSpace( head.CUSTOMERNAME )) {
|
|
head.CUSTOMERNAME = item.CUSTOMERNAME;
|
|
cdc.BillCheckOut.AddOrUpdate(head);
|
|
}
|
|
if (head.CUSTOMERNAME != item.CUSTOMERNAME) {
|
|
result.SetErrorInfo("必须选择相同委托单位的业务",false, head);
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
}
|
|
|
|
var newrec = new BillCheckOut_Detail_md();
|
|
newrec.GID = Guid.NewGuid().ToString();
|
|
newrec.BSNO= item.BSNO;
|
|
newrec.LINKGID = head.GID;
|
|
newrec.CHECKOUTNO = head.CHECKOUTNO;
|
|
cdc.BillCheckOut_Detail.Add(newrec);
|
|
needsave = true;
|
|
_count++;
|
|
}
|
|
}
|
|
|
|
if (needsave) {
|
|
cdc.SaveChanges();
|
|
}
|
|
head = cdc.BillCheckOut.FirstOrDefault(x => x.GID == head.GID);
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = true,
|
|
Message = $"添加成功{_count}条",
|
|
Data = head
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
public ContentResult DelHead(string GID)
|
|
{
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
var oldhead = cdc.BillCheckOut.Where(x => x.GID == GID).ToList();
|
|
|
|
var olddetail = cdc.BillCheckOut_Detail.Where(x => x.LINKGID == GID).ToList();
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = true,
|
|
Message = "删除成功!",
|
|
Data = ""
|
|
};
|
|
|
|
try
|
|
{
|
|
//判断能否删除 目前只看是否已发出
|
|
|
|
|
|
|
|
if (oldhead != null)
|
|
{
|
|
if (oldhead[0].SENDED==true)
|
|
{
|
|
jsonRespose.Success = false;
|
|
jsonRespose.Message = "已发出的签单条不能删除";
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
cdc.BillCheckOut.RemoveRange(oldhead);
|
|
|
|
|
|
if (olddetail != null)
|
|
{
|
|
cdc.BillCheckOut_Detail.RemoveRange(olddetail);
|
|
|
|
}
|
|
|
|
cdc.SaveChanges();
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception e) {
|
|
jsonRespose.Success = false;
|
|
jsonRespose.Message = e.Message;
|
|
}
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
|
|
|
|
public ContentResult DelDetail(string GID)
|
|
{
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
var GIDList = GID.Split(',').ToList();
|
|
|
|
var olddetail = cdc.BillCheckOut_Detail.Where(x => GIDList.Contains(x.GID)).ToList();
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = true,
|
|
Message = "",
|
|
Data = ""
|
|
};
|
|
try
|
|
{
|
|
if (olddetail != null)
|
|
{
|
|
cdc.BillCheckOut_Detail.RemoveRange(olddetail);
|
|
cdc.SaveChanges();
|
|
}
|
|
}
|
|
catch (Exception e) {
|
|
jsonRespose.Success = false;
|
|
jsonRespose.Message = e.Message;
|
|
}
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 通知签单
|
|
/// <summary>
|
|
/// 向客户发出签单条
|
|
/// </summary>
|
|
/// <param name="BSNOs"></param>
|
|
/// <returns></returns>
|
|
public ContentResult NoticeCustomerToCheckOut(string BSNOs)
|
|
{
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
if (!canlogin.Success)
|
|
{
|
|
return (ContentResult)canlogin.Data;
|
|
}
|
|
|
|
var result = new DBResult();
|
|
|
|
var path= Server.MapPath("../../UploadFiles/MailFile");
|
|
|
|
var username = Convert.ToString(Session["SHOWNAME"]);
|
|
|
|
result = BillCheckOutDAL.NoticeCustomerToCheckOut(BSNOs,path, username);
|
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 签字板签名完成后,记录签名后文档
|
|
/// </summary>
|
|
/// <param name="GID"></param>
|
|
/// <param name="Base64Str"></param>
|
|
/// <returns></returns>
|
|
public ContentResult SaveSignPdf(string GID,string Base64Str)
|
|
{
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
if (!canlogin.Success)
|
|
{
|
|
return (ContentResult)canlogin.Data;
|
|
}
|
|
|
|
var result = new DBResult();
|
|
|
|
var path = Server.MapPath("../../UploadFiles/MailFile");
|
|
|
|
var username = Convert.ToString(Session["SHOWNAME"]);
|
|
|
|
if (username == "")
|
|
{
|
|
result.SetErrorInfo("登录信息丢失,请尝试重新登陆");
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
}
|
|
|
|
result = BillCheckOutDAL.SaveSignPdf(GID, Base64Str, path, username);
|
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
}
|
|
|
|
public ContentResult TestCheckOut(string GID)
|
|
{
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
if (!canlogin.Success)
|
|
{
|
|
return (ContentResult)canlogin.Data;
|
|
}
|
|
|
|
var username = Convert.ToString(Session["SHOWNAME"]);
|
|
var result = BillCheckOutDAL.DoQC(GID,username);
|
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
}
|
|
#endregion
|
|
|
|
#region 查询客户的未签出业务
|
|
|
|
public ContentResult CUSOMERNOQC(string condition = "")
|
|
{
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
if (!canlogin.Success)
|
|
{
|
|
return (ContentResult)canlogin.Data;
|
|
}
|
|
|
|
var count = 0;
|
|
|
|
var data = BillCheckOutDAL.CUSOMERNOQC(condition);
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = data.Count, data = data });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|