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/MvcShipping/Controllers/RptCwSofpController.cs

181 lines
10 KiB
C#

3 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.RptCwSofpDAL;
using DSWeb.MvcShipping.Models.RptCwSofpEntity;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.DAL;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class RptCwSofpController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
//查询
public ContentResult GetDataList(int start, int limit, string sort, string TEMPLATE, string ACCDATE)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var dataList = RptCwSofpDAL.GetDataList(TEMPLATE, ACCDATE, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), 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 GetDataListStr(string TEMPLATE, string ACCDATE)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var dataListStr = RptCwSofpDAL.GetDataListStr(TEMPLATE, ACCDATE, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]).Trim());
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
//导出
public ContentResult GetDataListSQL(string TEMPLATE, string ACCDATE)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var dataListStr = RptCwSofpDAL.GetDataListSQL(TEMPLATE, ACCDATE, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetDetailList(string ACCDATE, string condition)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var dataList = RptCwSofpDAL.GetDetailList(ACCDATE, condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#region 明细表保存
public ContentResult SaveEdit(string data, string LINKGID, string LINKNUM, string ACCDATE)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var headData = JsonConvert.Deserialize<RptCwSofpDetailEntity>(data);
string strCondition = "LINKGID='" + LINKGID + "' and LINKNUM='" + LINKNUM + "'";
var isPost = true;
#region add
headData.GID = Guid.NewGuid().ToString();
headData.LINKGID = LINKGID;
headData.LINKNUM = LINKNUM;
headData.ACCGID = headData.ACCNAME.ToString();
headData.QTYLASTBLC = 0;//期末余额
headData.QTYYEARBLC = 0;//年初余额
headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//更改操作人gid
headData.DbOperationType = DbOperationType.DbotIns;
#endregion
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
if (result.Message.ToString().IndexOf("重复") > -1)
{
var jsonRespose1 = new JsonResponse { Success = false, Message = "抱歉,不允许保存重复数据!请重新录入" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
}
if (result.Success)
{
//RptCwSofpDAL.SaveRowDetail(ACCDATE, strCondition);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = RptCwSofpDAL.GetDetailList(ACCDATE, strCondition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#endregion
#region 明细表删除
public ContentResult DeleteDetail(string data)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var head = JsonConvert.Deserialize<RptCwSofpDetailEntity>(data);
//var modb = new ModelObjectDB();
//DBResult result = modb.Delete(head);
DBResult result = RptCwSofpDAL.DeleteDetail(head);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 重新计算
public ContentResult GetRecount(string TEMPLATE, string ACCDATE)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
RptCwSofpDAL.GetRecount(TEMPLATE, ACCDATE, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "操作成功!", data = "" });
return new ContentResult() { Content = json };
}
#endregion
//
}
}