/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.complian model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + databaseprefix + "complian set "); strSql.Append("order_no=@order_no,"); strSql.Append("user_id=@user_id,"); strSql.Append("user_name=@user_name,"); strSql.Append("complian_title=@complian_title,"); strSql.Append("complian_time=@complian_time,"); strSql.Append("complian_content=@complian_content,"); strSql.Append("mobile_phone=@mobile_phone,"); strSql.Append("is_status=@is_status,"); strSql.Append("is_anonymous=@is_anonymous,"); strSql.Append("parent_id=@parent_id,"); strSql.Append("com_type=@com_type,"); strSql.Append("good_id=@good_id"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@order_no", SqlDbType.NVarChar, 100), new SqlParameter("@user_id", SqlDbType.Int, 10), new SqlParameter("@user_name", SqlDbType.NVarChar, 100), new SqlParameter("@complian_title", SqlDbType.NVarChar, 100), new SqlParameter("@complian_time", SqlDbType.DateTime), new SqlParameter("@complian_content", SqlDbType.NVarChar, 500), new SqlParameter("@mobile_phone", SqlDbType.VarChar, 11), new SqlParameter("@is_status", SqlDbType.TinyInt, 1), new SqlParameter("@is_anonymous", SqlDbType.TinyInt, 1), new SqlParameter("@parent_id", SqlDbType.TinyInt, 1), new SqlParameter("@com_type", SqlDbType.TinyInt, 1), new SqlParameter("@good_id", SqlDbType.Int, 10), new SqlParameter("@id", SqlDbType.Int, 10) }; parameters[0].Value = model.order_no; parameters[1].Value = model.user_id; parameters[2].Value = model.user_name; parameters[3].Value = model.complian_title; parameters[4].Value = model.complian_time; parameters[5].Value = model.complian_content; parameters[6].Value = model.mobile_phone; parameters[7].Value = model.is_status; parameters[8].Value = model.is_anonymous; parameters[9].Value = model.parent_id; parameters[10].Value = model.com_type; parameters[11].Value = model.good_id; parameters[12].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据,及其子表数据 /// </summary> public int Add(Model.complian model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "complian("); strSql.Append(" user_id,user_name,complian_title,complian_time,complian_content,mobile_phone,is_status,is_anonymous,parent_id,com_type,good_id,target,order_no,reply_content)"); strSql.Append(" values ("); strSql.Append("@user_id,@user_name,@complian_title,@complian_time,@complian_content,@mobile_phone,@is_status,@is_anonymous,@parent_id,@com_type,@good_id,@target,@order_no,@reply_content)"); strSql.Append(";set @ReturnValue= @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@user_id", SqlDbType.Int, 10), new SqlParameter("@user_name", SqlDbType.NVarChar, 100), new SqlParameter("@complian_title", SqlDbType.NVarChar, 100), new SqlParameter("@complian_time", SqlDbType.DateTime), new SqlParameter("@complian_content", SqlDbType.NVarChar, 500), new SqlParameter("@mobile_phone", SqlDbType.VarChar, 11), new SqlParameter("@is_status", SqlDbType.TinyInt, 1), new SqlParameter("@is_anonymous", SqlDbType.TinyInt, 1), new SqlParameter("@parent_id", SqlDbType.TinyInt, 1), new SqlParameter("@com_type", SqlDbType.TinyInt, 1), new SqlParameter("@good_id", SqlDbType.Int, 10), new SqlParameter("@target", SqlDbType.NVarChar, 500), new SqlParameter("@order_no", SqlDbType.NVarChar, 500), new SqlParameter("@reply_content", SqlDbType.NVarChar, 500), new SqlParameter("@ReturnValue", SqlDbType.Int) }; parameters[0].Value = model.user_id; parameters[1].Value = model.user_name; parameters[2].Value = model.complian_title; parameters[3].Value = model.complian_time; parameters[4].Value = model.complian_content; parameters[5].Value = model.mobile_phone; parameters[6].Value = model.is_status; parameters[7].Value = model.is_anonymous; parameters[8].Value = model.parent_id; parameters[9].Value = model.com_type; parameters[10].Value = model.good_id; parameters[11].Value = model.target; parameters[12].Value = model.order_no; parameters[13].Value = model.reply_content; parameters[14].Direction = ParameterDirection.Output; List <CommandInfo> sqllist = new List <CommandInfo>(); CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(cmd); DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist); int id = (int)parameters[14].Value; return(id); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.complian GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,user_id,user_name,complian_title,complian_time,complian_content,mobile_phone,is_status,is_anonymous,parent_id,com_type,good_id"); strSql.Append(" from " + databaseprefix + "complian "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 10) }; parameters[0].Value = id; Model.complian model = new Model.complian(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { #region 表信息 if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["user_id"].ToString() != "") { model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString()); } if (ds.Tables[0].Rows[0]["complian_title"].ToString() != "") { model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString(); } if (ds.Tables[0].Rows[0]["complian_title"].ToString() != "") { model.complian_title = ds.Tables[0].Rows[0]["complian_title"].ToString(); } if (ds.Tables[0].Rows[0]["complian_time"].ToString() != "") { model.complian_time = DateTime.Parse(ds.Tables[0].Rows[0]["complian_time"].ToString()); } if (ds.Tables[0].Rows[0]["complian_content"].ToString() != "") { model.complian_content = ds.Tables[0].Rows[0]["complian_content"].ToString(); } if (ds.Tables[0].Rows[0]["mobile_phone"].ToString() != "") { model.mobile_phone = ds.Tables[0].Rows[0]["mobile_phone"].ToString(); } if (ds.Tables[0].Rows[0]["is_status"].ToString() != "") { model.is_status = int.Parse(ds.Tables[0].Rows[0]["is_status"].ToString()); } if (ds.Tables[0].Rows[0]["is_anonymous"].ToString() != "") { model.is_anonymous = int.Parse(ds.Tables[0].Rows[0]["is_anonymous"].ToString()); } if (ds.Tables[0].Rows[0]["parent_id"].ToString() != "") { model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString()); } if (ds.Tables[0].Rows[0]["com_type"].ToString() != "") { model.com_type = int.Parse(ds.Tables[0].Rows[0]["com_type"].ToString()); } if (ds.Tables[0].Rows[0]["good_id"].ToString() != "") { model.good_id = int.Parse(ds.Tables[0].Rows[0]["good_id"].ToString()); } #endregion return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.complian model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.complian model) { return(dal.Add(model)); }
protected void Page_Load(object sender, EventArgs e) { model = new BuysingooShop.BLL.complian().GetModel(Vincent._DTcms.DTRequest.GetQueryInt("id")); }