/// <summary> /// (Overrided) Loads the List with the supplied Key /// </summary> /// <param name="Keys"> /// Key object to use /// </param> public override void Load(ClsKeys Keys = null) { if (Keys == null) { this.New(); } else { ClsQueryCondition Qc = this.mDa.CreateQueryCondition(); foreach (string KeyName in Keys.pName) { Qc.Add(KeyName, Keys[KeyName].ToString(), typeof(Int64).ToString(), "0"); } if (this.mQc_LoadCondition != null) { foreach (Layer01_Common.Objects.ClsQueryCondition.Str_QueryCondition Str_Qc in this.mQc_LoadCondition.pList) { Qc.pList.Add(Str_Qc); } } this.Load(Qc); } }
public static bool CheckSeriesDuplicate( string TableName , string SeriesField , ClsKeys Keys , string SeriesNo) { bool Rv = false; DataTable Dt; System.Text.StringBuilder Sb_Query_Key = new StringBuilder(); string Query_Key = ""; string Query_And = ""; foreach (string Inner_Key in Keys.pName) { Sb_Query_Key.Append(Query_And + " " + Inner_Key + " = " + Keys[Inner_Key]); Query_And = " And "; } Query_Key = " 1 = 1 "; if (Sb_Query_Key.ToString() != "") { Query_Key = "(Not (" + Sb_Query_Key.ToString() + "))"; } Dt = new ClsBase().pDa.GetQuery( "[" + TableName + "]" , "Count(1) As [Ct]" , Query_Key + " And " + SeriesField + " = '" + SeriesNo + "'"); if (Dt.Rows.Count > 0) { if ((Int32)Dt.Rows[0][0] > 0) { Rv = true; } } //True means duplicates have been found return Rv; }
/// <summary> /// Loads the detail table /// </summary> /// <param name="Da"> /// An open DataAccess from calling method /// </param> /// <param name="Keys"> /// Key Object to use /// </param> public void Load(Interface_DataAccess Da, ClsKeys Keys) { this.mDt = Da.Load_TableDetails(this.mViewName, Keys, this.mOtherLoadCondition); }
public DataTable Load_TableDetails(string ObjectName, ClsKeys Keys, string Condition) { StringBuilder Sb_Condition = new StringBuilder(); DataTable Dt; if (Keys == null) { Dt = this.GetQuery(this.Connection, ObjectName, "*", "1 = 0"); } else { string Inner_Condition_And = ""; bool IsStart = false; foreach (string Inner_Key in Keys.pName) { Sb_Condition.Append(Inner_Condition_And + " " + Inner_Key + " = " + Keys[Inner_Key]); if (!IsStart) Inner_Condition_And = " And "; IsStart = true; } string OtherCondition = ""; if (Condition != "") OtherCondition = " And " + Condition; Dt = this.GetQuery(this.Connection, ObjectName, "*", Sb_Condition.ToString() + OtherCondition); } return Dt; }
public DataRow Load(string ObjectName, List<string> List_Key, ClsKeys Keys) { DataTable Dt; DataRow Dr; if (Keys == null) { Dr = this.GetQuery(this.Connection, ObjectName, "*", "1 = 0").NewRow(); } else { StringBuilder Sb_Condition = new StringBuilder(); if (Keys.Count() != List_Key.Count) { throw new Exception("Keys not equal to required keys."); } Sb_Condition.Append(" 1 = 1 "); foreach (string Inner_Key in List_Key) { Sb_Condition.Append(" And " + Inner_Key + " = " + Keys[Inner_Key]); } Dt = this.GetQuery(this.Connection, ObjectName, "*", Sb_Condition.ToString()); if (Dt.Rows.Count > 0) { Dr = Dt.Rows[0]; } else { throw new ClsCustomException("Record not found."); } } return Dr; }
//[-] /// <summary> /// (Overridable) Loads the Data Object with the supplied Key /// </summary> /// <param name="Keys"> /// Key object to use /// </param> public virtual void Load(ClsKeys Keys = null) { try { this.mDa.Connect(); //[-] this.mHeader_Dr = this.mDa.Load(this.mHeader_ViewName, this.mHeader_Key, Keys); //[-] if (this.mBase_TableDetail != null) { foreach (ClsBaseTableDetail Inner_Obj in this.mBase_TableDetail) { Inner_Obj.Load(this.mDa, Keys); } } //[-] if (this.mBase_RowDetail != null) { foreach (ClsBaseRowDetail Inner_Obj in this.mBase_RowDetail) { Inner_Obj.Load(this.mDa, Keys); } } //[-] this.AddRequired(); } catch (Exception Ex) { throw Ex; } finally { this.mDa.Close(); } }
/// <summary> /// Gets the Keys of the supplier datarow using the supplier Key Definition /// </summary> /// <param name="Dr"> /// Source datarow /// </param> /// <param name="KeyNames"> /// Key definition /// </param> /// <returns></returns> public ClsKeys GetKeys(DataRow Dr, List<string> KeyNames) { bool IsFound = false; ClsKeys Key = new ClsKeys(); foreach (string Inner_Key in KeyNames) { if (!Information.IsDBNull(Dr[Inner_Key])) { Key.Add(Inner_Key, (Int64)Layer01_Methods.IsNull(Dr[Inner_Key], 0)); } else { IsFound = true; break; } } if (IsFound) { Key = null; } return Key; }
/// <summary> /// Gets the Keys of the supplied row using the Key Definition of the Data Object /// </summary> /// <param name="Dr"> /// Source datarow, mostly the same definition as from Me.List() /// </param> /// <returns></returns> public ClsKeys GetKeys(DataRow Dr) { ClsKeys Obj = new ClsKeys(); foreach (string Key in this.mHeader_Key) { Int64 ID = (Int64)Layer01_Methods.IsNull(Dr[Key], 0); Obj.Add(Key, ID); } return Obj; }
//[-] /// <summary> /// Gets the current Keys of the Data Object /// </summary> /// <returns></returns> public ClsKeys GetKeys() { ClsKeys Obj = new ClsKeys(); foreach (string Key in this.mHeader_Key) { Int64 ID = Convert.ToInt64(Layer01_Methods.IsNull(this.mHeader_Dr[Key], 0)); Obj.Add(Key, ID); } return Obj; }