|
|
using System;
|
|
|
using System.Linq;
|
|
|
using System.Web.Mvc;
|
|
|
using DSWeb.Areas.Account.DAL.Chfee_Jinzhang;
|
|
|
using DSWeb.Areas.Account.Models.Chfee_jinzhang;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using System.Collections.Generic;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.Areas.Account.Models.Chfee_Exrate;
|
|
|
using System.Data;
|
|
|
using DSWeb.Areas.Account.Models.Chfee_Bankdata;
|
|
|
using DSWeb.Areas.Account.DAL.Chfee_bankdata;
|
|
|
using System.IO;
|
|
|
using DSWeb.Areas.Account.Models.Chfee_Invoice;
|
|
|
using DSWeb.Areas.Account.Models.Chfee_Settlement;
|
|
|
using DSWeb.SoftMng.Filter;
|
|
|
|
|
|
namespace DSWeb.Areas.Account.Controllers
|
|
|
{
|
|
|
[JsonRequestBehavior]
|
|
|
public class Chfee_bankdataController : Controller
|
|
|
{
|
|
|
//
|
|
|
// GET:
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET: /
|
|
|
public ActionResult Edit()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
public ActionResult StlIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult StlMateIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:
|
|
|
|
|
|
#region
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
|
{
|
|
|
var dataList = ChBankdataDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), 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)
|
|
|
{
|
|
|
ChBankdata head = null;
|
|
|
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = ChBankdataDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
|
|
|
if (list.Count > 0)
|
|
|
head = list[0];
|
|
|
}
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new ChBankdata();
|
|
|
}
|
|
|
|
|
|
if (handle == "add")
|
|
|
{
|
|
|
head.CREATEUSER = Convert.ToString(Session["USERID"]);
|
|
|
head.CREATEUSERREF = Convert.ToString(Session["SHOWNAME"]);
|
|
|
head.CORPID = Convert.ToString(Session["COMPANYID"]);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
public ContentResult Delete(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<ChBankdata>(data);
|
|
|
DBResult result;
|
|
|
var modb = new ModelObjectDB();
|
|
|
result=modb.Delete(headData);
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public ContentResult DeleteList(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<List<ChBankdata>>(data);
|
|
|
DBResult result=new DBResult();
|
|
|
foreach (var bill in headData)
|
|
|
{
|
|
|
var modb = new ModelObjectDB();
|
|
|
result = modb.Delete(bill);
|
|
|
}
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
#region 匹配结算
|
|
|
|
|
|
public ContentResult AddBankDataStlDetail(string billno, string data)
|
|
|
{
|
|
|
|
|
|
var bodyList = JsonConvert.Deserialize<List<ChSettlement>>(data);
|
|
|
|
|
|
DBResult result = ChBankdataDAL.AddBankDataStlDetail(bodyList, billno, 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 AddAutoBankDataStlDetail(string condition, string fitcondition)
|
|
|
{
|
|
|
DBResult result = ChBankdataDAL.AddAutoBankDataStlDetail(condition, fitcondition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public ContentResult AddBankDataDetail(string billno, string data)
|
|
|
{
|
|
|
|
|
|
var bodyList = JsonConvert.Deserialize<List<ChInvoice>>(data);
|
|
|
|
|
|
DBResult result = ChBankdataDAL.AddBankDataDetail(bodyList, billno, 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 AddAutoBankDataDetail(string condition, string fitcondition)
|
|
|
{
|
|
|
DBResult result = ChBankdataDAL.AddAutoBankDataDetail(condition, fitcondition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public ContentResult DelBankDataDetail(string data)
|
|
|
{
|
|
|
|
|
|
var bodyList = JsonConvert.Deserialize<List<ChBankdata>>(data);
|
|
|
|
|
|
DBResult result = ChBankdataDAL.DelBankDataDetail(bodyList);
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
|
public ContentResult ImpExcel()
|
|
|
{
|
|
|
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 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["DsLoadExcel"];
|
|
|
|
|
|
if (file == null)
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/ImpBsExcel");
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
{
|
|
|
Directory.CreateDirectory(path);
|
|
|
}
|
|
|
var imptype = Request.Form["imptype"];
|
|
|
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) };
|
|
|
}
|
|
|
|
|
|
|
|
|
try
|
|
|
{
|
|
|
string ext = Path.GetExtension(file.FileName).ToLower();
|
|
|
if (ext != ".xls" && ext != ".xlsx" && ext != ".csv")
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "上传的文件不是Excel文件";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
var strMsg = "";
|
|
|
System.Data.DataTable table = new System.Data.DataTable();
|
|
|
if (ext==".csv")
|
|
|
table = ChBankdataDAL.CSV2DataTable(filename, out strMsg);
|
|
|
else
|
|
|
table = ExcelHelper.ReadStreamToDataTable(file.InputStream, out strMsg,null,true,1);
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strMsg))
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = strMsg;
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
if (table.Rows.Count > 0)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select isnull(MAX(PCNO),0) BLCOUNT from ch_fee_bankdata where CORPID='" + Convert.ToString(Session["COMPANYID"]) + "' ");
|
|
|
|
|
|
if (ext == ".csv")
|
|
|
result = ChBankdataDAL.ImpBankData(table, BLCOUNT,Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
|
|
|
else result = ChBankdataDAL.ImpBankData2(table, BLCOUNT, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "excel无数据!";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new
|
|
|
{
|
|
|
success = result.Success,
|
|
|
Message = result.Message
|
|
|
});
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "读取Excel文件出错,请确认文件正确性" + e.Message;
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|