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/RptCwCfsController.cs

395 lines
22 KiB
C#

3 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using System.Text;
using System.Text.RegularExpressions;
using DSWeb.MvcShipping.DAL.RptCwCfsDAL;
using DSWeb.MvcShipping.Models.RptCwCfsEntity;
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 RptCwCfsController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
#region 报表 列表
public ContentResult GetDataList(int start, int limit, string sort, string sMODELGID, string sACCDATE)
{
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 = RptCwCfsDAL.GetDataList(sMODELGID, sACCDATE, 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 sMODELGID, string sACCDATE)
{
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 = RptCwCfsDAL.GetDataListStr(sMODELGID, sACCDATE, 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 sMODELGID, string sACCDATE)
{
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 = RptCwCfsDAL.GetDataListSQL(sMODELGID, sACCDATE, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
#endregion
#region 调整 列表
public ContentResult GetDataListTZ(int start, int limit, string sort, string sMODELGID, string sACCDATE)
{
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 = RptCwCfsDAL.GetDataListTZ(sMODELGID, sACCDATE, 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 SaveRowTZ(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 isPost = true;
var errorstr = "";
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
RptCwCfsEntity headRow = new RptCwCfsEntity();
var headData = JsonConvert.Deserialize<RptVWCwCfsTemplateModelItemEntity>(data);
//
#region 默认值
headRow.GID = headData.GID == null ? "" : headData.GID.ToString().Trim();//唯一编码
headRow.MODELGID = headData.MODELGID == null ? "" : headData.MODELGID.ToString().Trim();//方案GID
headRow.ITEMGID = headData.ITEMGID == null ? "" : headData.ITEMGID.ToString().Trim();//项目GID
headRow.ACCDATE = headData.ACCDATE == null ? "" : headData.ACCDATE.ToString().Trim();//会计期间
headRow.QTYLASTBLC = headData.QTYLASTBLC;//本年累计余额
headRow.QTYBLC = headData.QTYBLC;//本月金额
headRow.QTYLASTBLC_S = headData.QTYLASTBLC_S;//本年累计余额(公式生成)
headRow.QTYBLC_S = headData.QTYBLC_S;//本月金额(公式生成)
headRow.QTYLASTBLC_H = headData.QTYLASTBLC_H;//本年累计余额(手动调整)
headRow.QTYBLC_H = headData.QTYBLC_H;//本月金额(手动调整)
headRow.STARTGID = BasicDataRefDAL.GetCwSTARTGID(Convert.ToString(Session["USERID"]));//账套启用GID
headRow.CORPID = Convert.ToString(Session["COMPANYID"]);//分公司代码
headRow.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//更改操作人gid
headRow.MODIFIEDTIME = DateTime.Now;//更改操作时间
//
headRow.DbOperationType = DbOperationType.DbotUpd;
headRow.ModelUIStatus = "E";
#endregion
//
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headRow);
if (result.Message.ToString().IndexOf("重复键") > -1)
{
var jsonRespose = new JsonResponse { Success = false, Message = "数据重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
RptCwCfsDAL.SaveRow(headData.MODELGID.ToString(), headData.ACCDATE.ToString(), Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]).Trim());
//
var GID = headRow.GID;
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
//,Data = MsCwGenlegAccitemsDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#endregion
#region 明细表 列表
public ContentResult GetDetailList(string sACCDATE, 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 = RptCwCfsDAL.GetDetailList(sACCDATE, 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 sACCDATE)
{
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<RptCwCfsDetailEntity>(data);
string strCondition = "LINKGID='" + LINKGID + "'";
var isPost = true;
#region add
headData.GID = Guid.NewGuid().ToString();
headData.LINKGID = LINKGID;
headData.ACCGID = headData.ACCNAME.ToString();//ACCGID
headData.QTYLASTBLC = 0;//期末余额
headData.QTYBLC = 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)
{
RptCwCfsDAL.SaveRowDetail(sACCDATE, strCondition, Convert.ToString(Session["USERID"]).Trim());
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = RptCwCfsDAL.GetDetailList(sACCDATE, 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<RptCwCfsDetailEntity>(data);
//var modb = new ModelObjectDB();
//DBResult result = modb.Delete(head);
DBResult result = RptCwCfsDAL.DeleteDetail(head);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#endregion
#region 重新计算
public ContentResult GetRecount(string sMODELGID, string sACCDATE)
{
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) };
}
//
RptCwCfsDAL.GetRecount(sMODELGID, sACCDATE, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "操作成功!", data = "" });
return new ContentResult() { Content = json };
}
#endregion
#region 项目维护 列表
//加载 方案下拉框
public ContentResult GetCwCfsModelList(string condition)
{
var dataList = RptCwCfsDAL.GetCwCfsModelList(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]).Trim());
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetCwCfsModelItemList(string sMODELGID)
{
var dataList = RptCwCfsDAL.GetCwCfsModelItemList(sMODELGID, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]).Trim());
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
public ContentResult GetCwCfsModelItemList2(string sITEMGID)
{
var dataList = RptCwCfsDAL.GetCwCfsModelItemList2(sITEMGID, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]).Trim());
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
#region 子项目删除
public ContentResult DeleteItem(string data)
{
var head = JsonConvert.Deserialize<RptCwCfsModelItemEntity>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head);
//DBResult result = RptCwCfsDAL.DeleteDetail(head);
RptCwCfsDAL.GetSort(head.MODELGID.ToString(), Convert.ToString(Session["USERID"]).Trim());
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 子项目保存
public ContentResult SaveItem(string body, string sMODELGID, string sITEMGID, string sLINENUM)
{
string errorstr = "";
var isPost = true;
var bodyList = JsonConvert.Deserialize<List<RptCwCfsModelItemEntity>>(body);
int iLINENUM = int.Parse(sLINENUM) + 1;
//
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = null;
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
#region 默认值
RptCwCfsModelItemEntity headRow = new RptCwCfsModelItemEntity();
headRow.MODELGID = sMODELGID;//方案GID
headRow.ITEMNAME = enumValue.ITEMNAME == null ? "" : enumValue.ITEMNAME.ToString().Trim();//项目名称
headRow.LINENUM = iLINENUM;//项目行次
headRow.DETAILED = true;//末级科目(标志)
headRow.ISALTER = true;//是否允许修改项目
headRow.PACCGID = sITEMGID;//父级科目代码
headRow.ITEMTYPE = enumValue.ITEMTYPE == null ? "" : enumValue.ITEMTYPE.ToString().Trim();//项目属性
headRow.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//更改操作人gid
headRow.MODIFIEDTIME = DateTime.Now;//更改操作时间
//
if (enumValue.GID.ToString().Trim() == "*")
{
headRow.GID = Guid.NewGuid().ToString();//唯一编码
headRow.DbOperationType = DbOperationType.DbotIns;
}
else//"edit"
{
headRow.GID = enumValue.GID.ToString().Trim();//唯一编码
headRow.DbOperationType = DbOperationType.DbotUpd;
headRow.ModelUIStatus = "E";
}
#endregion
//
modb = new ModelObjectDB();
result = modb.Save(headRow);
if (result.Message.ToString().IndexOf("插入重复键") > -1)
{
errorstr += "重复数据不再重复插入!";
}
iLINENUM++;
}
}
RptCwCfsDAL.GetSort(sMODELGID, Convert.ToString(Session["USERID"]).Trim());
//
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#endregion
//新建方案
public ContentResult onAddModel(string dataDiv)
{
UnicodeEncoding unicode = new UnicodeEncoding();
dataDiv = unicode.GetString(unicode.GetBytes(Regex.Unescape(dataDiv)));
dataDiv = dataDiv.Replace("\"","");
DBResult result = RptCwCfsDAL.onAddModel(dataDiv, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = result.Success, Message = result.Message });
return new ContentResult() { Content = json };
}
#endregion
#region 判断资产负债表是否平衡
public ContentResult onIsCwSofp(string sACCDATE)
{
DBResult result = RptCwCfsDAL.onIsCwSofp(sACCDATE, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]).Trim());
var json = JsonConvert.Serialize(new { Success = result.Success, Message = result.Message, data = result.Message });
return new ContentResult() { Content = json };
}
#endregion
#region 自动调平
public ContentResult onAutoLevel(string sMODELGID, string sACCDATE)
{
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) };
}
//
RptCwCfsDAL.onAutoLevel(sMODELGID, sACCDATE, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "操作成功!", data = "" });
return new ContentResult() { Content = json };
}
#endregion
//
}
}