public string Add(string json, string clientInf) { Eva.Library.Data.AccessDataTrans.IAccessDataTrans t = null; Dictionary <string, string> resultDic = new Dictionary <string, string>(); resultDic["result"] = ""; resultDic["message"] = ""; try { t = sara.dd.ldsw.commonclass.commonclass.CreateIAccessDataTrans(); t.getTrans().begin(); sara.dd.ldsw.model.tbl_ld_jmb model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_ld_jmb>(json); model.sys_lasteditdate = DateTime.Now; model.sys_creatdate = DateTime.Now; model.f_czsj = DateTime.Now; if (model.f_jmbh == "") { model.f_jmbh = sara.dd.ldsw.commonclass.commonclass.getBusinessNum("jm", "", t); } resultDic["result"] = "true"; resultDic["message"] = _idal_tbl_ld_jmb.Add(model, t); t.getTrans().commit(); NewLog("数据创建成功,创建的数据为:" + json, "sql_insert", clientInf); } catch (Exception ex) { if (t != null) { t.getTrans().rollback(); } resultDic["result"] = "false"; resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace); NewLog("数据创建失败,创建的数据为:" + json + ",异常信息:" + Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace), "sql_insert", clientInf); } return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic)); }
public string Update(string json, string type, string columns, string clientInf) { Eva.Library.Data.AccessDataTrans.IAccessDataTrans t = null; Dictionary <string, string> resultDic = new Dictionary <string, string>(); resultDic["result"] = ""; resultDic["message"] = ""; try { t = sara.dd.ldsw.commonclass.commonclass.CreateIAccessDataTrans(); t.getTrans().begin(); sara.dd.ldsw.model.tbl_ld_jmb model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_ld_jmb>(json); model.sys_lasteditdate = DateTime.Now; if (type == "jm") { #region 减免并更新数据 string updatesql = "update TBL_LD_CBIAO set F_JMBH='" + model.f_jmbh + "',F_JMBHID='" + model.sys_id + "',F_JMJE='" + model.f_jmje + "' where SYS_ID='" + model.f_cbbhid + "'"; int flag = t.ExecuteSql(updatesql); if (flag < 0) { resultDic["result"] = "false"; resultDic["message"] = "错误,更新抄表表时出现错误。"; t.getTrans().rollback(); } else { columns = FormatColumns(columns).Replace("^", ","); resultDic["result"] = "true"; resultDic["message"] = _idal_tbl_ld_jmb.Update(model, columns, t); t.getTrans().commit(); NewLog("数据更新成功,更新的数据为:json:" + json + ",columns:" + columns, "sql_update", clientInf); } #endregion } else if (type == "hg") { #region 回滚 //关于读取tbl_ld_cbiao表的数据--只查询运行库中的抄表记录,前端程序控制,历史库中的抄表的减免数据不能回滚 //所以两个时间都传空,实现只查询本表 //判断对应的缴费记录是否已经缴费 IList <sara.dd.ldsw.model.tbl_ld_cbiao> model_cbiao_list = _idal_tbl_ld_cbiao.GetList(" sys_id='" + model.f_cbbhid.ToString() + "'", "", "", "*", "", "", t); if (model_cbiao_list.Count > 0) { sara.dd.ldsw.model.tbl_ld_cbiao model_cbiao = model_cbiao_list[0]; if (model_cbiao.f_ztid == "2") { string updatesql = "update TBL_LD_CBIAO set F_JMBH='',F_JMBHID='',F_JMJE='0' where SYS_ID='" + model.f_cbbhid + "'"; int flag = t.ExecuteSql(updatesql); if (flag < 0) { resultDic["result"] = "false"; resultDic["message"] = "错误,更新抄表表时出现错误。"; t.getTrans().rollback(); } else { columns = FormatColumns(columns).Replace("^", ","); resultDic["result"] = "true"; resultDic["message"] = _idal_tbl_ld_jmb.Update(model, columns, t); #region 减免回滚日志 List <IDictionary <string, string> > array1 = new List <IDictionary <string, string> >(); IDictionary <string, string> temp1 = null; temp1 = new Dictionary <string, string>(); temp1.Add("key", "rollback"); temp1.Add("oldvalue", "客户编号: " + model_cbiao.f_khbh + " 抄表编号:" + model_cbiao.f_cb_cbbh + " 减免编号: " + model.f_jmbh); temp1.Add("newvalue", ""); temp1.Add("name", "减免回滚"); array1.Add(temp1); sara.dd.ldsw.commonclass.commonclass.addUpdateLog("tbl_ld_jmb", model.sys_id.ToString(), "tbl_ld_jmb_detail", "减免回滚", array1, clientInf, t); #endregion t.getTrans().commit(); NewLog("数据更新成功,更新的数据为:json:" + json + ",columns:" + columns, "sql_update", clientInf); } } else { //回滚数据已经改变状态 resultDic["result"] = "false"; resultDic["message"] = "错误,选择的减免信息所对应的抄表记录状态不为已算费。"; t.getTrans().rollback(); } } else { //回滚数据已经改变状态 resultDic["result"] = "false"; resultDic["message"] = "错误,选择的减免信息所对应的抄表记录不存在于运行库中。"; t.getTrans().rollback(); } #endregion } else if (type == "pt") { columns = FormatColumns(columns).Replace("^", ","); resultDic["result"] = "true"; resultDic["message"] = _idal_tbl_ld_jmb.Update(model, columns, t); t.getTrans().commit(); NewLog("数据更新成功,更新的数据为:json:" + json + ",columns:" + columns, "sql_update", clientInf); } else { resultDic["result"] = "false"; resultDic["message"] = "不支持传入的类型参数"; t.getTrans().rollback(); } } catch (Exception ex) { if (t != null) { t.getTrans().rollback(); } resultDic["result"] = "false"; resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace); NewLog("数据更新失败,更新的数据为:json:" + json + ",columns:" + columns + ",异常信息:" + Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace), "sql_update", clientInf); } return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic)); }