/// /// 插入一个XT_DICDEPART实体到数据库。 /// /// 将要插入的实体 public int InsertEntity(DataSetXT_DICDEPART entity) { CheckData(entity); int iRtn = 0; bool isExistTrans = db.IsInTransaction(); if (!isExistTrans) { db.BeginTrans(); } try { foreach (DataRow row in entity.Tables["XT_XT_DICDEPART"].Rows) { int j = db.exeSql(new SS_XT_DICDEPART_InsertXT_XT_DICDEPART(), row); iRtn = iRtn + j; } if (!isExistTrans) { db.CommitTrans(); } return(iRtn); } catch (Exception e) { if (!isExistTrans) { db.RollbackTrans(); } throw e; } }
///////////// #endregion //// 2006-09-11 public DataSetXT_DICDEPART GetDataSet(SqlClass sC, string sTableName) { DataSetXT_DICDEPART ds = new DataSetXT_DICDEPART(); db.FillDataSet(sC, ds, sTableName); return(ds); }
} // Data_SelectByIDXT_XT_DICDEPART #endregion #region Data_XT_DICDEPART_SelectAll /// /// 对于SelectAll的类的实现(数据库操作)。 /// public DataSetXT_DICDEPART Data_XT_DICDEPART_SelectAll(string sTj) { DataSetXT_DICDEPART ds = new DataSetXT_DICDEPART(); SS_XT_DICDEPART_SelectAll ss = new SS_XT_DICDEPART_SelectAll(); ss.SqlString = ss.SqlString.Replace("1=1", sTj); db.FillDataSet(ss, ds, "XT_XT_DICDEPART"); return(ds); } // Data_SelectAll
//wuqb modify 2007-03-27 //强名DataSet #region Data_XT_DICDEPART_SelectByIDXT_XT_DICDEPART /// /// 对于SelectByIDXT_XT_DICDEPART的类的实现(数据库操作)。 /// public DataSetXT_DICDEPART Data_XT_DICDEPART_SelectByIDXT_XT_DICDEPART(System.String VDEPARTCODE) { DataSetXT_DICDEPART ds = new DataSetXT_DICDEPART(); SS_XT_DICDEPART_SelectByIDXT_XT_DICDEPART ss = new SS_XT_DICDEPART_SelectByIDXT_XT_DICDEPART(); ss.VDEPARTCODE = VDEPARTCODE; db.FillDataSet(ss, ds, "XT_XT_DICDEPART"); return(ds); } // Data_SelectByIDXT_XT_DICDEPART
/// /// 检查给定的实体是否有给定状态的更改,如果有把更改的行提交到数据库。 /// /// 要检验的实体 /// 要检查更改的状态 /// 2006-05-21 public int CommitChanges(DataSetXT_DICDEPART entity, DataRowState drs, ArrayList alUpdateColumn, ArrayList alUpdateControl) { db.SetUpdateControl(alUpdateControl); db.SetUpdateColumn(alUpdateColumn); int iRet = CommitChanges(entity, drs); db.SetUpdateControl(null); db.SetUpdateColumn(null); return(iRet); }
/// /// 按照XT_DICDEPART实体的主表的主键查询数据。 /// /// 主键的值 public DataSetXT_DICDEPART FindByPrimaryKey(object KeyValue) { DataSetXT_DICDEPART entity = new DataSetXT_DICDEPART(); SS_XT_DICDEPART_SelectByIDXT_XT_DICDEPART ss = new SS_XT_DICDEPART_SelectByIDXT_XT_DICDEPART(); ss.Params[0].Value = KeyValue; db.FillDataSet(ss, entity, "XT_XT_DICDEPART"); return(entity); }
///////////////// public int CommitChanges(DataSetXT_DICDEPART entity, DataRowState drs) { int iRtn = 0; if (!entity.HasChanges(drs)) { return(iRtn); } CheckData(entity); bool isExistTrans = db.IsInTransaction(); if (!isExistTrans) { db.BeginTrans(); } try { if (drs == DataRowState.Deleted) { iRtn += DeleteEntity(entity.GetChangesEntity(drs)); } else if (drs == DataRowState.Modified) { iRtn += UpdateEntity(entity.GetChangesEntity(drs)); } else if (drs == DataRowState.Added) { iRtn += InsertEntity(entity.GetChangesEntity(drs)); } if (!isExistTrans) { db.CommitTrans(); } return(iRtn); } catch (Exception e) { if (isExistTrans) { db.RollbackTrans(); } throw e; } }
/// /// 检查给定的实体是否有更改,如果有把更改的行提交到数据库。 /// /// 要检验的实体 public int CommitChanges(DataSetXT_DICDEPART entity) { int iRtn = 0; if (!entity.HasChanges()) { return(iRtn); } CheckData(entity); bool isExistTrans = db.IsInTransaction(); if (!isExistTrans) { db.BeginTrans(); } try { //CommitChanges(entity, DataRowState.Deleted); //CommitChanges(entity, DataRowState.Modified); //CommitChanges(entity, DataRowState.Added); ////////// 2006-05-21 iRtn += CommitChanges(entity, DataRowState.Deleted, null, null); iRtn += CommitChanges(entity, DataRowState.Modified, alUpdateColumn, alUpdateControl); iRtn += CommitChanges(entity, DataRowState.Added, null, null); ///////////// if (!isExistTrans) { db.CommitTrans(); } return(iRtn); } catch (Exception e) { if (isExistTrans) { db.RollbackTrans(); } throw e; } }
/// /// 校验数据输入的有效性。 /// /// 要检验的实体 protected void CheckData(DataSetXT_DICDEPART entity) { //在这里可以加入操作之前所需要对实体检验的代码 }
/// 2006-05-21 /// public int CommitChanges(DataSetXT_DICDEPART entity, ArrayList alUpdateColumn, ArrayList alUpdateControl) { this.alUpdateColumn = alUpdateColumn; this.alUpdateControl = alUpdateControl; return(CommitChanges(entity)); }