protected Int64 List_Count(QueryCondition Condition = null) { DataRow Dr_Bind = Do_Methods_Query.GetSystemBindDefinition(this.mSystem_BinDefinition_Name); string Bind_Condition = (string)Do_Methods.IsNull(Dr_Bind["Condition"], ""); string Bind_Sort = (string)Do_Methods.IsNull(Dr_Bind["Sort"], ""); string Query_Condition = ""; if (Bind_Condition.Trim() != "") { Query_Condition = " Where " + Bind_Condition; } string Source = (string)this.ViewState[CnsSource]; if (Source == "") { Source = this.mObj_Base.pHeader_ViewName; } string Query = @"(Select * From " + Source + " " + Query_Condition + " ) As [Tb]"; Interface_DataAccess Da = this.mObj_Base.CreateDataAccess(); //DataTable Dt = Do_Methods_Query.GetQuery(Query, "Count(1) As [Ct]", Condition); DataTable Dt = Da.GetQuery(Query, "Count(1) As [Ct]", Condition); Int64 Rv = 0; try { Rv = Convert.ToInt64(Do_Methods.IsNull(Dt.Rows[0]["Ct"], 0)); } catch { } return(Rv); }
public ClsBaseRowDetail( ClsBase pObj_Base , string pHeaderName , string pTableName , string pViewName = "" , string pOtherLoadCondition = "" , List<string> CustomKeys = null , List<Do_Constants.Str_ForeignKeyRelation> ForeignKeys = null) { if (pViewName == "") pViewName = pTableName; this.mHeaderName = pHeaderName; this.mTableName = pTableName; this.mViewName = pViewName; this.mOtherLoadCondition = pOtherLoadCondition; this.mList_ForeignKey = ForeignKeys; this.mObj_Base = pObj_Base; this.mDa = pObj_Base.pDa; this.mIsCustomKeys = CustomKeys != null; if (CustomKeys == null) { DataTable Dt_Def = this.mDa.GetTableDef(this.mTableName); DataRow[] ArrDr = Dt_Def.Select("IsPk = 1"); foreach (DataRow Dr in ArrDr) { this.mList_Key.Add((string)Dr["ColumnName"]); } } else { this.mList_Key = CustomKeys; } }
public void UpdatePriceHistory(Int64 ItemID) { DataTable Dt_Item = Do_Methods_Query.GetQuery("Item", "", "ItemID = " + ItemID); DataRow Dr_Item = null; if (Dt_Item.Rows.Count > 0) { Dr_Item = Dt_Item.Rows[0]; } else { return; } DateTime ServerDate = Layer02_Common.GetServerDate(); DataTable Dt_PriceHistory = Do_Methods_Query.GetQuery("Item_PriceHistory", "", "1 = 0"); DataRow Dr_PriceHistory = Dt_PriceHistory.NewRow(); Dr_PriceHistory["ItemID"] = ItemID; Dr_PriceHistory["Price"] = Dr_Item["Price"]; Dr_PriceHistory["EmployeeID_PostedBy"] = this.mCurrentUser.pDrUser["EmployeeID"]; Dr_PriceHistory["DatePosted"] = ServerDate; Interface_DataAccess Da = Do_Methods.CreateDataAccess(); try { Da.Connect(); Da.SaveDataRow(Dr_PriceHistory, "Item_PriceHistory"); } catch { } finally { Da.Close(); } }
public override DataTable List(string Condition = "", string Sort = "") { Interface_DataAccess Da = this.CreateDataAccess(); try { return(base.List(Da, Condition, Sort)); } catch (Exception Ex) { throw Ex; } finally { Da.Close(); } }
public override DataTable List(DataObjects_Framework.Objects.QueryCondition Condition, string Sort = "", int Top = 0, int Page = 0) { Interface_DataAccess Da = this.CreateDataAccess(); try { return(base.List(Da, Condition, Sort, Top, Page)); } catch (Exception Ex) { throw Ex; } finally { Da.Close(); } }
public override bool Save(Interface_DataAccess Da = null) { //foreach (ClsBaseObjs.Str_Obj Obj in this.mBO_Details_Person.pList_Obj) //{ // Obj.Obj.Save(); // DataRow[] Inner_ArrDr = this.pDt_ContactPerson.Select("TmpKey = " + Obj.Name); // if (Inner_ArrDr.Length > 0) // { Inner_ArrDr[0]["PersonID"] = Obj.Obj.pDr["PersonID"]; } //} return(base.Save(Da)); }
public override bool Save(Interface_DataAccess Da = null) { //foreach (ClsBaseObjs.Str_Obj Obj in this.mBO_Details_Person.pList_Obj) //{ // Obj.Obj.Save(); // DataRow[] Inner_ArrDr = this.pDt_ContactPerson.Select("TmpKey = " + Obj.Name); // if (Inner_ArrDr.Length > 0) // { Inner_ArrDr[0]["PersonID"] = Obj.Obj.pDr["PersonID"]; } //} return base.Save(Da); }
public static DateTime GetServerDate(Interface_DataAccess Da) { DataTable Dt = Da.ExecuteQuery("Select GetDate() As ServerDate").Tables[0]; if (Dt.Rows.Count > 0) { return((DateTime)Dt.Rows[0][0]); } else { return(DateTime.Now); } }
public Interface_DataAccess CreateDataAccess() { Interface_DataAccess Da = Do_Methods.CreateDataAccess(); try { if (this.mIsCache) { Da.Connect(Do_Methods.Convert_String(Do_Globals.gSettings.pCollection[Layer01_Constants.CnsConnectionString_Cache])); } else { Da.Connect(); } } catch (Exception Ex) { throw Ex; } return(Da); }
public override void Load(Keys Keys, DataObjects_Framework.BaseObjects.Base Obj_Parent = null) { Interface_DataAccess Da = Do_Methods.CreateDataAccess(); try { if (this.mIsCache) { Da.Connect(Do_Methods.Convert_String(Do_Globals.gSettings.pCollection[Layer01_Constants.CnsConnectionString_Cache])); } else { Da.Connect(); } base.Load(Da, Keys, Obj_Parent); } catch (Exception Ex) { throw Ex; } finally { Da.Close(); } }
/// <summary> /// Constructor for this class /// </summary> /// <param name="Obj_Base"> /// Parent Object Base /// </param> /// <param name="HeaderName"> /// Parent Table Name, (apparently not used at all) /// </param> /// <param name="TableName"> /// Detail Table Name /// </param> /// <param name="ViewName"> /// Detail View Name /// </param> /// <param name="OtherLoadCondition"> /// Additional conditions for fetching /// </param> public ClsBaseTableDetail( ClsBase Obj_Base , string HeaderName , string TableName , string ViewName = "" , string OtherLoadCondition = "") { if (ViewName == "") ViewName = TableName; this.mHeaderName = HeaderName; this.mTableName = TableName; this.mViewName = ViewName; this.mOtherLoadCondition = OtherLoadCondition; this.mObj_Base = Obj_Base; this.mDa = Obj_Base.pDa; DataTable Dt_Def = this.mDa.GetTableDef(this.mTableName); DataRow[] ArrDr = Dt_Def.Select("IsPk = 1"); foreach (DataRow Dr in ArrDr) { this.mList_Key.Add((string)Dr["ColumnName"]); } }
//[-] protected DataTable List( QueryCondition Condition = null , string Sort = "" , Int64 Top = 0 , Int32 Page = 0) { DataRow Dr_Bind = Do_Methods_Query.GetSystemBindDefinition(this.mSystem_BinDefinition_Name); string Bind_Condition = (string)Do_Methods.IsNull(Dr_Bind["Condition"], ""); string Bind_Sort = (string)Do_Methods.IsNull(Dr_Bind["Sort"], ""); string Query_Condition = ""; if (Bind_Condition.Trim() != "") { Query_Condition = " Where " + Bind_Condition; } string Source = (string)this.ViewState[CnsSource]; if (Source == "") { Source = this.mObj_Base.pHeader_ViewName; } if (Sort == "") { Sort = Bind_Sort; } string Query_Table = @"(Select * From " + Source + " " + Query_Condition + " ) As [Tb]"; Interface_DataAccess Da = this.mObj_Base.CreateDataAccess(); //DataTable Dt = Do_Methods_Query.GetQuery(Query_Table, "", Condition, Sort, Top, Page); DataTable Dt = Da.GetQuery(Query_Table, "", Condition, Sort, Top, Page); Da.Close(); return(Dt); }
public ClsBaseTableDetail( ClsBase pObj_Base , string pHeaderName , string pTableName , string pViewName = "" , string pOtherLoadCondition = "") { if (pViewName == "") pViewName = pTableName; this.mHeaderName = pHeaderName; this.mTableName = pTableName; this.mViewName = pViewName; this.mOtherLoadCondition = pOtherLoadCondition; this.mObj_Base = pObj_Base; DataTable Dt_Def = Methods_Query.GetTableDef(this.mTableName); DataRow[] ArrDr = Dt_Def.Select("IsPk = 1"); foreach (DataRow Dr in ArrDr) { this.mList_Key.Add((string)Dr["ColumnName"]); } this.mDa = pObj_Base.pDa; }
public override bool Save(Interface_DataAccess Da = null) { if (this.mIsCache) { DataTable Dt_Tub = Do_Methods_Query.GetQuery(@"System_TableUpdateBatch", "", @"TableName = '" + this.mHeader_TableName + @"'"); DataRow Dr_Tub = null; if (Dt_Tub.Rows.Count > 0) { Dr_Tub = Dt_Tub.Rows[0]; } else { throw new Exception("Table Cache info not found."); } List <QueryParameter> List_Qp = new List <QueryParameter>(); List_Qp.Add(new QueryParameter("TableUpdateBatchID", Do_Methods.Convert_Int64(Dr_Tub["System_TableUpdateBatchID"]))); List_Qp.Add(new QueryParameter("ID", this.pID)); Do_Methods_Query.ExecuteNonQuery("usp_InsertToTableUpdateBatch", List_Qp); } return(base.Save(Da)); }
public bool CheckAccess(Int64 System_ModulesID, Layer01_Constants.eAccessLib AccessLib) { if (!this.mIsLoggedIn) { return(false); } if (this.mIsAdmin) { return(true); } Interface_DataAccess Da = Do_Methods.CreateDataAccess(); try { Da.Connect(); DataTable Dt = Da.GetQuery( @"uvw_User_Rights As Ur Left Join uvw_Rights_Details As Rd On Ur.RightsID = Rd.RightsID" , @"Ur.UserID, Rd.*" , @"Ur.UserID = " + ((Int64)this.mDrUser["UserID"]).ToString() + " And Rd.System_ModulesID = " + System_ModulesID.ToString() + " And Rd.System_Modules_AccessLibID = " + ((long)AccessLib).ToString() + " And Rd.IsAllowed = 1 And Ur.IsActive = 1" , "UserID"); if (Dt.Rows.Count > 0) { return(true); } return(false); } catch (Exception ex) { throw ex; } finally { Da.Close(); } }
/// <summary> /// Saves the changes to the detail table /// </summary> /// <param name="Da"> /// An open DataAccess from calling method /// </param> public void Save(Interface_DataAccess Da) { DataRow[] ArrDr = this.mDt.Select("", "", DataViewRowState.CurrentRows); foreach (DataRow Dr in ArrDr) { if (Dr.RowState == DataRowState.Added || Dr.RowState == DataRowState.Modified) { foreach (string Header_Key in this.mObj_Base.pHeader_Key) { Int64 Inner_ID = (Int64)Layer01_Methods.IsNull(this.mObj_Base.pDr[Header_Key], 0); Dr[Header_Key] = Inner_ID; } Da.SaveDataRow(Dr, this.mTableName); } } ArrDr = this.mDt.Select("", "", DataViewRowState.Deleted); foreach (DataRow Dr in ArrDr) { DataRow Nr = Dr.Table.NewRow(); foreach (DataColumn Dc in Dr.Table.Columns) { Nr[Dc.ColumnName] = Dr[Dc.ColumnName, DataRowVersion.Original]; } bool IsPKComplete = true; foreach (string Key in this.mList_Key) { if (Information.IsDBNull(Dr[Key])) { IsPKComplete = false; break; } } if (IsPKComplete) { Da.SaveDataRow(Dr, this.mTableName, "", true); } } }
/// <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 override bool Save(Interface_DataAccess Da = null) { if (this.mIsCache) { DataTable Dt_Tub = Do_Methods_Query.GetQuery(@"System_TableUpdateBatch", "", @"TableName = '" + this.mHeader_TableName + @"'"); DataRow Dr_Tub = null; if (Dt_Tub.Rows.Count > 0) { Dr_Tub = Dt_Tub.Rows[0]; } else { throw new Exception("Table Cache info not found."); } List<QueryParameter> List_Qp = new List<QueryParameter>(); List_Qp.Add(new QueryParameter("TableUpdateBatchID", Do_Methods.Convert_Int64(Dr_Tub["System_TableUpdateBatchID"]))); List_Qp.Add(new QueryParameter("ID", this.pID)); Do_Methods_Query.ExecuteNonQuery("usp_InsertToTableUpdateBatch", List_Qp); } return base.Save(Da); }
public void Save(Interface_DataAccess Da) { foreach (string Header_Key in this.mObj_Base.pHeader_Key) { Int64 Inner_ID = (Int64)Layer01_Methods.IsNull(this.mObj_Base.pDr[Header_Key], 0); this.mDr[Header_Key] = Inner_ID; } Da.SaveDataRow(this.mDr, this.mTableName); }
public void Save(Interface_DataAccess Da) { /* foreach (string Header_Key in this.mObj_Base.pHeader_Key) { Int64 Inner_ID = Do_Methods.Convert_Int64(this.mObj_Base.pDr[Header_Key]); this.mDr[Header_Key] = Inner_ID; } */ if (!this.mIsCustomKeys) { foreach (string Header_Key in this.mObj_Base.pHeader_Key) { Int64 Inner_ID = Do_Methods.Convert_Int64(this.mObj_Base.pDr[Header_Key]); this.mDr[Header_Key] = Inner_ID; } } else { foreach (Do_Constants.Str_ForeignKeyRelation Inner_Keys in this.mList_ForeignKey) { Int64 Inner_ID = Do_Methods.Convert_Int64(this.mObj_Base.pDr[Inner_Keys.Parent_Key]); this.mDr[Inner_Keys.Child_Key] = Inner_ID; } } Da.SaveDataRow(this.mDr, this.mTableName, "", false, this.mIsCustomKeys ? this.mList_Key : null); }
public void Load(Interface_DataAccess Da, ClsKeys Keys) { this.mDr = Da.Load_RowDetails(this.mViewName, Keys, this.mOtherLoadCondition, this.mList_ForeignKey); }
/// <summary> /// Saves the changes to the detail table /// </summary> /// <param name="Da"> /// An open DataAccess from calling method /// </param> public void Save(Interface_DataAccess Da) { DataRow[] ArrDr = this.mDt.Select("", "", DataViewRowState.CurrentRows); foreach (DataRow Dr in ArrDr) { if (Dr.RowState == DataRowState.Added || Dr.RowState == DataRowState.Modified) { if (!this.mIsCustomKeys) { foreach (string Header_Key in this.mObj_Base.pHeader_Key) { Int64 Inner_ID = Do_Methods.Convert_Int64(this.mObj_Base.pDr[Header_Key]); Dr[Header_Key] = Inner_ID; } } else { foreach (Do_Constants.Str_ForeignKeyRelation Inner_Keys in this.mList_ForeignKey) { Int64 Inner_ID = Do_Methods.Convert_Int64(this.mObj_Base.pDr[Inner_Keys.Parent_Key]); Dr[Inner_Keys.Child_Key] = Inner_ID; } } Da.SaveDataRow(Dr, this.mTableName, "", false, this.mIsCustomKeys ? this.mList_Key : null); } } ArrDr = this.mDt.Select("", "", DataViewRowState.Deleted); foreach (DataRow Dr in ArrDr) { DataRow Nr = Dr.Table.NewRow(); foreach (DataColumn Dc in Dr.Table.Columns) { Nr[Dc.ColumnName] = Dr[Dc.ColumnName, DataRowVersion.Original]; } bool IsPKComplete = true; foreach (string Key in this.mList_Key) { if (Information.IsDBNull(Dr[Key])) { IsPKComplete = false; break; } } if (IsPKComplete) { Da.SaveDataRow(Dr, this.mTableName, "", true, this.mIsCustomKeys ? this.mList_Key : null); } } }
public static DateTime GetServerDate() { using (Interface_DataAccess Da = Do_Methods.CreateDataAccess()) { return(GetServerDate(Da)); } }
public override bool Save(Interface_DataAccess Da = null) { return this.Save(false); }
public bool Save(bool IsApprove = false, Interface_DataAccess Da = null) { DateTime ServerDate = DateTime.Now; if (IsApprove) { this.mHeader_Dr["IsApproved"] = true; this.mHeader_Dr["DateApproved"] = ServerDate; this.mHeader_Dr["RecruitmentTestUserID_ApprovedBy"] = this.mCurrentUser.pDrUser["RecruitmentTestUserID"]; } else { this.mHeader_Dr["IsApproved"] = DBNull.Value; this.mHeader_Dr["DateApproved"] = DBNull.Value; this.mHeader_Dr["RecruitmentTestUserID_ApprovedBy"] = DBNull.Value; } if (this.pID == 0) { this.mHeader_Dr["DateCreated"] = ServerDate; this.mHeader_Dr["RecruitmentTestUserID_CreatedBy"] = this.mCurrentUser.pDrUser["RecruitmentTestUserID"]; } this.mHeader_Dr["DateUpdated"] = ServerDate; this.mHeader_Dr["RecruitmentTestUserID_UpdatedBy"] = this.mCurrentUser.pDrUser["RecruitmentTestUserID"]; base.Save(Da); //DataRow[] ArrDr = this.mBL_QuestionAnswer.pDt_List.Select("", "", DataViewRowState.CurrentRows); //foreach (DataRow Inner_Dr in ArrDr) //{ // ClsBase Obj = this.mBO_Answer[Do_Methods.Convert_Int64(Inner_Dr["TmpKey"]).ToString()]; // if (Obj != null) // { // Obj.Save(); // Inner_Dr["Lkp_RecruitmentTestAnswersID"] = Obj.pDr["RecruitmentTestAnswersID"]; // Inner_Dr["Lkp_RecruitmentTestQuestionsID"] = this.pDr["RecruitmentTestQuestionsID"]; // } //} //ArrDr = this.mBL_QuestionAnswer.pDt_List.Select("", "", DataViewRowState.Deleted); //foreach (DataRow Inner_Dr in ArrDr) //{ // ClsBase Obj = this.mBO_Answer[Do_Methods.Convert_Int64(Inner_Dr["TmpKey", DataRowVersion.Original]).ToString()]; // if (Obj != null) // { // if (!Microsoft.VisualBasic.Information.IsDBNull(Obj.pDr[Obj.pHeader_TableKey])) // { Obj.Delete(); } // } //} this.mBL_QuestionAnswer.Save(Da); return true; }
public override bool Save(Interface_DataAccess Da = null) { DateTime ServerDate = DateTime.Now; if (this.pID == 0) { this.mHeader_Dr["DateRequested"] = ServerDate; } return base.Save(Da); }
public static DataTable GetQuery(Interface_DataAccess Da, string ViewObject, string Fields, QueryCondition Condition, string Sort = "", Int64 Top = 0, Int32 Page = 0) { return Da.GetQuery(ViewObject, Fields, Condition, Sort, Top, Page); }
public static DateTime GetServerDate(Interface_DataAccess Da) { DataTable Dt = Da.ExecuteQuery("Select GetDate() As ServerDate").Tables[0]; if (Dt.Rows.Count > 0) return (DateTime)Dt.Rows[0][0]; else return DateTime.Now; }
/// <summary> /// (Overridable) Saves changes to the Data Object /// </summary> /// <param name="Da"> /// Optional, an open Data_Access Objects that is reused from the calling method /// </param> /// <returns></returns> public virtual bool Save(Interface_DataAccess Da = null) { bool IsSave = false; bool IsDa = false; try { if (Da == null) { Da = this.mDa; Da.Connect(); Da.BeginTransaction(); IsDa = true; } 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); } } //[-] if (IsDa) { Da.CommitTransaction(); } IsSave = true; } catch (Exception ex) { if (IsDa) { Da.RollbackTransaction(); } throw ex; } finally { if (IsDa) { Da.Close(); } } return IsSave; }
/// <summary> /// Loads the List with the supplied QueryCondition object /// </summary> /// <param name="Da"> /// An open DataAccess Object to be used. /// </param> /// <param name="Condition"> /// QueryCondition object to use. /// </param> public virtual void Load(Interface_DataAccess Da, QueryCondition Condition) { this.mDt_List = Da.List(this.mHeader_ViewName, Condition); this.AddRequired(this.mDt_List); }
public bool Save(eSaveAction SaveAction = eSaveAction.Save) { bool IsSave = false; if (this.mCurrentUser == null) { throw new Exception("User is not initialized"); } Interface_DataAccess Da = this.mDa; try { Da.Connect(); Da.BeginTransaction(); DateTime ServerDate = Layer02_Common.GetServerDate(Da); switch (SaveAction) { case eSaveAction.Save: if ((bool)Do_Methods.IsNull(this.mHeader_Dr["IsCancelled"], false)) { throw new Exception("Document is already cancelled."); } if ((bool)Do_Methods.IsNull(this.mHeader_Dr["IsPosted"], false)) { throw new Exception("Document is already posted."); } break; case eSaveAction.Post: if ((bool)Do_Methods.IsNull(this.mHeader_Dr["IsPosted"], false)) { throw new Exception("Document is already posted."); } this.mHeader_Dr["IsPosted"] = true; this.mHeader_Dr["DatePosted"] = ServerDate; this.mHeader_Dr["EmployeeID_PostedBy"] = this.mCurrentUser.pDrUser["EmployeeID"]; break; case eSaveAction.Cancel: if ((bool)Do_Methods.IsNull(this.mHeader_Dr["IsCancelled"], false)) { throw new Exception("Document is already cancelled."); } this.mHeader_Dr["IsCancelled"] = true; this.mHeader_Dr["DateCancelled"] = ServerDate; this.mHeader_Dr["EmployeeID_CancelledBy"] = this.mCurrentUser.pDrUser["EmployeeID"]; break; } Da.SaveDataRow(this.mHeader_Dr, this.mHeader_TableName); Da.CommitTransaction(); IsSave = true; } catch (Exception ex) { Da.RollbackTransaction(); throw ex; } finally { Da.Close(); } return(IsSave); }
public Configuration() { this.mBase = new Base(); this.mDa = this.mBase.pDa; }