|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
|
|
{
|
|
|
|
|
[JsonRequestBehavior]
|
|
|
|
|
public class MsOpReceiptController : Controller
|
|
|
|
|
{
|
|
|
|
|
public ActionResult TemplateAddIndex()
|
|
|
|
|
{
|
|
|
|
|
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 };
|
|
|
|
|
}
|
|
|
|
|
#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) };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
[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 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) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 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 };
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var message = string.Empty;
|
|
|
|
|
|
|
|
|
|
var isSucess = MsOpReceiptDAL.UpdateFileData(filenameURL, name, BSNO, Convert.ToString(Session["USERID"]),TYPE,DOCUMENTATTACHEDCODE,DOCUMENTATTACHEDNO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}
|