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.
664 lines
27 KiB
C#
664 lines
27 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using System.IO;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using DSWeb.Areas.TruckMng.DAL;
|
|
using DSWeb.Areas.TruckMng.DAL.MsRptPcHeadEdit;
|
|
using DSWeb.Areas.TruckMng.Models.MsWlBs;
|
|
|
|
using DSWeb.TruckMng.Helper;
|
|
using HcUtility.Comm;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using HcUtility.Core;
|
|
using DSWeb.TruckMng.Comm.Cookie;
|
|
using DSWeb.EntityDA;
|
|
|
|
using DSWeb.TruckMng.Helper.Repository;
|
|
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
|
|
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
|
|
using DSWeb.Areas.TruckMng.DAL.MsWlBs;
|
|
using DSWeb.MvcShipping.Models.WMSNew;
|
|
using DSWeb.MvcShipping.DAL.WMSNewDAL;
|
|
using DSWeb.SoftMng.Filter;
|
|
|
|
namespace DSWeb.Areas.TruckMng.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 路单查询
|
|
/// </summary>
|
|
[JsonRequestBehavior]
|
|
public class PcHeadEdit_LTJYController : Controller
|
|
//20180426 良通捷运 邓羽 复制自PcHeadEdit_WFSD
|
|
|
|
{
|
|
//
|
|
// GET: /RptMng/MsRptPcHeadQry
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult Edit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult FeeEdit ( )
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetDataList ( int start, int limit, string sort, string condition )
|
|
{
|
|
var dataList = MsRptPcHeadEditDAL.GetLTJYList(condition, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_UserName(Request), CookieConfig.GetCookie_CompanyId(Request), sort);
|
|
//( string strCondition, string userid,string usercode,string username,string companyid,string 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 };
|
|
}
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetDataFenList(int start, int limit, string sort, string condition)
|
|
{
|
|
var dataList = MsRptPcHeadEditDAL.GetLTJYFenList(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 };
|
|
}
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetData(string handle, string condition)
|
|
{
|
|
MsWlPcHead_LTJYEdit head = null;
|
|
if (handle == "edit" || handle == "copyadd")
|
|
{
|
|
head = MsRptPcHeadEditDAL.GetLTJYData(condition);
|
|
}
|
|
if (head == null)
|
|
{
|
|
head = new MsWlPcHead_LTJYEdit();
|
|
head.gId = "PC_" + Guid.NewGuid().ToString("N").ToUpper();
|
|
head.PGid = head.gId;
|
|
head.UserCode = CookieConfig.GetCookie_UserCode(Request);
|
|
head.UserName = Convert.ToString(Session["SHOWNAME"]);
|
|
head.BLTYPE = "派车单票";
|
|
head.PcBillType = "2";
|
|
}
|
|
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult SaveLTJY(string opstatus, string data)
|
|
{
|
|
|
|
var headData = JsonConvert.Deserialize<MsWlPcHead_LTJYEdit>(data);
|
|
|
|
var isPost = true;
|
|
var errorstr = "";
|
|
|
|
var custno = "";
|
|
|
|
if (opstatus == "add")
|
|
{
|
|
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='陆运'", Convert.ToString(Session["COMPANYID"]));
|
|
billnoset.BILLTYPE = "0111";
|
|
billnoset.RULEDATETYPE = "业务日期";
|
|
var bsdate=headData.ExpDate;
|
|
if (bsdate == "" || bsdate == null)
|
|
bsdate = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
|
headData.BillNo = MsSysBillNoSetDAL.GetBillNo(billnoset, bsdate, DateTime.Now.ToString("yyyy-MM")); //获取合同号
|
|
|
|
headData.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
|
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
}
|
|
else if (opstatus == "edit")
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
headData.ModelUIStatus = "E";
|
|
}
|
|
else
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
}
|
|
//if ( !string.IsNullOrEmpty(headData.ExpDate)){
|
|
// headData.ExpDate = headData.ExpDate.Replace("T", " ");
|
|
//}
|
|
//if ( !string.IsNullOrEmpty(headData.ExpDate))
|
|
//{
|
|
// headData.ExpDate = headData.ExpDate.Substring(0, 10);
|
|
//}
|
|
//if ( !string.IsNullOrEmpty(headData.ArriveDate))
|
|
//{
|
|
// headData.ArriveDate = headData.ArriveDate.Substring(0, 10);
|
|
//}
|
|
//if (!string.IsNullOrEmpty(headData.ReturnDate))
|
|
//{
|
|
// headData.ReturnDate = headData.ReturnDate.Substring(0, 10);
|
|
//}
|
|
|
|
if (!string.IsNullOrEmpty(headData.LrDate))
|
|
{
|
|
headData.LrDate = headData.LrDate.Substring(0, 10);
|
|
}
|
|
else
|
|
{
|
|
var currentTime = System.DateTime.Now;
|
|
headData.LrDate = currentTime.ToString("d");
|
|
}
|
|
|
|
var BSNO = headData.gId;
|
|
|
|
if (isPost)
|
|
{
|
|
var modb = new ModelObjectDB();
|
|
DBResult result = modb.Save(headData);
|
|
if (result.Success == true) { }
|
|
else
|
|
{
|
|
MsSysBillNoSetDAL.DeleteBsNo(custno);
|
|
}
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
Data = MsRptPcHeadEditDAL.GetLTJYData("GID='" + BSNO + "'")
|
|
};
|
|
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 SaveLTJYList ( string data )
|
|
{
|
|
var dataList = JsonConvert.Deserialize<List<MsWlPcHead_LTJYEdit>>(data);
|
|
foreach (var _d in dataList){
|
|
if ( !string.IsNullOrEmpty(_d.ExpDate)){
|
|
_d.ExpDate = _d.ExpDate.Replace("T", " ");
|
|
}
|
|
if ( !string.IsNullOrEmpty(_d.ExpDate))
|
|
{
|
|
_d.ExpDate = _d.ExpDate.Substring(0, 10);
|
|
}
|
|
if ( !string.IsNullOrEmpty(_d.ArriveDate))
|
|
{
|
|
_d.ArriveDate = _d.ArriveDate.Substring(0, 10);
|
|
}
|
|
if (!string.IsNullOrEmpty(_d.ReturnDate))
|
|
{
|
|
_d.ReturnDate = _d.ReturnDate.Substring(0, 10);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(_d.LrDate))
|
|
{
|
|
_d.LrDate = _d.LrDate.Substring(0, 10);
|
|
}
|
|
else
|
|
{
|
|
var currentTime = System.DateTime.Now;
|
|
_d.LrDate = currentTime.ToString("d");
|
|
}
|
|
|
|
if (_d.BillNo == "" || _d.BillNo == "*")
|
|
{
|
|
_d.DbOperationType = DbOperationType.DbotIns;
|
|
_d.ModelUIStatus = "I";
|
|
|
|
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='陆运'", Convert.ToString(Session["COMPANYID"]));
|
|
billnoset.BILLTYPE = "0111";
|
|
|
|
_d.BillNo = MsSysBillNoSetDAL.GetBillNo(billnoset, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM")); //获取合同号
|
|
|
|
_d.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
|
|
_d.gId = "PC_" + Guid.NewGuid().ToString("N").ToUpper();
|
|
_d.PGid = _d.gId;
|
|
|
|
}
|
|
else
|
|
{
|
|
_d.DbOperationType = DbOperationType.DbotUpd;
|
|
_d.ModelUIStatus = "E";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
var _L = ModelObjectConvert<MsWlPcHead_LTJYEdit>.ToModelObjectList(dataList);
|
|
//var _DL = ModelObjectConvert<MsWlPcHead_ADLEdit>.ToModelObjectList(DeldataList);
|
|
|
|
var modb = new ModelObjectRepository();
|
|
result = modb.SaveHead(_L);
|
|
|
|
//刷新父窗口上的父节点
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
public ContentResult CreatePC ( string MblNo, string CustomerName, string ContainerQty, string Ton, string LoadCount )
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var _D = new MsWlPcHead_LTJYEdit();
|
|
_D.MblNo = MblNo;
|
|
_D.CustomerName = CustomerName;
|
|
_D.ContainerQty = ContainerQty;//件数
|
|
_D.Ton = Ton;//重量
|
|
_D.LoadCount = LoadCount;//体积
|
|
//////////////
|
|
_D.DbOperationType = DbOperationType.DbotIns;
|
|
_D.ModelUIStatus = "I";
|
|
|
|
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='拼箱运输'", Convert.ToString(Session["COMPANYID"]));
|
|
billnoset.BILLTYPE = "0121";
|
|
|
|
_D.BillNo = MsSysBillNoSetDAL.GetBillNo(billnoset, DateTime.Now.ToString(), DateTime.Now.ToString()); //获取合同号
|
|
|
|
_D.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
|
|
_D.gId = "PC_" + Guid.NewGuid().ToString("N").ToUpper();
|
|
|
|
var modb = new ModelObjectRepository();
|
|
result = modb.Save(_D);
|
|
|
|
//刷新父窗口上的父节点
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
public ContentResult MAKEFEE(string BSNO, string FEENAME, string CUSTOMERNAME, string PRICETYPE,string FEETYPE, string QUANTITY, string PRICE,string REMARK)
|
|
{
|
|
|
|
var userid = CookieConfig.GetCookie_UserId(Request);
|
|
|
|
var amount =( Convert.ToDecimal(QUANTITY)*Convert.ToDecimal(PRICE)).ToString();
|
|
|
|
StringBuilder INSSql = new StringBuilder();
|
|
|
|
INSSql.Append(" INSERT INTO ch_fee ");
|
|
INSSql.Append(" ([GID],[BSNO],[FEETYPE],[FEENAME],[FEEDESCRIPTION],[CUSTOMERTYPE],[CUSTOMERNAME],[UNIT],[UNITPRICE],[QUANTITY] ");
|
|
INSSql.Append(" ,[AMOUNT],[CURRENCY],[EXCHANGERATE],[REASON],[REMARK],[COMMISSIONRATE],[SETTLEMENT],[INVOICE],[ORDERAMOUNT] ");
|
|
INSSql.Append(" ,[ORDERINVOICE],[SUBMITDATE],[AUDITOPERATOR],[AUDITDATE],[ENTEROPERATOR],[ENTERDATE],[DEBITNO] ");
|
|
INSSql.Append(" ,[ISDEBIT],[ISOPEN],[ISADVANCEDPAY],[SORT],[ISINVOICE],[FEESTATUS],[FEEFRT],[ISCRMORDERFEE],[AUDITSTATUS] ");
|
|
INSSql.Append(" ,[INVOICENUM],[CHEQUENUM],[WMSOUTBSNO],[LINENUM],[TAXRATE],[NOTAXAMOUNT],[ACCTAXRATE],[ISVOU],[VOUCHERNO] ");
|
|
INSSql.Append(" ,[ACCDATE],[BXGID],[TAX],[F_NO],[ORDERSETTLEMENT],[TAXUNITPRICE],[ORDERINVSETTLEMENT],[MODIFIEDUSER],[MODIFIEDTIME] ");
|
|
INSSql.Append(" ,[VOUALLNO],[SALESNO],[CARGO_GID],[JKGID],[PREAMOUNT],[INPUTMODE],[DELIVERYNO],[LOCALCURR],[MANAGER]) ");
|
|
INSSql.Append(" VALUES ");
|
|
INSSql.Append(" (newid(),'" + BSNO + "'," + FEETYPE + ",'" + FEENAME + "','','','" + CUSTOMERNAME + "','" + PRICETYPE + "','" + PRICE + "','" + QUANTITY + "' ");
|
|
INSSql.Append(" ," + amount + ",'RMB',1,'','" + REMARK + "',0,0,0,0 ");
|
|
INSSql.Append(" ,0,null,null,null,'"+userid+"',getdate(),null ");
|
|
INSSql.Append(" ,0,0,0,1,0,1,'',0,0 ");
|
|
INSSql.Append(" ,null,null,'',0,0," + amount + ",0,0,null ");
|
|
INSSql.Append(" ,null,null,null,null,null," + PRICE + ",null,'" + userid + "',getdate() ");
|
|
INSSql.Append(" ,'',null,'','',0,'','','RMB','') ");
|
|
|
|
var _r = BasicDataRefDAL.ExecSql(INSSql.ToString());
|
|
var jsonRespose = new JsonResponse { Success = true, Message = "成功" };
|
|
|
|
if (_r == 0)
|
|
{
|
|
jsonRespose = new JsonResponse { Success = false, Message = "失败" };
|
|
}
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
public ContentResult Delete(string data )
|
|
{
|
|
var head = JsonConvert.Deserialize<MsWlPcHead_LTJYEdit>(data);
|
|
|
|
var isfee = MsWlPcDAL.GetFeeCount(head.gId);
|
|
if (isfee)
|
|
{
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "此票业务存在费用,请先删除费用才能删除此票业务!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else
|
|
{
|
|
//如果是出库单 首先取得所涉及的入库明细的列表
|
|
List<WMSNewIN> wmsinList = new List<WMSNewIN>();
|
|
if (head.PcBillTypeREF == "出库") {
|
|
wmsinList = WMSNewDAL.GetWMSINList(" wi.gid in(select inbsno from wms_out_detail where BSNO='" + head.BillNo + "') ", "");
|
|
}
|
|
|
|
var modb = new ModelObjectDBBill();
|
|
DBResult result = modb.Delete(head,
|
|
"delete from tMsWlBsFixed where BillNo='" + head.BillNo + "'",
|
|
"delete from ch_fee where BsNo='" + head.gId + "'",
|
|
"delete from tcard_use where BillNo='" + head.BillNo + "'",
|
|
"delete from WMS where BLNO='" + head.BillNo + "'",
|
|
"delete from WMS_IN where BLNO='" + head.BillNo + "'",
|
|
"delete from WMS_OUT where BSNO='" + head.BillNo + "'",
|
|
"delete from WMS_OUT_DETAIL where BSNO='" + head.BillNo + "'"
|
|
);
|
|
MsSysBillNoSetDAL.DeleteBsNo(head.BillNo);
|
|
|
|
if (wmsinList.Count > 0)
|
|
{
|
|
foreach (var wmsin in wmsinList)
|
|
{
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
string sSQL = "update wms_in set GOODSPACKSTOCK=GOODSPACK-isnull((select sum(GOODSPACKPFSL_OUT) as GOODSPACKPFSL_OUT from VW_WMS_DETAIL where GID=wms_in.GID),0),GOODSSTOCK=GOODSRKSL-isnull((select sum(GOODSPFSL_OUT) as GOODSPFSL_OUT from VW_WMS_DETAIL where GID=wms_in.GID),0) where BLNO='" + wmsin.BLNO + "'";
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
|
|
|
|
sSQL = "update wms set GOODSPACKSTOCK=isnull((select sum(GOODSPACKSTOCK) as GOODSPACKSTOCK from wms_in where ASSOCIATEDNO=wms.GID),0),GOODSSTOCK=isnull((select sum(GOODSSTOCK) as GOODSSTOCK from wms_in where ASSOCIATEDNO=wms.GID),0) where BLNO='" + wmsin.BLNO + "'";
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
|
|
}
|
|
|
|
}
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
public ContentResult UploadFile()
|
|
{
|
|
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["LoadFile"];
|
|
var BillNo = Request.Form["BillNo"];
|
|
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/MsOpFiles/" + BillNo);
|
|
/////////首先删除全部文件
|
|
DirectoryInfo dir = new DirectoryInfo(path);
|
|
try
|
|
{
|
|
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
|
|
foreach (FileSystemInfo i in fileinfo)
|
|
{
|
|
if (i is DirectoryInfo) //判断是否文件夹
|
|
{
|
|
DirectoryInfo subdir = new DirectoryInfo(i.FullName);
|
|
subdir.Delete(true); //删除子目录和文件
|
|
}
|
|
else
|
|
{
|
|
System.IO.File.Delete(i.FullName); //删除指定文件
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e) {
|
|
var message=e.Message;
|
|
}
|
|
//////////
|
|
|
|
if (!Directory.Exists(path))
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
|
|
var size = file.ContentLength;
|
|
var name = Path.GetFileName(file.FileName);
|
|
|
|
var usercode = Convert.ToString(Session["USERCODE"]);
|
|
var partname = usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
string filename = path + "\\" + partname;
|
|
string filenameURL = "../../UploadFiles/MsOpFiles/" + BillNo + "/" + partname;
|
|
if (System.IO.File.Exists(filename))
|
|
{
|
|
System.IO.File.Delete(filename);
|
|
}
|
|
file.SaveAs(filename);
|
|
|
|
if (!System.IO.File.Exists(filename))
|
|
{
|
|
|
|
var json = JsonConvert.Serialize(new { success = false, Message = "上传文件发生未知错误,请重新上传" });
|
|
return new ContentResult() { Content = json };
|
|
|
|
}
|
|
|
|
|
|
try
|
|
{
|
|
|
|
var message = string.Empty;
|
|
|
|
//ContainerNoSe
|
|
var isSucess = MsRptPcHeadEditDAL.UpdateFileData(filenameURL, BillNo, Convert.ToString(Session["USERID"]) );
|
|
|
|
var json = JsonConvert.Serialize(new { success = isSucess.Success, Message = isSucess.Message, data = filename });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
catch (Exception)
|
|
{
|
|
var json = JsonConvert.Serialize(new { success = false, Message = "上传文件出错,请确认文件正确性" });
|
|
return new ContentResult() { Content = json };
|
|
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public ContentResult UploadFile_WMS()
|
|
{
|
|
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["LoadFile"];
|
|
var BillNo = Request.Form["BillNo"];
|
|
var TABLENAME = Request.Form["TABLENAME"];
|
|
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/WMS/" + BillNo);
|
|
/////////首先删除全部文件
|
|
DirectoryInfo dir = new DirectoryInfo(path);
|
|
try
|
|
{
|
|
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
|
|
foreach (FileSystemInfo i in fileinfo)
|
|
{
|
|
if (i is DirectoryInfo) //判断是否文件夹
|
|
{
|
|
DirectoryInfo subdir = new DirectoryInfo(i.FullName);
|
|
subdir.Delete(true); //删除子目录和文件
|
|
}
|
|
else
|
|
{
|
|
System.IO.File.Delete(i.FullName); //删除指定文件
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
var message = e.Message;
|
|
}
|
|
//////////
|
|
|
|
if (!Directory.Exists(path))
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
|
|
var size = file.ContentLength;
|
|
var name = Path.GetFileName(file.FileName);
|
|
|
|
var usercode = Convert.ToString(Session["USERCODE"]);
|
|
var partname = usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
string filename = path + "\\" + partname;
|
|
string filenameURL = "../../UploadFiles/WMS/" + BillNo + "/" + partname;
|
|
if (System.IO.File.Exists(filename))
|
|
{
|
|
System.IO.File.Delete(filename);
|
|
}
|
|
file.SaveAs(filename);
|
|
|
|
if (!System.IO.File.Exists(filename))
|
|
{
|
|
|
|
var json = JsonConvert.Serialize(new { success = false, Message = "上传文件发生未知错误,请重新上传" });
|
|
return new ContentResult() { Content = json };
|
|
|
|
}
|
|
|
|
|
|
try
|
|
{
|
|
|
|
var message = string.Empty;
|
|
|
|
//ContainerNoSe
|
|
var isSucess = MsRptPcHeadEditDAL.UpdateFileData(filenameURL, BillNo, Convert.ToString(Session["USERID"]),TABLENAME);
|
|
|
|
var json = JsonConvert.Serialize(new { success = isSucess.Success, Message = isSucess.Message, data = filename });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
catch (Exception)
|
|
{
|
|
var json = JsonConvert.Serialize(new { success = false, Message = "上传文件出错,请确认文件正确性" });
|
|
return new ContentResult() { Content = json };
|
|
|
|
}
|
|
}
|
|
|
|
public ContentResult DeleteUploadFile(string BillNo)
|
|
{
|
|
|
|
int iResult = 0;
|
|
var bodyList = BillNo;
|
|
var result = new DBResult();
|
|
|
|
if (bodyList != "" || bodyList != null)
|
|
{
|
|
iResult = MsRptPcHeadEditDAL.DeleteUploadFile(bodyList);
|
|
|
|
|
|
}
|
|
if (iResult == 1)
|
|
{
|
|
result.Success = true;
|
|
result.Message = "删除成功!";
|
|
|
|
var path = Server.MapPath("../../UploadFiles/MsOpFiles/" + BillNo);
|
|
/////////首先删除全部文件
|
|
DirectoryInfo dir = new DirectoryInfo(path);
|
|
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
|
|
foreach (FileSystemInfo i in fileinfo)
|
|
{
|
|
if (i is DirectoryInfo) //判断是否文件夹
|
|
{
|
|
DirectoryInfo subdir = new DirectoryInfo(i.FullName);
|
|
subdir.Delete(true); //删除子目录和文件
|
|
}
|
|
else
|
|
{
|
|
System.IO.File.Delete(i.FullName); //删除指定文件
|
|
}
|
|
}
|
|
//////////
|
|
|
|
}
|
|
else if (iResult == 0)
|
|
{
|
|
result.Success = false;
|
|
result.Message = "出现错误,未删除!";
|
|
}
|
|
else if (iResult == -1)
|
|
{
|
|
result.Success = false;
|
|
result.Message = "有异常,删除失败!";
|
|
}
|
|
else if (iResult == -2)
|
|
{
|
|
result.Success = false;
|
|
result.Message = "删除异常,事务已回滚成功!";
|
|
}
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
// Data = MsChFeeDAL.GetDataList(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|