/// <summary> /// 更新一条数据 /// </summary> public bool Update(university.Model.CCOM.Form_value model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Form_value set "); strSql.Append("User_id=@User_id,"); strSql.Append("Form_id=@Form_id,"); strSql.Append("Self_value=@Self_value,"); strSql.Append("Tea_value=@Tea_value"); strSql.Append(" where Fv_id=@Fv_id"); SqlParameter[] parameters = { new SqlParameter("@User_id", SqlDbType.BigInt, 8), new SqlParameter("@Form_id", SqlDbType.Int, 4), new SqlParameter("@Self_value", SqlDbType.Int, 4), new SqlParameter("@Tea_value", SqlDbType.Int, 4), new SqlParameter("@Fv_id", SqlDbType.BigInt, 8) }; parameters[0].Value = model.User_id; parameters[1].Value = model.Form_id; parameters[2].Value = model.Self_value; parameters[3].Value = model.Tea_value; parameters[4].Value = model.Fv_id; int rows = DBSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public long Add(university.Model.CCOM.Form_value model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Form_value("); strSql.Append("User_id,Form_id,Self_value,Tea_value)"); strSql.Append(" values ("); strSql.Append("@User_id,@Form_id,@Self_value,@Tea_value)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@User_id", SqlDbType.BigInt, 8), new SqlParameter("@Form_id", SqlDbType.Int, 4), new SqlParameter("@Self_value", SqlDbType.Int, 4), new SqlParameter("@Tea_value", SqlDbType.Int, 4) }; parameters[0].Value = model.User_id; parameters[1].Value = model.Form_id; parameters[2].Value = model.Self_value; parameters[3].Value = model.Tea_value; object obj = DBSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt64(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public university.Model.CCOM.Form_value DataRowToModel(DataRow row) { university.Model.CCOM.Form_value model = new university.Model.CCOM.Form_value(); if (row != null) { if (row["Fv_id"] != null && row["Fv_id"].ToString() != "") { model.Fv_id = long.Parse(row["Fv_id"].ToString()); } if (row["User_id"] != null && row["User_id"].ToString() != "") { model.User_id = long.Parse(row["User_id"].ToString()); } if (row["Form_id"] != null && row["Form_id"].ToString() != "") { model.Form_id = int.Parse(row["Form_id"].ToString()); } if (row["Self_value"] != null && row["Self_value"].ToString() != "") { model.Self_value = int.Parse(row["Self_value"].ToString()); } if (row["Tea_value"] != null && row["Tea_value"].ToString() != "") { model.Tea_value = int.Parse(row["Tea_value"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public university.Model.CCOM.Form_value GetModel(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Fv_id,User_id,Form_id,Self_value,Tea_value "); strSql.Append(" from Form_value "); strSql.Append(" where " + strWhere); university.Model.CCOM.Form_value model = new university.Model.CCOM.Form_value(); DataSet ds = DBSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Fv_id"] != null && ds.Tables[0].Rows[0]["Fv_id"].ToString() != "") { model.Fv_id = long.Parse(ds.Tables[0].Rows[0]["Fv_id"].ToString()); } if (ds.Tables[0].Rows[0]["User_id"] != null && ds.Tables[0].Rows[0]["User_id"].ToString() != "") { model.User_id = long.Parse(ds.Tables[0].Rows[0]["User_id"].ToString()); } if (ds.Tables[0].Rows[0]["Form_id"] != null && ds.Tables[0].Rows[0]["Form_id"].ToString() != "") { model.Form_id = int.Parse(ds.Tables[0].Rows[0]["Form_id"].ToString()); } if (ds.Tables[0].Rows[0]["Self_value"] != null && ds.Tables[0].Rows[0]["Self_value"].ToString() != "") { model.Self_value = int.Parse(ds.Tables[0].Rows[0]["Self_value"].ToString()); } if (ds.Tables[0].Rows[0]["Tea_value"] != null && ds.Tables[0].Rows[0]["Tea_value"].ToString() != "") { model.Tea_value = int.Parse(ds.Tables[0].Rows[0]["Tea_value"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public university.Model.CCOM.Form_value GetModel(long Fv_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Fv_id,User_id,Form_id,Self_value,Tea_value from Form_value "); strSql.Append(" where Fv_id=@Fv_id"); SqlParameter[] parameters = { new SqlParameter("@Fv_id", SqlDbType.BigInt) }; parameters[0].Value = Fv_id; university.Model.CCOM.Form_value model = new university.Model.CCOM.Form_value(); DataSet ds = DBSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }