|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
using DSWeb.Areas.RptMng.Comm;
|
|
|
|
|
|
|
|
|
|
using DSWeb.TruckMng.Comm.Cookie;
|
|
|
|
|
using DSWeb.TruckMng.Helper;
|
|
|
|
|
using DSWeb.TruckMng.Helper.Repository;
|
|
|
|
|
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Data.OleDb;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsOpAirn;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsOpAirnDAL;
|
|
|
|
|
using System.Web.Configuration;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 路单查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonRequestBehavior]
|
|
|
|
|
public class MsOpAirn_RECEIPTWMSController : Controller
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Edit()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult DoList ( )
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
|
|
|
{
|
|
|
|
|
var dataList = MsOpAirn_RECEIPTWMSDAL.GetDataList(condition, 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)
|
|
|
|
|
{
|
|
|
|
|
MsOpAirn_RECEIPTWMSmb head = null;
|
|
|
|
|
|
|
|
|
|
if (handle == "add")
|
|
|
|
|
{
|
|
|
|
|
head = new MsOpAirn_RECEIPTWMSmb();
|
|
|
|
|
head.GID = System.Guid.NewGuid().ToString();
|
|
|
|
|
head.OP = Convert.ToString(Session["SHOWNAME"]);
|
|
|
|
|
head.OPDATE = DateTime.Now.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var _t = "";
|
|
|
|
|
var list = MsOpAirn_RECEIPTWMSDAL.GetDataList(condition, _t);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
head = list[0];
|
|
|
|
|
|
|
|
|
|
if (head == null)
|
|
|
|
|
{
|
|
|
|
|
head = new MsOpAirn_RECEIPTWMSmb();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ContentResult GetBodyList ( int start, int limit, string sort, string condition )
|
|
|
|
|
{
|
|
|
|
|
var dataList = MsOpAirn_RECEIPTWMSDAL.GetBodyList(condition, 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 Save ( string opstatus, string data,string DetailBody, string DetailDelBody
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
var head = JsonConvert.Deserialize<MsOpAirn_RECEIPTWMSmb>(data);
|
|
|
|
|
var DetailbodyList = JsonConvert.Deserialize<List<MsOpAirn_RECEIPTmb>>(DetailBody);
|
|
|
|
|
var DetaildelbodyList = JsonConvert.Deserialize<List<MsOpAirn_RECEIPTmb>>(DetailDelBody);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(DetailBody) || !string.IsNullOrEmpty(DetailDelBody))
|
|
|
|
|
{
|
|
|
|
|
head.OP = Convert.ToString(Session["SHOWNAME"]);
|
|
|
|
|
head.OPDATE = DateTime.Now.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opstatus == "add")
|
|
|
|
|
{
|
|
|
|
|
head.DbOperationType = DbOperationType.DbotIns;
|
|
|
|
|
head.ModelUIStatus = "I";
|
|
|
|
|
//head.Mainstate = "0";
|
|
|
|
|
head.GID = System.Guid.NewGuid().ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (opstatus == "edit")
|
|
|
|
|
{
|
|
|
|
|
head.DbOperationType = DbOperationType.DbotUpd;
|
|
|
|
|
head.ModelUIStatus = "E";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
head.DbOperationType = DbOperationType.DbotDel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var modb = new ModelObjectRepository();
|
|
|
|
|
DBResult result = modb.Save(head,
|
|
|
|
|
ModelObjectConvert<MsOpAirn_RECEIPTmb>.ToModelObjectList(DetailbodyList),
|
|
|
|
|
ModelObjectConvert<MsOpAirn_RECEIPTmb>.ToModelObjectList(DetaildelbodyList)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (result.Success == true && (!string.IsNullOrEmpty(DetailBody) || !string.IsNullOrEmpty(DetailDelBody)))
|
|
|
|
|
{
|
|
|
|
|
var RECEIPTDOList=new List<MsOpAirn_RECEIPTDOmb>();
|
|
|
|
|
if (!string.IsNullOrEmpty(DetailBody)) {
|
|
|
|
|
foreach (var _d in DetailbodyList) {
|
|
|
|
|
var _do = new MsOpAirn_RECEIPTDOmb();
|
|
|
|
|
_do.GID = Guid.NewGuid().ToString();
|
|
|
|
|
_do.R_GID = _d.GID;
|
|
|
|
|
_do.BSNO = "";
|
|
|
|
|
_do.CUSTOMERNAME = _d.CUSTOMERNAME;
|
|
|
|
|
_do.FIRSTCODE = _d.FIRSTCODE;
|
|
|
|
|
_do.RECEIPTNO = _d.RECEIPTNO;
|
|
|
|
|
_do.TOTALNO = _d.TOTALNO;
|
|
|
|
|
_do.RTYPE = _d.RTYPE;
|
|
|
|
|
_do.ISBAOCANG = _d.ISBAOCANG;
|
|
|
|
|
_do.RSTATUS = _d.RSTATUS;
|
|
|
|
|
_do.OP = _d.OP;
|
|
|
|
|
_do.OPDATE = _d.OPDATE;
|
|
|
|
|
_do.REMARK = _d.REMARK;
|
|
|
|
|
_do.ISWMS = _d.ISWMS;
|
|
|
|
|
RECEIPTDOList.Add(_do);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(DetailDelBody))
|
|
|
|
|
{
|
|
|
|
|
foreach (var _d in DetaildelbodyList)
|
|
|
|
|
{
|
|
|
|
|
var _do = new MsOpAirn_RECEIPTDOmb();
|
|
|
|
|
_do.GID = Guid.NewGuid().ToString();
|
|
|
|
|
_do.R_GID = _d.GID;
|
|
|
|
|
_do.BSNO = "";
|
|
|
|
|
_do.CUSTOMERNAME = _d.CUSTOMERNAME;
|
|
|
|
|
_do.FIRSTCODE = _d.FIRSTCODE;
|
|
|
|
|
_do.RECEIPTNO = _d.RECEIPTNO;
|
|
|
|
|
_do.TOTALNO = _d.TOTALNO;
|
|
|
|
|
_do.RTYPE = _d.RTYPE;
|
|
|
|
|
_do.ISBAOCANG = _d.ISBAOCANG;
|
|
|
|
|
_do.RSTATUS = "删除";
|
|
|
|
|
_do.OP = _d.OP;
|
|
|
|
|
_do.OPDATE = _d.OPDATE;
|
|
|
|
|
_do.REMARK = _d.REMARK;
|
|
|
|
|
_do.ISWMS = _d.ISWMS;
|
|
|
|
|
RECEIPTDOList.Add(_do);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var modb2 = new ModelObjectRepository();
|
|
|
|
|
DBResult result2 = modb2.SaveComm("BSNO",head.GID,
|
|
|
|
|
ModelObjectConvert<MsOpAirn_RECEIPTDOmb>.ToModelObjectList(RECEIPTDOList),
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//刷新父窗口上的父节点
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = result.Success,
|
|
|
|
|
Message = result.Message,
|
|
|
|
|
Data = MsOpAirn_RECEIPTWMSDAL.GetData("GID='" + head.GID + "'")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult Delete ( string data, string USERID )
|
|
|
|
|
{
|
|
|
|
|
var head = JsonConvert.Deserialize<MsOpAirn_RECEIPTWMSmb>(data);
|
|
|
|
|
|
|
|
|
|
var _Bodylist = MsOpAirn_RECEIPTWMSDAL.GetBodyList(" BSNO='"+head.GID+"' and RSTATUS='取用' ", "" );
|
|
|
|
|
|
|
|
|
|
if (_Bodylist.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "单据库存内有已经取用的单据,不能删除。" };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
|
|
DBResult result = modb.Delete(head
|
|
|
|
|
, "delete from op_airn_RECEIPT where BSNO='" + head.GID + "'"
|
|
|
|
|
);
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ContentResult MakeDetail ( string BSNO, string DetailBody, string DetailDelBody )
|
|
|
|
|
{
|
|
|
|
|
var DetailbodyList = JsonConvert.Deserialize<List<MsOpAirn_RECEIPTmb>>(DetailBody);
|
|
|
|
|
var DetaildelbodyList = JsonConvert.Deserialize<List<MsOpAirn_RECEIPTmb>>(DetailDelBody);
|
|
|
|
|
|
|
|
|
|
var modb = new ModelObjectRepository();
|
|
|
|
|
DBResult result = modb.SaveComm("BSNO",BSNO,
|
|
|
|
|
ModelObjectConvert<MsOpAirn_RECEIPTmb>.ToModelObjectList(DetailbodyList),
|
|
|
|
|
ModelObjectConvert<MsOpAirn_RECEIPTmb>.ToModelObjectList(DetaildelbodyList)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//刷新父窗口上的父节点
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = result.Success,
|
|
|
|
|
Message = result.Message,
|
|
|
|
|
Data = null
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 主单库存操作记录
|
|
|
|
|
|
|
|
|
|
public ContentResult GetDoList ( int start, int limit, string sort, string condition )
|
|
|
|
|
{
|
|
|
|
|
var dataList = MsOpAirn_RECEIPTWMSDAL.GetDoList(condition, 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 };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ContentResult File()
|
|
|
|
|
{
|
|
|
|
|
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["file"];
|
|
|
|
|
var PLAN_GID = Request.Form["GID"].ToString().Trim();
|
|
|
|
|
var AIRLINES = Request.Form["AIRLINES"].ToString().Trim();
|
|
|
|
|
if (file == null)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/Bs");
|
|
|
|
|
|
|
|
|
|
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 = filename + " 上传的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;
|
|
|
|
|
OleDbDataAdapter oada = new OleDbDataAdapter("select * from [" + sheetname + "A2:AA]", 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;
|
|
|
|
|
List<MsOpAirn_Freight_Detailmb> headList;
|
|
|
|
|
|
|
|
|
|
//if (customerFieldName == "委托单位")
|
|
|
|
|
//{
|
|
|
|
|
var InsertCount = 0;
|
|
|
|
|
var UpdateCount = 0;
|
|
|
|
|
var UnKnowenTruckNo = "";
|
|
|
|
|
var isSucess = MsOpAirn_FreightDAL.ImportExcelData(Request, table, out message, out InsertCount, out UpdateCount, PLAN_GID, AIRLINES, out UnKnowenTruckNo, out headList);
|
|
|
|
|
if (!isSucess)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = message;
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new
|
|
|
|
|
{
|
|
|
|
|
success = true,
|
|
|
|
|
Message = "上传成功,共处理" + Convert.ToString(headList.Count) + "条记录,其中新增" + Convert.ToString(InsertCount)
|
|
|
|
|
+ "个,更新" + Convert.ToString(UpdateCount) + "个。" + UnKnowenTruckNo,
|
|
|
|
|
data = headList.ToList()
|
|
|
|
|
});
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "读取Excel文件出错 "+e.Message;
|
|
|
|
|
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;
|
|
|
|
|
OleDbConnection conn = new OleDbConnection(strConn);
|
|
|
|
|
conn.Open();
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|