using System; using System.Linq; using System.Web.Mvc; using DSWeb.MvcShipping.DAL.MsCwCurrencyRateDAL; using DSWeb.MvcShipping.Models.MsCwCurrencyRate; 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 MsCwCurrencyRateController : Controller { public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } public ContentResult GetDataList(string currency) { var dataList = MsCwCurrencyRateDAL.GetDataList(currency, 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 currency) { MsCwCurrencyRate head = null; head = MsCwCurrencyRateDAL.GetData(currency, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"])); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult Save(string body, string currency) { 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) }; } // T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(Convert.ToString(Session["USERID"])); string CurrencyGID = T_ALL_DA.GetStrSQL("GID", "select top 1 gid from code_currency where CODENAME='" + currency + "'"); string errorstr = ""; var isPost = true; var bodyList = JsonConvert.Deserialize>(body); // if (isPost) { var modb = new ModelObjectDB(); DBResult result = null; if (bodyList != null) { foreach (var enumValue in bodyList) { #region 默认值 MsCwCurrencyRate headRow = new MsCwCurrencyRate(); headRow.GID = enumValue.GID.ToString().Trim();//惟一值 headRow.LINKGID = CurrencyGID.Trim();//货币GID headRow.ACCDATE = enumValue.ACCDATE.ToString().Trim();//会计期间 headRow.BEGRATE = enumValue.BEGRATE;//期初汇率 headRow.ENDRATE = enumValue.ENDRATE;//期末汇率 headRow.CORPID = Convert.ToString(Session["COMPANYID"]);//分公司代码 headRow.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人gid headRow.CREATETIME = DateTime.Now;//创建时间 headRow.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//更改操作人gid headRow.MODIFIEDTIME = DateTime.Now;//更改操作时间 headRow.ISDELETE = false;//是否删除 headRow.DELETEUSER = Convert.ToString(Session["USERID"]);//删除人 headRow.DELETETIME = DateTime.Now;//删除时间 headRow.STARTGID = strCwSTARTGID; // headRow.DbOperationType = DbOperationType.DbotUpd; headRow.ModelUIStatus = "E"; #endregion // modb = new ModelObjectDB(); result = modb.Save(headRow); } } // var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsCwCurrencyRateDAL.GetData(currency, 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 GetACCDATE() { string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(Convert.ToString(Session["USERID"])); //strCwACCDATE = strCwACCDATE.Trim().Substring(5,2); //int iMonth = int.Parse(strACCDATE); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = strCwACCDATE }); return new ContentResult() { Content = json }; } } }