using System; using System.Linq; using System.Web.Mvc; using DSWeb.MvcShipping.DAL.MsCompanysAccountDAL; using DSWeb.MvcShipping.Models.MsCompanysAccount; 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; namespace DSWeb.MvcShipping.Controllers { [JsonRequestBehavior] public class MsCompanysAccountController : Controller { public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } public ContentResult GetDataList(string condition) { var dataList = MsCompanysAccountDAL.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) { MsCompanysAccount head = null; if (handle == "edit") { head = MsCompanysAccountDAL.GetData(condition, Convert.ToString(Session["COMPANYID"])); head.MODIFIEDUSER = Convert.ToString(Session["USERID"]); head.MODIFIEDTIME = DateTime.Now; } if (head == null) { head = new MsCompanysAccount(); head.LINKID = 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, string LINKID) { 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) }; } // string errorstr = ""; var isPost = true; var bodyList = JsonConvert.Deserialize>(body); // if (isPost) { var modb = new ModelObjectDB(); DBResult result = new DBResult(); if (bodyList != null) { foreach (var enumValue in bodyList) { #region 默认值 MsCompanysAccount headRow = new MsCompanysAccount(); headRow.LINKID = LINKID.Trim(); headRow.CODENAME = enumValue.CODENAME.ToString().Trim(); headRow.CURRENCY = enumValue.CURRENCY.ToString().Trim(); headRow.BANKNAME = enumValue.BANKNAME.ToString().Trim(); headRow.ACCOUNT = enumValue.ACCOUNT.ToString().Trim(); headRow.ACCOUNTNAME = enumValue.ACCOUNTNAME.ToString().Trim(); headRow.SUBJECTCODE = enumValue.SUBJECTCODE.ToString().Trim(); headRow.REMARK = enumValue.REMARK.ToString().Trim(); headRow.FINANCESOFTCODE = enumValue.FINANCESOFTCODE.ToString().Trim(); headRow.CWGLACCID = enumValue.CWGLACCID.ToString().Trim(); headRow.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人gid headRow.CREATETIME = DateTime.Now; headRow.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//更改操作人gid headRow.MODIFIEDTIME = DateTime.Now; headRow.ISSTOP = enumValue.ISSTOP.ToString().Trim(); headRow.ISDEF= enumValue.ISDEF.ToString().Trim(); headRow.BANKNAME2 = enumValue.BANKNAME2.ToString().Trim(); // 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 += "重复数据不再重复插入!"; } } } // var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsCompanysAccountDAL.GetData("", 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) }; } } public ContentResult Delete(string data, string LINKID) { 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 modb = new ModelObjectDB(); var head = JsonConvert.Deserialize(data); //DBResult result = modb.Delete(head); DBResult result = MsCompanysAccountDAL.Delete(head, LINKID); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } }