|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsOpReceiptDAL;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsOpReceipt;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsOpAmend;
|
|
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
using javax.xml.crypto;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
|
|
{
|
|
|
|
|
[JsonRequestBehavior]
|
|
|
|
|
public class MsOpReceiptController : Controller
|
|
|
|
|
{
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 查询列表
|
|
|
|
|
public ContentResult GetDataList(string billno, string optype)
|
|
|
|
|
{
|
|
|
|
|
var dataList = MsOpReceiptDAL.GetDataList("BSNO='" + billno + "'", optype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetBLDataList(int start, int limit, string sort, string condition)
|
|
|
|
|
{
|
|
|
|
|
int total = 0;
|
|
|
|
|
var dataList = MsOpReceiptDAL.GetBLDataList(condition, start, limit, out total, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = total, data = dataList.ToList() });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
public ContentResult GetBLDataListStr(string sort, string condition)
|
|
|
|
|
{
|
|
|
|
|
int total = 0;
|
|
|
|
|
var dataList = MsOpReceiptDAL.GetBLDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = total, data = dataList });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 插入、更新、删除 等 op_receipt 表的操作,并返回操作结果
|
|
|
|
|
public ContentResult Save(string BSNO, string OpReceiptbody)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsOpReceiptEntity>>(OpReceiptbody);
|
|
|
|
|
var result =new DBResult();
|
|
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
iResult = MsOpReceiptDAL.SaveUpdateReceipt(bodyList, BSNO, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
}
|
|
|
|
|
if (iResult == 1) {
|
|
|
|
|
result.Success=true;
|
|
|
|
|
result.Message = "更新成功!";
|
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult Delete(string BSNO,string data)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
var bodyList = data;
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
if (bodyList !="" ||bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
iResult = MsOpReceiptDAL.DeleteReceipt(bodyList);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (iResult == 1)
|
|
|
|
|
{
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "删除成功!";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
|
};
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 单据确认,并返回操作结果
|
|
|
|
|
public ContentResult onSetRECEIPT(string strBSNO, string gids, string onSetType)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
var bodyList = gids;
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
if (bodyList !="" ||bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
iResult = MsOpReceiptDAL.onSetRECEIPT(strBSNO, bodyList, onSetType, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (iResult == 1)
|
|
|
|
|
{
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "操作成功!";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
|
};
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult SongDan(string data,string formdata)
|
|
|
|
|
{
|
|
|
|
|
var MsOpReceiptEntityList = JsonConvert.Deserialize<List<MsOpReceipt>>(data);
|
|
|
|
|
var headData = JsonConvert.Deserialize<MsOpReceiptEntity>(formdata);
|
|
|
|
|
|
|
|
|
|
if (headData.SEND_DATE == "") headData.SEND_DATE = null;
|
|
|
|
|
|
|
|
|
|
var result = MsOpReceiptDAL.SongDan(headData, MsOpReceiptEntityList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
public ContentResult SongDanAll(string condition, string formdata)
|
|
|
|
|
{
|
|
|
|
|
int total = 0;
|
|
|
|
|
var dataList = MsOpReceiptDAL.GetBLDataList(condition, 0,1000, out total, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
|
var headData = JsonConvert.Deserialize<MsOpReceiptEntity>(formdata);
|
|
|
|
|
|
|
|
|
|
if (headData.SEND_DATE == "") headData.SEND_DATE = null;
|
|
|
|
|
var result = MsOpReceiptDAL.SongDan(headData, dataList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult CancelSongDan(string data)
|
|
|
|
|
{
|
|
|
|
|
var MsOpReceiptEntityList = JsonConvert.Deserialize<List<MsOpReceipt>>(data);
|
|
|
|
|
var headData =new MsOpReceiptEntity();
|
|
|
|
|
headData.SEND_DATE = null;
|
|
|
|
|
|
|
|
|
|
var result = MsOpReceiptDAL.SongDan(headData, MsOpReceiptEntityList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ContentResult HuiDan(string data, string formdata)
|
|
|
|
|
{
|
|
|
|
|
var MsOpReceiptEntityList = JsonConvert.Deserialize<List<MsOpReceipt>>(data);
|
|
|
|
|
var headData = JsonConvert.Deserialize<MsOpReceiptEntity>(formdata);
|
|
|
|
|
|
|
|
|
|
if (headData.REPEAT_DATE == "") headData.REPEAT_DATE = null;
|
|
|
|
|
|
|
|
|
|
var result = MsOpReceiptDAL.HuiDan(headData, MsOpReceiptEntityList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
public ContentResult HuiDanAll(string condition, string formdata)
|
|
|
|
|
{
|
|
|
|
|
int total = 0;
|
|
|
|
|
var dataList = MsOpReceiptDAL.GetBLDataList(condition, 0, 1000, out total, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
|
var headData = JsonConvert.Deserialize<MsOpReceiptEntity>(formdata);
|
|
|
|
|
|
|
|
|
|
if (headData.REPEAT_DATE == "") headData.REPEAT_DATE = null;
|
|
|
|
|
var result = MsOpReceiptDAL.HuiDan(headData, dataList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult CancelHuiDan(string data)
|
|
|
|
|
{
|
|
|
|
|
var MsOpReceiptEntityList = JsonConvert.Deserialize<List<MsOpReceipt>>(data);
|
|
|
|
|
var headData = new MsOpReceiptEntity();
|
|
|
|
|
headData.REPEAT_DATE = null;
|
|
|
|
|
|
|
|
|
|
var result = MsOpReceiptDAL.HuiDan(headData, MsOpReceiptEntityList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult HuanDan(string data, string formdata)
|
|
|
|
|
{
|
|
|
|
|
var MsOpReceiptEntityList = JsonConvert.Deserialize<List<MsOpReceipt>>(data);
|
|
|
|
|
var headData = JsonConvert.Deserialize<MsOpReceiptEntity>(formdata);
|
|
|
|
|
|
|
|
|
|
if (headData.RETURN_DATE == "") headData.RETURN_DATE = null;
|
|
|
|
|
|
|
|
|
|
var result = MsOpReceiptDAL.HuanDan(headData, MsOpReceiptEntityList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
public ContentResult HuanDanAll(string condition, string formdata)
|
|
|
|
|
{
|
|
|
|
|
int total = 0;
|
|
|
|
|
var dataList = MsOpReceiptDAL.GetBLDataList(condition, 0, 1000, out total, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
|
var headData = JsonConvert.Deserialize<MsOpReceiptEntity>(formdata);
|
|
|
|
|
|
|
|
|
|
if (headData.RETURN_DATE == "") headData.RETURN_DATE = null;
|
|
|
|
|
var result = MsOpReceiptDAL.HuanDan(headData, dataList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult CancelHuanDan(string data)
|
|
|
|
|
{
|
|
|
|
|
var MsOpReceiptEntityList = JsonConvert.Deserialize<List<MsOpReceipt>>(data);
|
|
|
|
|
var headData = new MsOpReceiptEntity();
|
|
|
|
|
headData.RETURN_DATE = null;
|
|
|
|
|
|
|
|
|
|
var result = MsOpReceiptDAL.HuanDan(headData, MsOpReceiptEntityList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ContentResult UploadFile()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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) };
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
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 CUSTNO = Request.Form["CUSTNO"];
|
|
|
|
|
var BSNO = Request.Form["BSNO"];
|
|
|
|
|
var TYPE = Request.Form["TYPE"];
|
|
|
|
|
var DOCUMENTATTACHEDCODE = Request.Form["DOCUMENTATTACHEDCODE"];
|
|
|
|
|
var DOCUMENTATTACHEDNO = Request.Form["DOCUMENTATTACHEDNO"];
|
|
|
|
|
if (file == null)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//20230206 增加逻辑 如果bsno来自一个op_seae_billmanage.as_id 则将BSNO改为它的op_seae_billmanag.BSNO
|
|
|
|
|
//该功能用于将在【提单管理】模块中,选择分单之后上传的附件,在主单的【单据管理】模块中可见
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
var fenlist = cdc.OP_SEAE_BILLMANAGE.Where(x => x.AS_ID == CUSTNO).ToList();
|
|
|
|
|
if (fenlist != null && fenlist.Count > 0) {
|
|
|
|
|
BSNO = fenlist[0].BSNO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/MsOpFiles/" + CUSTNO);
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var size = file.ContentLength;
|
|
|
|
|
var name =BasicDataRefDAL.DelOtherWord( 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/" + CUSTNO + "/" + 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 };
|
|
|
|
|
}
|
|
|
|
|
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 message = string.Empty;
|
|
|
|
|
|
|
|
|
|
var isSucess = MsOpReceiptDAL.UpdateFileData(filenameURL, name, BSNO, Convert.ToString(Session["USERID"]),TYPE,DOCUMENTATTACHEDCODE,DOCUMENTATTACHEDNO,CUSTNO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var json2 = JsonConvert.Serialize(new { success = isSucess.Success, Message = isSucess.Message, data = filename });
|
|
|
|
|
return new ContentResult() { Content = json2 };
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
var json = JsonConvert.Serialize(new { success = false, Message = $"上传文件出错,请确认文件正确性{e.Message}" });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult UploadFile_PL()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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 isSucess = new DBResult();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
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 CUSTNO = Request.Form["CUSTNO"];
|
|
|
|
|
var BSNO = Request.Form["BSNO"];
|
|
|
|
|
var TYPE = Request.Form["TYPE"];
|
|
|
|
|
var DOCUMENTATTACHEDCODE = Request.Form["DOCUMENTATTACHEDCODE"];
|
|
|
|
|
var DOCUMENTATTACHEDNO = Request.Form["DOCUMENTATTACHEDNO"];
|
|
|
|
|
|
|
|
|
|
TYPE = TYPE == null ? "" : TYPE;
|
|
|
|
|
DOCUMENTATTACHEDCODE = DOCUMENTATTACHEDCODE == null ? "" : DOCUMENTATTACHEDCODE;
|
|
|
|
|
DOCUMENTATTACHEDNO = DOCUMENTATTACHEDNO == null ? "" : DOCUMENTATTACHEDNO;
|
|
|
|
|
|
|
|
|
|
for (int idx = 0; idx < Request.Files.Count; idx++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var file = Request.Files.Get(idx);
|
|
|
|
|
|
|
|
|
|
if (file == null)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//20230206 增加逻辑 如果bsno来自一个op_seae_billmanage.as_id 则将BSNO改为它的op_seae_billmanag.BSNO
|
|
|
|
|
//该功能用于将在【提单管理】模块中,选择分单之后上传的附件,在主单的【单据管理】模块中可见
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
var fenlist = cdc.OP_SEAE_BILLMANAGE.Where(x => x.AS_ID == CUSTNO).ToList();
|
|
|
|
|
if (fenlist != null && fenlist.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
BSNO = fenlist[0].BSNO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/MsOpFiles/" + CUSTNO);
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var size = file.ContentLength;
|
|
|
|
|
var name = BasicDataRefDAL.DelOtherWord(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/" + CUSTNO + "/" + 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 };
|
|
|
|
|
}
|
|
|
|
|
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 message = string.Empty;
|
|
|
|
|
|
|
|
|
|
isSucess = MsOpReceiptDAL.UpdateFileData(filenameURL, name, BSNO, Convert.ToString(Session["USERID"]), TYPE, DOCUMENTATTACHEDCODE, DOCUMENTATTACHEDNO, CUSTNO);
|
|
|
|
|
|
|
|
|
|
if (!isSucess.Success) {
|
|
|
|
|
return Json(isSucess);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Json(isSucess);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = false, Message = $"上传文件出错,请确认文件正确性{e.Message}" });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ContentResult UploadFileCust()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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 CUSTNO = Request.Form["MBLNO"];
|
|
|
|
|
var BSNO = Request.Form["BSNO"];
|
|
|
|
|
var TYPE = Request.Form["FILETYPE"];
|
|
|
|
|
var DOCUMENTATTACHEDCODE = Request.Form["DOCUMENTATTACHEDCODE"];
|
|
|
|
|
var DOCUMENTATTACHEDNO = Request.Form["DOCUMENTATTACHEDNO"];
|
|
|
|
|
var USERID= Request.Form["USERID"];
|
|
|
|
|
var userList = BasicDataRefDAL.GetUserRefList("GID='"+USERID+"'","");
|
|
|
|
|
if (string.IsNullOrEmpty(USERID) || userList.Count <= 1) {
|
|
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file == null)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/MsOpFiles/" + CUSTNO);
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var size = file.ContentLength;
|
|
|
|
|
var name = Path.GetFileName(file.FileName);
|
|
|
|
|
|
|
|
|
|
var partname ="PR"+ DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
|
|
|
string filename = path + "\\" + partname;
|
|
|
|
|
string filenameURL = "../../UploadFiles/MsOpFiles/" + CUSTNO + "/" + 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 };
|
|
|
|
|
}
|
|
|
|
|
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) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var message = string.Empty;
|
|
|
|
|
|
|
|
|
|
var isSucess = MsOpReceiptDAL.UpdateFileData(filenameURL, name, BSNO, USERID, TYPE, DOCUMENTATTACHEDCODE, DOCUMENTATTACHEDNO,CUSTNO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 data)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
var bodyList = data;
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
if (bodyList != "" || bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
iResult = MsOpReceiptDAL.DeleteUploadFile(bodyList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (iResult == 1)
|
|
|
|
|
{
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "删除成功!";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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) };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public ContentResult SaveUploadFile(string data)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
var bodyList = JsonConvert.Deserialize<List<ReceiptDocmb>>(data);
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
result = MsOpReceiptDAL.UpdateFileData(bodyList, Convert.ToString(Session["USERID"]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 权限设置
|
|
|
|
|
public ContentResult GetReceiptOpRang()
|
|
|
|
|
{
|
|
|
|
|
var list = MsOpReceiptDAL.GetReceiptOpRang(Convert.ToString(Session["USERID"]));
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
|
|
new { Success = true, Message = "查询成功", data = list.ToList() });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}
|