public virtual bool Save() { bool IsSave = false; ClsDataAccess Da = new ClsDataAccess(); try { Da.Connect(); Da.BeginTransaction(); Da.SaveDataRow(this.mHeader_Dr, this.mHeader_TableName); //[-] if (this.mBase_TableDetail != null) { foreach (ClsBaseTableDetail Inner_Obj in this.mBase_TableDetail) { Inner_Obj.Save(Da); } } //[-] if (this.mBase_RowDetail != null) { foreach (ClsBaseRowDetail Inner_Obj in this.mBase_RowDetail) { Inner_Obj.Save(Da); } } //[-] Da.CommitTransaction(); IsSave = true; } catch (Exception ex) { Da.RollbackTransaction(); throw ex; } finally { Da.Close(); } return(IsSave); }
//[-] public virtual void Load(ClsKeys Keys = null) { ClsDataAccess Da = new ClsDataAccess(); StringBuilder Sb_Condition = new StringBuilder(); string Condition = ""; try { if (Keys != null) { if (Keys.Count() != this.mHeader_Key.Count) { throw new Exception("Keys not equal to required keys."); } string Inner_Condition_And = ""; bool IsStart = false; foreach (string Inner_Key in this.mHeader_Key) { Sb_Condition.Append(Inner_Condition_And + " " + Inner_Key + " = " + Keys[Inner_Key]); if (!IsStart) { Inner_Condition_And = " And "; } IsStart = true; } } Condition = Sb_Condition.ToString(); Da.Connect(); DataTable Dt; DataRow Dr; if (Keys == null) { Dt = Methods_Query.GetQuery(Da, this.mHeader_ViewName, "*", "1 = 0"); Dr = Dt.NewRow(); } else { Dt = Methods_Query.GetQuery(Da, this.mHeader_ViewName, "*", Condition); Dr = Dt.Rows[0]; } this.mHeader_Dr = Dr; //[-] if (this.mBase_TableDetail != null) { foreach (ClsBaseTableDetail Inner_Obj in this.mBase_TableDetail) { Inner_Obj.Load(Da, Condition); } } //[-] if (this.mBase_RowDetail != null) { foreach (ClsBaseRowDetail Inner_Obj in this.mBase_RowDetail) { Inner_Obj.Load(Da, Condition); } } //[-] this.AddRequired(); } catch { } }