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.

263 lines
11 KiB
C#

9 months ago
using System;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.CRM_QUOTATIONDAL;
using DSWeb.MvcShipping.Models.CRM_QUOTATION;
using DSWeb.MvcShipping.Models.MsOpAireBill;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using System.IO;
using System.Data;
using System.Data.OleDb;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
using DSWeb.Areas.CommMng.Models;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsOpApply;
using DSWeb.MvcShipping.DAL.MsOpApplyDAL;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.TruckMng.Helper.Repository;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class CRM_QUOTATION_CARRIERController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition,string load)
{
var dataList = CRM_QUOTATIONDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort, load);
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,string BLTYPE)
{
CRM_QUOTATIONmb head = null;
if (handle == "edit")
{
head = CRM_QUOTATIONDAL.GetData(condition);
}
if (head == null)
{
head = new CRM_QUOTATIONmb();
/*
head.OP = Convert.ToString(Session["SHOWNAME"]);
head.INPUTBY= Convert.ToString(Session["SHOWNAME"]);
head.CUSTSERVICE = Convert.ToString(Session["SHOWNAME"]);
head.PFREIGHT = "0";
head.PVALUEFEE = "0";
head.PCARRIEROT = "0";
head.POTFREIGHT = "0";
head.PTOTAL = "0";
head.CFREIGHT = "0";
head.CVALUEFEE = "0";
head.CCARRIEROT = "0";
head.COTFREIGHT = "0";
head.CTOTAL = "0";*/
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save ( string opstatus, string data, string DetailBody, string DetailDelBody )
{
var aaa = "";
//var dataall = data.Replace("}", ",") + (data2.Replace("{", "")).Replace("}", ",") + data3.Replace("{", "");
//var dataall = data.Replace("}", ",") + data2.Replace("{", "");
var headData = JsonConvert.Deserialize<CRM_QUOTATIONmb>(data);
var DetailbodyList = JsonConvert.Deserialize<List<CRM_QUOTATION_DETAILmb>>(DetailBody);
var DetaildelbodyList = JsonConvert.Deserialize<List<CRM_QUOTATION_DETAILmb>>(DetailDelBody);
if (opstatus == "add" && headData.GID=="")
{
headData.GID = PubSysDAL.GetBillNo("0403");
}
var isPost = true;
var errorstr = "";
var isuse = false;
var iscreatecustno = false;
if (headData.CORPID == ""||headData.CORPID ==null)
{
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
}
/*
if (headData.MBLNO != "" && headData.MBLNO != null && headData.BLTYPE == "国内主单" )
{
var ct = CRM_QUOTATIONDAL.GetRdCount(" MBLNO='" + headData.MBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "' and BLTYPE='国内主单'");
if (ct != 0)
{
isPost = false;
errorstr = "主单号";
}
}
*/
if (opstatus == "add")
{
//headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
headData.CREATETIME = DateTime.Now.ToString();
//headData.BSSTATUS = false;
//headData.FEESTATUS = false;
headData.DbOperationType = DbOperationType.DbotIns;
headData.ModelUIStatus = "I";
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
//if (headData.MASTERNO == null || headData.MASTERNO =="") { headData.MASTERNO = headData.BSNO; }
if (headData.ETA == "") headData.ETA = null;
if (headData.ETD == "") headData.ETD = null;
//if (headData.STLDATE == "") headData.STLDATE = null;
//if (headData.INSPECTIONDATE == "") headData.INSPECTIONDATE = null;
//if (headData.CUSTOMDATE == "") headData.CUSTOMDATE = null;
////headData.PORTLOAD = MsBaseInfoDAL.DelPortCn(headData.PORTLOAD);
////headData.PORTDISCHARGE = MsBaseInfoDAL.DelPortCn(headData.PORTDISCHARGE);
//var BSNO = headData.BSNO;
/*
if (headData.BLTYPE == "国内主单" && headData.MASTERNO!="" && opstatus!="add")
{
//如果是编辑 需要根据MASTERNO清除库存主单使用记录
CRM_QUOTATIONDAL.ExecSql(" update op_airn_RECEIPT set RSTATUS='入库',OP='" + Convert.ToString(Session["SHOWNAME"]) + "',OPDATE=getdate() where GID=(select Masterno from OP_AIRN where BSNO='" + headData.BSNO + "') ");
}*/
if (isPost)
{
var modb = new ModelObjectRepository();
DBResult result = modb.Save(headData
,
ModelObjectConvert<CRM_QUOTATION_DETAILmb>.ToModelObjectList(DetailbodyList),
ModelObjectConvert<CRM_QUOTATION_DETAILmb>.ToModelObjectList(DetaildelbodyList)
);
/*
else
{
//MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
} */
headData.MODIFIEDUSER = Convert.ToString(Session["SHOWNAME"]);
headData.MODIFIEDTIME = DateTime.Now.ToString();
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = CRM_QUOTATIONDAL.GetData("GID='" + headData.GID + "'")
};
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 SaveChild ( string opstatus, string data, string parentgid,string DetailBody, string DetailDelBody )
{
var headData = JsonConvert.Deserialize<CRM_QUOTATIONmb>(data);
if (opstatus == "add" && headData.GID == "")
{
headData.GID = PubSysDAL.GetBillNo("0403");
}
CRM_QUOTATIONDAL.ExecSql(" delete from CRM_QUOTATION_LINK where CUSTCQGID='" + parentgid + "' and CARRIERCQGID='" + headData.GID + "'");
CRM_QUOTATIONDAL.ExecSql(" insert into CRM_QUOTATION_LINK (GID,CUSTCQGID,CARRIERCQGID) values(newid(), '" + parentgid + "','" + headData.GID + "') ");
return Save(opstatus, data, DetailBody, DetailDelBody);
}
public ContentResult Delete(string data)
{
var head = JsonConvert.Deserialize<CRM_QUOTATIONmb>(data);
var isfee = CRM_QUOTATIONDAL.GetFeeCount(head.GID);
if (isfee)
{
var jsonRespose = new JsonResponse { Success = false, Message ="此票业务存在费用,请先删除费用才能删除此票业务!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
var BSNO = head.GID;
var modb = new ModelObjectDB();
DBResult result = new DBResult();
if (head.BLTYPE == "国内主单") {
/*
result = modb.Delete(head, "update op_airn_RECEIPT set RSTATUS='入库',OP='" + Convert.ToString(Session["SHOWNAME"])
+ "',OPDATE=getdate() where GID=(select Masterno from OP_AIRN where BSNO='" + head.BSNO + "')"
,"update OP_AIRN set MBLNO='' where BLTYPE='国内分单' and MBLNO='"+head.MBLNO+"'"
);*/
}
if (head.BLTYPE == "国内分单")
{
/*
if (head.MBLNO != "")
{
result.Success = false;
result.Message = "已经生成主单,请先删除其主单";
}
else {
result = modb.Delete(head);
}*/
}
//if (result.Success == true) { MsSysBillNoSetDAL.DeleteBsNo(head.CUSTNO); }
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#region 商品信息
public ContentResult GetDetailList ( string condition )
{
var dataList = CRM_QUOTATIONDAL.GetDetailList(condition);
//var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#endregion
}
}