/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_complaint model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_complaint("); strSql.Append("c_tjtimes,c_tjname,c_clname,c_cltimes,c_result,c_reason,c_state,c_appid,c_userid,c_payid,c_tradeno,c_code,c_money,c_times,c_datimes"); strSql.Append(") values ("); strSql.Append("@c_tjtimes,@c_tjname,@c_clname,@c_cltimes,@c_result,@c_reason,@c_state,@c_appid,@c_userid,@c_payid,@c_tradeno,@c_code,@c_money,@c_times,@c_datimes"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@c_tjtimes", SqlDbType.DateTime), new SqlParameter("@c_tjname", SqlDbType.NVarChar, 50), new SqlParameter("@c_clname", SqlDbType.NVarChar, 50), new SqlParameter("@c_cltimes", SqlDbType.DateTime), new SqlParameter("@c_result", SqlDbType.NVarChar, -1), new SqlParameter("@c_reason", SqlDbType.NVarChar, -1), new SqlParameter("@c_state", SqlDbType.Char, 10), new SqlParameter("@c_appid", SqlDbType.Int, 4), new SqlParameter("@c_userid", SqlDbType.Int, 4), new SqlParameter("@c_payid", SqlDbType.Int, 4), new SqlParameter("@c_tradeno", SqlDbType.NVarChar, -1), new SqlParameter("@c_code", SqlDbType.NVarChar, -1), new SqlParameter("@c_money", SqlDbType.Decimal, 9), new SqlParameter("@c_times", SqlDbType.DateTime), new SqlParameter("@c_datimes", SqlDbType.DateTime) }; parameters[0].Value = model.c_tjtimes; parameters[1].Value = model.c_tjname; parameters[2].Value = model.c_clname; parameters[3].Value = model.c_cltimes; parameters[4].Value = model.c_result; parameters[5].Value = model.c_reason; parameters[6].Value = model.c_state; parameters[7].Value = model.c_appid; parameters[8].Value = model.c_userid; parameters[9].Value = model.c_payid; parameters[10].Value = model.c_tradeno; parameters[11].Value = model.c_code; parameters[12].Value = model.c_money; parameters[13].Value = model.c_times; parameters[14].Value = model.c_datimes; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_complaint model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_complaint set "); strSql.Append(" c_tjtimes = @c_tjtimes , "); strSql.Append(" c_tjname = @c_tjname , "); strSql.Append(" c_clname = @c_clname , "); strSql.Append(" c_cltimes = @c_cltimes , "); strSql.Append(" c_result = @c_result , "); strSql.Append(" c_reason = @c_reason , "); strSql.Append(" c_state = @c_state , "); strSql.Append(" c_appid = @c_appid , "); strSql.Append(" c_userid = @c_userid , "); strSql.Append(" c_payid = @c_payid , "); strSql.Append(" c_tradeno = @c_tradeno , "); strSql.Append(" c_code = @c_code , "); strSql.Append(" c_money = @c_money , "); strSql.Append(" c_times = @c_times , "); strSql.Append(" c_datimes = @c_datimes "); strSql.Append(" where c_id=@c_id "); SqlParameter[] parameters = { new SqlParameter("@c_id", SqlDbType.Int, 4), new SqlParameter("@c_tjtimes", SqlDbType.DateTime), new SqlParameter("@c_tjname", SqlDbType.NVarChar, 50), new SqlParameter("@c_clname", SqlDbType.NVarChar, 50), new SqlParameter("@c_cltimes", SqlDbType.DateTime), new SqlParameter("@c_result", SqlDbType.NVarChar, -1), new SqlParameter("@c_reason", SqlDbType.NVarChar, -1), new SqlParameter("@c_state", SqlDbType.Char, 10), new SqlParameter("@c_appid", SqlDbType.Int, 4), new SqlParameter("@c_userid", SqlDbType.Int, 4), new SqlParameter("@c_payid", SqlDbType.Int, 4), new SqlParameter("@c_tradeno", SqlDbType.NVarChar, -1), new SqlParameter("@c_code", SqlDbType.NVarChar, -1), new SqlParameter("@c_money", SqlDbType.Decimal, 9), new SqlParameter("@c_times", SqlDbType.DateTime), new SqlParameter("@c_datimes", SqlDbType.DateTime) }; parameters[0].Value = model.c_id; parameters[1].Value = model.c_tjtimes; parameters[2].Value = model.c_tjname; parameters[3].Value = model.c_clname; parameters[4].Value = model.c_cltimes; parameters[5].Value = model.c_result; parameters[6].Value = model.c_reason; parameters[7].Value = model.c_state; parameters[8].Value = model.c_appid; parameters[9].Value = model.c_userid; parameters[10].Value = model.c_payid; parameters[11].Value = model.c_tradeno; parameters[12].Value = model.c_code; parameters[13].Value = model.c_money; parameters[14].Value = model.c_times; parameters[15].Value = model.c_datimes; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_complaint GetModel(int c_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select c_id, c_tjtimes, c_tjname, c_clname, c_cltimes, c_result, c_reason, c_state, c_appid, c_userid, c_payid, c_tradeno, c_code, c_money, c_times, c_datimes "); strSql.Append(" from jmp_complaint "); strSql.Append(" where c_id=@c_id"); SqlParameter[] parameters = { new SqlParameter("@c_id", SqlDbType.Int, 4) }; parameters[0].Value = c_id; JMP.MDL.jmp_complaint model = new JMP.MDL.jmp_complaint(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["c_id"].ToString() != "") { model.c_id = int.Parse(ds.Tables[0].Rows[0]["c_id"].ToString()); } if (ds.Tables[0].Rows[0]["c_tjtimes"].ToString() != "") { model.c_tjtimes = DateTime.Parse(ds.Tables[0].Rows[0]["c_tjtimes"].ToString()); } model.c_tjname = ds.Tables[0].Rows[0]["c_tjname"].ToString(); model.c_clname = ds.Tables[0].Rows[0]["c_clname"].ToString(); if (ds.Tables[0].Rows[0]["c_cltimes"].ToString() != "") { model.c_cltimes = DateTime.Parse(ds.Tables[0].Rows[0]["c_cltimes"].ToString()); } model.c_result = ds.Tables[0].Rows[0]["c_result"].ToString(); model.c_reason = ds.Tables[0].Rows[0]["c_reason"].ToString(); model.c_state = ds.Tables[0].Rows[0]["c_state"].ToString(); if (ds.Tables[0].Rows[0]["c_appid"].ToString() != "") { model.c_appid = int.Parse(ds.Tables[0].Rows[0]["c_appid"].ToString()); } if (ds.Tables[0].Rows[0]["c_userid"].ToString() != "") { model.c_userid = int.Parse(ds.Tables[0].Rows[0]["c_userid"].ToString()); } if (ds.Tables[0].Rows[0]["c_payid"].ToString() != "") { model.c_payid = int.Parse(ds.Tables[0].Rows[0]["c_payid"].ToString()); } model.c_tradeno = ds.Tables[0].Rows[0]["c_tradeno"].ToString(); model.c_code = ds.Tables[0].Rows[0]["c_code"].ToString(); if (ds.Tables[0].Rows[0]["c_money"].ToString() != "") { model.c_money = decimal.Parse(ds.Tables[0].Rows[0]["c_money"].ToString()); } if (ds.Tables[0].Rows[0]["c_times"].ToString() != "") { model.c_times = DateTime.Parse(ds.Tables[0].Rows[0]["c_times"].ToString()); } if (ds.Tables[0].Rows[0]["c_datimes"].ToString() != "") { model.c_datimes = DateTime.Parse(ds.Tables[0].Rows[0]["c_datimes"].ToString()); } return(model); } else { return(null); } }