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/MsCtDesignStartusingControl...

194 lines
9.6 KiB
C#

2 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsCtDesignStartusingDAL;
using DSWeb.MvcShipping.Models.MsCtDesignStartusing;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
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 MsCtDesignStartusingController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ContentResult GetDataList(string condition)
{
var dataList = MsCtDesignStartusingDAL.GetDataList(condition, 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 };
}
public ContentResult GetData(string handle, string condition)
{
MsCtDesignStartusing head = null;
if (handle == "edit")
{
head = MsCtDesignStartusingDAL.GetData(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
head.MODIFIEDUSER = Convert.ToString(Session["USERID"]);
head.MODIFIEDTIME = DateTime.Now;
}
if (head == null)
{
head = new MsCtDesignStartusing();
head.CORPID = Convert.ToString(Session["COMPANYID"]);
head.CREATEUSER = Convert.ToString(Session["USERID"]);
head.CREATETIME = DateTime.Now;
head.MODIFIEDUSER = Convert.ToString(Session["USERID"]);
head.MODIFIEDTIME = DateTime.Now;
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string body)
{
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) };
}
//
string errorstr = "";
var isPost = true;
var bodyList = JsonConvert.Deserialize<List<MsCtDesignStartusing>>(body);
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = null;
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
#region 默认值
MsCtDesignStartusing headRow = new MsCtDesignStartusing();
headRow.GID = enumValue.STARTGID == null ? "" : enumValue.STARTGID.ToString().Trim();//唯一编码
headRow.STARTMONTH = enumValue.STARTMONTH == null ? "" : enumValue.STARTMONTH.ToString().Trim().Substring(0, 7);//启用年月
headRow.STARTGID = enumValue.STARTGID == null ? "" : enumValue.STARTGID.ToString().Trim();//财务账套GID
headRow.ISENABLE = enumValue.ISENABLE;//是否启用
headRow.CORPID = Convert.ToString(Session["COMPANYID"]);//分公司代码
headRow.ISDELETE = false;//是否删除
headRow.DELETEUSER = Convert.ToString(Session["USERID"]);//删除人
headRow.DELETETIME = DateTime.Now;//删除时间
headRow.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人gid
headRow.CREATETIME = DateTime.Now;//创建时间
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 = "注意:重复数据,不予以保存!";
}
}
}
if (errorstr.Trim() != "")
{
result.Message = errorstr;
}
//
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCtDesignStartusingDAL.GetData("", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult Delete(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 modb = new ModelObjectDB();
var head = JsonConvert.Deserialize<MsCtDesignStartusing>(data);
//DBResult result = modb.Delete(head);
DBResult result = MsCtDesignStartusingDAL.Delete(head, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult onISENABLE(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 modb = new ModelObjectDB();
var head = JsonConvert.Deserialize<MsCtDesignStartusing>(data);
DBResult result = MsCtDesignStartusingDAL.onISENABLE(head, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 所属账套
public ContentResult GetCtSTARTGID(string condition)
{
var dataList = MsCtDesignStartusingDAL.GetCtSTARTGID(condition, Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#endregion
#region 返回财务当前账套和会计期间
public ContentResult GetInitData(string condition)
{
var strList = MsCtDesignStartusingDAL.GetInitData(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
if (strList.Trim() == "-1")
{
var json = JsonConvert.Serialize(new { Success = false, Message = "请先设置对应的总账账套信息!", data = "" });
return new ContentResult() { Content = json };
}
else
{
var json = JsonConvert.Serialize(new { Success = true, Message = "操作成功!", data = strList });
return new ContentResult() { Content = json };
}
}
#endregion
}
}