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.
DS7/DSWeb/Areas/Account/Controllers/Chfee_bankdataController.cs

265 lines
9.5 KiB
C#

2 years ago
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;
2 years ago
using System.IO;
2 years ago
using DSWeb.Areas.Account.Models.Chfee_Invoice;
2 years ago
namespace DSWeb.Areas.Account.Controllers
{
[JsonRequestBehavior]
public class Chfee_bankdataController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
#region
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 };
}
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) };
}
2 years ago
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);
}
2 years ago
2 years ago
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AddBankDataDetail(string billno, string data)
{
2 years ago
2 years ago
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) };
}
2 years ago
2 years ago
[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 = ChBankdataDAL.CSV2DataTable(filename, out strMsg);
2 years ago
var result = new DBResult();
2 years ago
if (!string.IsNullOrEmpty(strMsg))
{
jsonRespose.Success = false;
jsonRespose.Message = strMsg;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
if (table.Rows.Count > 0)
{
2 years ago
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"]) + "' ");
result = ChBankdataDAL.ImpBankData(table, BLCOUNT,Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
2 years ago
}
else
{
jsonRespose.Success = false;
jsonRespose.Message = "excel无数据";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
2 years ago
2 years ago
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) };
}
}
2 years ago
#endregion
2 years ago
2 years ago
#region 参照部分
#endregion
}
}