/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Yo_Jurisdiction model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Yo_Jurisdiction set "); strSql.Append("JurisdictionName=@JurisdictionName,"); strSql.Append("Note=@Note,"); strSql.Append("ActionName=@ActionName,"); strSql.Append("IsLock=@IsLock"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@JurisdictionName", SqlDbType.NVarChar, 50), new SqlParameter("@Note", SqlDbType.NVarChar, 200), new SqlParameter("@ActionName", SqlDbType.NVarChar, 50), new SqlParameter("@IsLock", SqlDbType.Bit, 1), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.JurisdictionName; parameters[1].Value = model.Note; parameters[2].Value = model.ActionName; parameters[3].Value = model.IsLock; parameters[4].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Yo_Jurisdiction DataRowToModel(DataRow row) { Maticsoft.Model.Yo_Jurisdiction model = new Maticsoft.Model.Yo_Jurisdiction(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["JurisdictionName"] != null) { model.JurisdictionName = row["JurisdictionName"].ToString(); } if (row["Note"] != null) { model.Note = row["Note"].ToString(); } if (row["ActionName"] != null) { model.ActionName = row["ActionName"].ToString(); } if (row["IsLock"] != null && row["IsLock"].ToString() != "") { if ((row["IsLock"].ToString() == "1") || (row["IsLock"].ToString().ToLower() == "true")) { model.IsLock = true; } else { model.IsLock = false; } } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.Yo_Jurisdiction model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Yo_Jurisdiction("); strSql.Append("JurisdictionName,Note,ActionName,IsLock)"); strSql.Append(" values ("); strSql.Append("@JurisdictionName,@Note,@ActionName,@IsLock)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@JurisdictionName", SqlDbType.NVarChar, 50), new SqlParameter("@Note", SqlDbType.NVarChar, 200), new SqlParameter("@ActionName", SqlDbType.NVarChar, 50), new SqlParameter("@IsLock", SqlDbType.Bit, 1) }; parameters[0].Value = model.JurisdictionName; parameters[1].Value = model.Note; parameters[2].Value = model.ActionName; parameters[3].Value = model.IsLock; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Yo_Jurisdiction GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,JurisdictionName,Note,ActionName,IsLock from Yo_Jurisdiction "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Maticsoft.Model.Yo_Jurisdiction model = new Maticsoft.Model.Yo_Jurisdiction(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }