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