public string SaveAlloctionAndLog() { var inputValue = HttpContext.Current.Request.Form["Inputs"]; var memo = HttpContext.Current.Request.Form["Memo"]; QueryAlloction model = Newtonsoft.Json.JsonConvert.DeserializeObject <QueryAlloction>(inputValue); if (model == null) { return(null); } for (int i = 1; i <= model.ListConfig.Count; i++) { TB_ALLOCTION_CONFIG m = model.ListConfig[(i - 1)]; m.ALLOCTION_StartDate = m.ALLOCTION_EndDate.AddMonths(-1); } memo = memo.Replace('\'', '"'); TB_ALLOCTION_CONFIG_History log = new TB_ALLOCTION_CONFIG_History(); log.CFGDATE = model.ListConfig[0].ALLOCTION_EndDate; log.CFGDEC = memo; log.OPTIONUSER = Framework.Common.Utils.GetCookie("userid"); log.CFGOBJECT = model.ListConfig[0].ParentAREAID; log.OPTIONTIME = DateTime.Now; log.PAYClass = model.ListConfig[0].PAYClass; model.ConfigLog = log; var result = new AlloctionBLL().SaveAlloctionAndLog(model); result.TreeName = model.ParentName; return(Newtonsoft.Json.JsonConvert.SerializeObject(result)); }
public ResultRate SaveAlloctionAndLog(QueryAlloction model) { ResultRate modelResult = new ResultRate(); string sql = ""; if (model.ListConfig != null) { foreach (Model.TB_ALLOCTION_CONFIG c in model.ListConfig) { if (c.ID == 0) { sql += string.Format(@"insert into TB_ALLOCTION_CONFIG(ParentAREAID,AREAID,ALLOCTION_FEE,CFGPERCENT,ALLOCTION_StartDate,PAYTYPE,ALLOCTION_EndDate,PAYClass) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", c.ParentAREAID, c.AREAID, c.ALLOCTION_FEE, c.CFGPERCENT, c.ALLOCTION_StartDate, c.PAYTYPE, c.ALLOCTION_EndDate, c.PAYClass); } else { sql += string.Format(@"update TB_ALLOCTION_CONFIG set ALLOCTION_FEE='{0}',CFGPERCENT='{1}',ALLOCTION_StartDate='{2}',ALLOCTION_EndDate='{3}',PAYClass='{4}' where ID={5}" , c.ALLOCTION_FEE, c.CFGPERCENT, c.ALLOCTION_StartDate, c.ALLOCTION_EndDate, c.PAYClass, c.ID); } } } if (model.ConfigLog != null) { Model.TB_ALLOCTION_CONFIG_History h = model.ConfigLog; sql += string.Format(@" insert into TB_ALLOCTION_CONFIG_History (OPTIONUSER,CFGOBJECT,CFGDEC,CFGDATE,OPTIONTIME,PAYClass) values('{0}','{1}','{2}','{3}','{4}','{5}')", h.OPTIONUSER, h.CFGOBJECT, h.CFGDEC, h.CFGDATE, h.OPTIONTIME, h.PAYClass); } modelResult.IsSucess = _dal.SaveAlloctionAndLog(sql); return(modelResult); }