void IFinanceBLL.InsertSZType(Model.bi_t_sz_type item) { try { DB.IDB db = new DB.DBByAutoClose(Appsetting.conn); string sql = "select 1 from bi_t_sz_type where pay_way=@pay_way "; var pars = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@pay_way", item.pay_way) }; var dt = db.ExecuteToTable(sql, pars); if (dt.Rows.Count > 0) { throw new Exception("收支类型编号已存在"); } sql = "select 1 from bi_t_sz_type where pay_name=@pay_name "; pars = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@pay_name", item.pay_name) }; dt = db.ExecuteToTable(sql, pars); if (dt.Rows.Count > 0) { throw new Exception("收支类型名称已存在"); } sql = "insert into bi_t_sz_type(pay_way,pay_name,pay_flag,km_code,pay_kind,other1,other2,num1,num2,pay_memo,max_change,if_acc,path,is_account"; sql += ",account_flag,is_pay,is_profit,profit_type,auto_cashsheet,if_CtFix,update_time) values(@pay_way,@pay_name,@pay_flag,@km_code,@pay_kind,@other1"; sql += ",@other2,@num1,@num2,@pay_memo,0,@if_acc,@path,@is_account,@account_flag,@is_pay,@is_profit,@profit_type,@auto_cashsheet,@if_CtFix,@update_time)"; pars = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@pay_way", item.pay_way), new System.Data.SqlClient.SqlParameter("@pay_name", item.pay_name), new System.Data.SqlClient.SqlParameter("@pay_flag", item.pay_flag), new System.Data.SqlClient.SqlParameter("@km_code", item.km_code), new System.Data.SqlClient.SqlParameter("@pay_kind", item.pay_kind), new System.Data.SqlClient.SqlParameter("@other1", item.other1), new System.Data.SqlClient.SqlParameter("@other2", item.other2), new System.Data.SqlClient.SqlParameter("@num1", item.num1), new System.Data.SqlClient.SqlParameter("@num2", item.num2), new System.Data.SqlClient.SqlParameter("@pay_memo", item.pay_memo), new System.Data.SqlClient.SqlParameter("@if_acc", item.if_acc), new System.Data.SqlClient.SqlParameter("@path", item.path), new System.Data.SqlClient.SqlParameter("@is_account", item.is_account), new System.Data.SqlClient.SqlParameter("@account_flag", item.account_flag), new System.Data.SqlClient.SqlParameter("@is_pay", item.is_pay), new System.Data.SqlClient.SqlParameter("@is_profit", item.is_profit), new System.Data.SqlClient.SqlParameter("@profit_type", item.profit_type), new System.Data.SqlClient.SqlParameter("@auto_cashsheet", item.auto_cashsheet), new System.Data.SqlClient.SqlParameter("@if_CtFix", item.if_CtFix), new System.Data.SqlClient.SqlParameter("@update_time", DateTime.Now) }; db.ExecuteScalar(sql, pars); } catch (Exception ex) { Log.writeLog("FinanceBLL.InsertSZType()", ex.ToString(), item.pay_way, item.pay_name); throw new Exception("新建收支类型异常[" + ex.Message + "]"); } }
void IFinanceBLL.UpdateSZType(Model.bi_t_sz_type item) { try { DB.IDB db = new DB.DBByAutoClose(Appsetting.conn); string sql = "select 1 from bi_t_sz_type where pay_name=@pay_name and pay_way<>@pay_way "; var pars = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@pay_way", item.pay_way), new System.Data.SqlClient.SqlParameter("@pay_name", item.pay_name) }; var dt = db.ExecuteToTable(sql, pars); if (dt.Rows.Count > 0) { throw new Exception("收支类型名称已存在"); } sql = "update bi_t_sz_type set pay_name=@pay_name,pay_flag=@pay_flag,km_code=@km_code,pay_kind=@pay_kind,other1=@other1,other2=@other2"; sql += ",num1=@num1,num2=@num2,pay_memo=@pay_memo,if_acc=@if_acc,path=@path,is_account=@is_account,account_flag=@account_flag,is_pay=@is_pay"; sql += ",is_profit=@is_profit,profit_type=@profit_type,auto_cashsheet=@auto_cashsheet,if_CtFix=@if_CtFix,update_time=@update_time where pay_way=@pay_way "; pars = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@pay_way", item.pay_way), new System.Data.SqlClient.SqlParameter("@pay_name", item.pay_name), new System.Data.SqlClient.SqlParameter("@pay_flag", item.pay_flag), new System.Data.SqlClient.SqlParameter("@km_code", item.km_code), new System.Data.SqlClient.SqlParameter("@pay_kind", item.pay_kind), new System.Data.SqlClient.SqlParameter("@other1", item.other1), new System.Data.SqlClient.SqlParameter("@other2", item.other2), new System.Data.SqlClient.SqlParameter("@num1", item.num1), new System.Data.SqlClient.SqlParameter("@num2", item.num2), new System.Data.SqlClient.SqlParameter("@pay_memo", item.pay_memo), new System.Data.SqlClient.SqlParameter("@if_acc", item.if_acc), new System.Data.SqlClient.SqlParameter("@path", item.path), new System.Data.SqlClient.SqlParameter("@is_account", item.is_account), new System.Data.SqlClient.SqlParameter("@account_flag", item.account_flag), new System.Data.SqlClient.SqlParameter("@is_pay", item.is_pay), new System.Data.SqlClient.SqlParameter("@is_profit", item.is_profit), new System.Data.SqlClient.SqlParameter("@profit_type", item.profit_type), new System.Data.SqlClient.SqlParameter("@auto_cashsheet", item.auto_cashsheet), new System.Data.SqlClient.SqlParameter("@if_CtFix", item.if_CtFix), new System.Data.SqlClient.SqlParameter("@update_time", DateTime.Now) }; db.ExecuteScalar(sql, pars); } catch (Exception ex) { LogHelper.writeLog("FinanceBLL.UpdateSZType()", ex.ToString(), item.pay_way, item.pay_name); throw new Exception("修改收支类型异常[" + ex.Message + "]"); } }
Model.bi_t_sz_type IFinanceBLL.GetSZTypeItem(string pay_way) { try { Helper.IRequest req = new Helper.Request(); var json = req.request("/finance?t=get_sz_item", "{\"pay_way\":\"" + pay_way + "\"}"); ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json); if (read.Read("errId") != "0") { throw new Exception(read.Read("errMsg")); } if (read.Read("data") != null) { foreach (ReadWriteContext.IReadContext r in read.ReadList("data")) { Model.bi_t_sz_type item = new Model.bi_t_sz_type(); item.pay_way = r.Read("pay_way"); item.pay_name = r.Read("pay_name"); item.pay_flag = r.Read("pay_flag"); item.km_code = r.Read("km_code"); item.pay_kind = r.Read("pay_kind"); item.other1 = r.Read("other1"); item.other2 = r.Read("other2"); item.num1 = Helper.Conv.ToDecimal(r.Read("num1")); item.num2 = Helper.Conv.ToInt(r.Read("num2")); item.pay_memo = r.Read("pay_memo"); item.if_acc = r.Read("if_acc"); item.path = r.Read("path"); item.is_account = r.Read("is_account"); item.account_flag = r.Read("account_flag"); item.is_pay = r.Read("is_pay"); item.is_profit = r.Read("is_profit"); item.profit_type = r.Read("profit_type"); item.auto_cashsheet = r.Read("auto_cashsheet"); item.if_CtFix = r.Read("if_CtFix"); return(item); } } return(null); } catch (Exception ex) { Helper.LogHelper.writeLog("FinanceBLL.GetSZTypeItem()", ex.ToString(), null); throw ex; } }
void IFinanceBLL.UpdateSZType(Model.bi_t_sz_type item) { try { Helper.IRequest req = new Helper.Request(); ReadWriteContext.IWriteContext write = new ReadWriteContext.WriteContextByJson(); write.Append("pay_way", item.pay_way); write.Append("pay_name", item.pay_name); write.Append("pay_flag", item.pay_flag); write.Append("km_code", item.km_code); write.Append("pay_kind", item.pay_kind); write.Append("other1", item.other1); write.Append("other2", item.other2); write.Append("num1", item.num1.ToString()); write.Append("num2", item.num2.ToString()); write.Append("pay_memo", item.pay_memo); write.Append("if_acc", item.if_acc); write.Append("path", item.path); write.Append("is_account", item.is_account); write.Append("account_flag", item.account_flag); write.Append("is_pay", item.is_pay); write.Append("is_profit", item.is_profit); write.Append("profit_type", item.profit_type); write.Append("auto_cashsheet", item.auto_cashsheet); write.Append("if_CtFix", item.if_CtFix); var json = req.request("/finance?t=change_sz", write.ToString()); ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json); if (read.Read("errId") != "0") { throw new Exception(read.Read("errMsg")); } } catch (Exception ex) { Helper.LogHelper.writeLog("FinanceBLL.UpdateSZType()", ex.ToString(), null); throw ex; } }
DataTable IFinanceBLL.GetSZTypeList() { try { Helper.IRequest req = new Helper.Request(); var json = req.request("/finance?t=get_sz_list", "{\"is_show_stop\":\"1\"}"); ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json); if (read.Read("errId") != "0") { throw new Exception(read.Read("errMsg")); } System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("pay_way", typeof(string)); dt.Columns.Add("pay_name", typeof(string)); dt.Columns.Add("pay_flag", typeof(string)); dt.Columns.Add("km_code", typeof(string)); dt.Columns.Add("pay_kind", typeof(string)); dt.Columns.Add("other1", typeof(string)); dt.Columns.Add("other2", typeof(string)); dt.Columns.Add("num1", typeof(decimal)); dt.Columns.Add("num2", typeof(int)); dt.Columns.Add("pay_memo", typeof(string)); dt.Columns.Add("if_acc", typeof(string)); dt.Columns.Add("path", typeof(string)); dt.Columns.Add("is_account", typeof(string)); dt.Columns.Add("account_flag", typeof(string)); dt.Columns.Add("is_pay", typeof(string)); dt.Columns.Add("is_profit", typeof(string)); dt.Columns.Add("profit_type", typeof(string)); dt.Columns.Add("auto_cashsheet", typeof(string)); dt.Columns.Add("if_CtFix", typeof(string)); if (read.Read("data") != null) { foreach (ReadWriteContext.IReadContext r in read.ReadList("data")) { Model.bi_t_sz_type item = new Model.bi_t_sz_type(); item.pay_way = r.Read("pay_way"); item.pay_name = r.Read("pay_name"); item.pay_flag = r.Read("pay_flag"); item.km_code = r.Read("km_code"); item.pay_kind = r.Read("pay_kind"); item.other1 = r.Read("other1"); item.other2 = r.Read("other2"); item.num1 = Helper.Conv.ToDecimal(r.Read("num1")); item.num2 = Helper.Conv.ToInt(r.Read("num2")); item.pay_memo = r.Read("pay_memo"); item.if_acc = r.Read("if_acc"); item.path = r.Read("path"); item.is_account = r.Read("is_account"); item.account_flag = r.Read("account_flag"); item.is_pay = r.Read("is_pay"); item.is_profit = r.Read("is_profit"); item.profit_type = r.Read("profit_type"); item.auto_cashsheet = r.Read("auto_cashsheet"); item.if_CtFix = r.Read("if_CtFix"); dt.Rows.Add(item.pay_way, item.pay_name, item.pay_flag, item.km_code, item.pay_kind, item.other1, item.other2, item.num1 , item.num2, item.pay_memo, item.if_acc, item.path, item.is_account, item.account_flag, item.is_pay, item.is_profit , item.profit_type, item.auto_cashsheet, item.if_CtFix); } } return(dt); } catch (Exception ex) { Helper.LogHelper.writeLog("FinanceBLL.GetSZTypeList()", ex.ToString(), null); throw ex; } }
public void change_sz(WebHelper w, Dictionary <string, object> kv) { Model.bi_t_sz_type item = w.GetObject <Model.bi_t_sz_type>(); bll.UpdateSZType(item); }
public void add_sz(WebHelper w, Dictionary <string, object> kv) { Model.bi_t_sz_type item = w.GetObject <Model.bi_t_sz_type>(); bll.InsertSZType(item); }
void IServiceBase.Request(string t, string pars, out string res) { try { ReadWriteContext.IReadContext r = new ReadWriteContext.ReadContextByJson(pars); var kv = r.ToDictionary(); IBLL.IFinanceBLL bll = new BLL.FinanceBLL(); if (t == "get_sz_list") { string is_show_stop = r.Read("is_show_stop"); var tb = bll.GetSZTypeList(is_show_stop); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); w.Append("data", tb); res = w.ToString(); } else if (t == "get_sz_item") { string pay_way = r.Read("pay_way"); var tb = bll.GetSZTypeItem(pay_way); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); w.Append("data", tb); res = w.ToString(); } else if (t == "add_sz") { Model.bi_t_sz_type item = new Model.bi_t_sz_type(); item.pay_way = r.Read("pay_way"); item.pay_name = r.Read("pay_name"); item.pay_flag = r.Read("pay_flag"); item.km_code = r.Read("km_code"); item.pay_kind = r.Read("pay_kind"); item.other1 = r.Read("other1"); item.other2 = r.Read("other2"); item.num1 = Helper.Conv.ToDecimal(r.Read("num1")); item.num2 = Helper.Conv.ToInt(r.Read("num2")); item.pay_memo = r.Read("pay_memo"); item.if_acc = r.Read("if_acc"); item.path = r.Read("path"); item.is_account = r.Read("is_account"); item.account_flag = r.Read("account_flag"); item.is_pay = r.Read("is_pay"); item.is_profit = r.Read("is_profit"); item.profit_type = r.Read("profit_type"); item.auto_cashsheet = r.Read("auto_cashsheet"); item.if_CtFix = r.Read("if_CtFix"); bll.InsertSZType(item); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); res = w.ToString(); } else if (t == "change_sz") { Model.bi_t_sz_type item = new Model.bi_t_sz_type(); item.pay_way = r.Read("pay_way"); item.pay_name = r.Read("pay_name"); item.pay_flag = r.Read("pay_flag"); item.km_code = r.Read("km_code"); item.pay_kind = r.Read("pay_kind"); item.other1 = r.Read("other1"); item.other2 = r.Read("other2"); item.num1 = Helper.Conv.ToDecimal(r.Read("num1")); item.num2 = Helper.Conv.ToInt(r.Read("num2")); item.pay_memo = r.Read("pay_memo"); item.if_acc = r.Read("if_acc"); item.path = r.Read("path"); item.is_account = r.Read("is_account"); item.account_flag = r.Read("account_flag"); item.is_pay = r.Read("is_pay"); item.is_profit = r.Read("is_profit"); item.profit_type = r.Read("profit_type"); item.auto_cashsheet = r.Read("auto_cashsheet"); item.if_CtFix = r.Read("if_CtFix"); bll.UpdateSZType(item); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); res = w.ToString(); } else if (t == "delete_sz") { string pay_way = r.Read("pay_way"); bll.DeleteSZType(pay_way); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "0"); w.Append("errMsg", ""); res = w.ToString(); } else { throw new Exception("接口不存在[" + t + "]"); } } catch (Exception ex) { LogHelper.writeLog("finance()", ex.ToString(), t, pars); ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson(); w.Append("errId", "-1"); w.Append("errMsg", ex.Message); res = w.ToString(); } }