/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_rate GetModel(int r_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select r_id, r_userid, r_paymodeid, r_proportion, r_klproportion, r_state, r_time, r_name "); strSql.Append(" from jmp_rate "); strSql.Append(" where r_id=@r_id"); SqlParameter[] parameters = { new SqlParameter("@r_id", SqlDbType.Int, 4) }; parameters[0].Value = r_id; JMP.MDL.jmp_rate model = new JMP.MDL.jmp_rate(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["r_id"].ToString() != "") { model.r_id = int.Parse(ds.Tables[0].Rows[0]["r_id"].ToString()); } if (ds.Tables[0].Rows[0]["r_userid"].ToString() != "") { model.r_userid = int.Parse(ds.Tables[0].Rows[0]["r_userid"].ToString()); } if (ds.Tables[0].Rows[0]["r_paymodeid"].ToString() != "") { model.r_paymodeid = int.Parse(ds.Tables[0].Rows[0]["r_paymodeid"].ToString()); } if (ds.Tables[0].Rows[0]["r_proportion"].ToString() != "") { model.r_proportion = decimal.Parse(ds.Tables[0].Rows[0]["r_proportion"].ToString()); } if (ds.Tables[0].Rows[0]["r_klproportion"].ToString() != "") { model.r_klproportion = decimal.Parse(ds.Tables[0].Rows[0]["r_klproportion"].ToString()); } if (ds.Tables[0].Rows[0]["r_state"].ToString() != "") { model.r_state = int.Parse(ds.Tables[0].Rows[0]["r_state"].ToString()); } if (ds.Tables[0].Rows[0]["r_time"].ToString() != "") { model.r_time = DateTime.Parse(ds.Tables[0].Rows[0]["r_time"].ToString()); } model.r_name = ds.Tables[0].Rows[0]["r_name"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 获得数据列表 /// </summary> public List <JMP.MDL.jmp_rate> DataTableToList(DataTable dt) { List <JMP.MDL.jmp_rate> modelList = new List <JMP.MDL.jmp_rate>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { JMP.MDL.jmp_rate model; for (int n = 0; n < rowsCount; n++) { model = new JMP.MDL.jmp_rate(); if (dt.Rows[n]["r_id"].ToString() != "") { model.r_id = int.Parse(dt.Rows[n]["r_id"].ToString()); } if (dt.Rows[n]["r_userid"].ToString() != "") { model.r_userid = int.Parse(dt.Rows[n]["r_userid"].ToString()); } if (dt.Rows[n]["r_paymodeid"].ToString() != "") { model.r_paymodeid = int.Parse(dt.Rows[n]["r_paymodeid"].ToString()); } if (dt.Rows[n]["r_proportion"].ToString() != "") { model.r_proportion = decimal.Parse(dt.Rows[n]["r_proportion"].ToString()); } if (dt.Rows[n]["r_klproportion"].ToString() != "") { model.r_klproportion = decimal.Parse(dt.Rows[n]["r_klproportion"].ToString()); } if (dt.Rows[n]["r_state"].ToString() != "") { model.r_state = int.Parse(dt.Rows[n]["r_state"].ToString()); } if (dt.Rows[n]["r_time"].ToString() != "") { model.r_time = DateTime.Parse(dt.Rows[n]["r_time"].ToString()); } model.r_name = dt.Rows[n]["r_name"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_rate model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_rate set "); strSql.Append(" r_userid = @r_userid , "); strSql.Append(" r_paymodeid = @r_paymodeid , "); strSql.Append(" r_proportion = @r_proportion , "); strSql.Append(" r_klproportion = @r_klproportion , "); strSql.Append(" r_state = @r_state , "); strSql.Append(" r_time = @r_time , "); strSql.Append(" r_name = @r_name "); strSql.Append(" where r_id=@r_id "); SqlParameter[] parameters = { new SqlParameter("@r_id", SqlDbType.Int, 4), new SqlParameter("@r_userid", SqlDbType.Int, 4), new SqlParameter("@r_paymodeid", SqlDbType.Int, 4), new SqlParameter("@r_proportion", SqlDbType.Decimal, 9), new SqlParameter("@r_klproportion", SqlDbType.Decimal, 9), new SqlParameter("@r_state", SqlDbType.Int, 4), new SqlParameter("@r_time", SqlDbType.DateTime), new SqlParameter("@r_name", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.r_id; parameters[1].Value = model.r_userid; parameters[2].Value = model.r_paymodeid; parameters[3].Value = model.r_proportion; parameters[4].Value = model.r_klproportion; parameters[5].Value = model.r_state; parameters[6].Value = model.r_time; parameters[7].Value = model.r_name; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_rate model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_rate("); strSql.Append("r_userid,r_paymodeid,r_proportion,r_klproportion,r_state,r_time,r_name"); strSql.Append(") values ("); strSql.Append("@r_userid,@r_paymodeid,@r_proportion,@r_klproportion,@r_state,@r_time,@r_name"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@r_userid", SqlDbType.Int, 4), new SqlParameter("@r_paymodeid", SqlDbType.Int, 4), new SqlParameter("@r_proportion", SqlDbType.Decimal, 9), new SqlParameter("@r_klproportion", SqlDbType.Decimal, 9), new SqlParameter("@r_state", SqlDbType.Int, 4), new SqlParameter("@r_time", SqlDbType.DateTime), new SqlParameter("@r_name", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.r_userid; parameters[1].Value = model.r_paymodeid; parameters[2].Value = model.r_proportion; parameters[3].Value = model.r_klproportion; parameters[4].Value = model.r_state; parameters[5].Value = model.r_time; parameters[6].Value = model.r_name; 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_rate model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_rate model) { return(dal.Add(model)); }