/// <summary> /// 比较当前对象和同一类型的另一对象。用于排序。 /// </summary> /// <param name="other">与此对象进行比较的对象。</param> /// <returns>一个 32 位有符号整数,指示要比较的对象的相对顺序。</returns> public int CompareTo(SysBu other) { int s = this.Sort.CompareTo(other.Sort); if (s == 0) { return(this.Code.CompareTo(other.Code)); } else { return(s); } }
public static void Delete(SysBu entry) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(String.Format(@"DELETE FROM {1} WHERE [Code] = N'{0}'", entry.Code, DataDictionaryEntryDa.GetDictionaryTableName(DictionaryName.SysBu))); try { db.ExecuteNonQuery(dbCommand); } catch (System.Data.SqlClient.SqlException sex) // 只捕获SqlException,其余抛出继续传播 { DBHelper.ParseSqlException(sex, true); } }
public static void Insert(SysBu entry) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(String.Format(@"INSERT INTO {6} VALUES (N'{0}', N'{1}', N'{2}', N'{3}', {4}, N'{5}', GETDATE(), 0)", entry.Code, entry.Title, entry.QrPrefixT, entry.LePrefixT, entry.Sort, entry.Updator, DataDictionaryEntryDa.GetDictionaryTableName(DictionaryName.SysBu))); try { db.ExecuteNonQuery(dbCommand); } catch (System.Data.SqlClient.SqlException sex) // 只捕获SqlException,其余抛出继续传播 { DBHelper.ParseSqlException(sex, false); } }
public static void Update(SysBu entry) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(String.Format(@"UPDATE {7} SET [Title] = N'{1}' ,[QrPrefix] = N'{2}' ,[LePrefix] = N'{3}' ,[Sort] = {4} ,[Optor] = N'{5}',[OpTime] = GETDATE(), [Deleted] = {6} WHERE [Code] = N'{0}'", entry.Code, entry.TitleT, entry.QrPrefixT, entry.LePrefixT, entry.SortT, entry.UpdatorT, entry.VisibleT ? 0 : 1, DataDictionaryEntryDa.GetDictionaryTableName(DictionaryName.SysBu))); try { db.ExecuteNonQuery(dbCommand); } catch (System.Data.SqlClient.SqlException sex) // 只捕获SqlException,其余抛出继续传播 { DBHelper.ParseSqlException(sex, false); } }
/// <summary> /// 比较当前对象和同一类型的另一对象。用于排序。 /// </summary> /// <param name="obj">与此对象进行比较的对象。</param> /// <returns>一个 32 位有符号整数,指示要比较的对象的相对顺序。</returns> /// <remarks>也可以添加一个范型实现。</remarks> public override int CompareTo(object obj) { if (obj is SysBu) { SysBu temp = (SysBu)obj; int s = this.Sort.CompareTo(temp.Sort); if (s == 0) { return(this.Code.CompareTo(temp.Code)); } else { return(s); } } throw new ArgumentException("object is not a SysBu"); }
/// <summary> /// 比较当前对象和同一类型的另一对象。用于排序。 /// </summary> /// <param name="other">与此对象进行比较的对象。</param> /// <returns>一个 32 位有符号整数,指示要比较的对象的相对顺序。</returns> public int CompareTo(SysBu other) { int s = this.Sort.CompareTo(other.Sort); if (s == 0) return this.Code.CompareTo(other.Code); else return s; }
public void Remove(SysBu entry) { SysBuDa.Delete(entry); }
public void Edit(SysBu entry) { SysBuDa.Update(entry); }
public void Add(SysBu entry) { SysBuDa.Insert(entry); }