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 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(); } }
//[-] public void UpdatePriceHistory(DataRow[] ArrDr_Item) { DateTime ServerDate = Layer02_Common.GetServerDate(); PreparedQuery Pq = Do_Methods.CreateDataAccess().CreatePreparedQuery(); Pq.pQuery = @"Insert Into Item_PriceHistory (ItemID, Price, EmployeeID_PostedBy, DatePosted) Values (@ItemID, @Price, @EmployeeID_PostedBy, @DatePosted)"; Pq.Add_Parameter("ItemID", Do_Constants.eParameterType.Long); Pq.Add_Parameter("EmployeeID_PostedBy", Do_Constants.eParameterType.Long, this.mCurrentUser.pDrUser["EmployeeID"]); Pq.Add_Parameter("DatePosted", Do_Constants.eParameterType.DateTime, ServerDate); Pq.Add_Parameter("Price", Do_Constants.eParameterType.Numeric, null, 0, 18, 2); Pq.Prepare(); foreach (DataRow Dr in ArrDr_Item) { Pq.pParameter_Set("ItemID", Dr["ItemID"]); Pq.pParameter_Set("Price", Dr["Price"]); Pq.ExecuteNonQuery(); } }
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(); } }
//[-] public static void AddSelected( DataTable Dt_Target , DataTable Dt_Selected , string Query_Selected_Source , string Query_Selected_Key , string Target_Key , List <Str_AddSelectedFields> Obj_Fields = null , List <Str_AddSelectedFieldsDefault> Obj_FieldsDefault = null) { if (!(Dt_Selected.Rows.Count > 0)) { return; } PreparedQuery Pq = Do_Methods.CreateDataAccess().CreatePreparedQuery(); Pq.pQuery = @"Select * From " + Query_Selected_Source + @" Where " + Query_Selected_Key + @" = @ID"; Pq.Add_Parameter("ID", Do_Constants.eParameterType.Long); Pq.Prepare(); foreach (DataRow Dr_Selected in Dt_Selected.Rows) { //Pq.pParameters["ID"].Value = (Int64)Do_Methods.IsNull(Dr_Selected["ID"], 0); Pq.pParameter_Set("ID", Do_Methods.Convert_Int64(Dr_Selected["ID"])); DataTable Inner_Dt_Selected = Pq.ExecuteQuery().Tables[0]; if (Inner_Dt_Selected.Rows.Count > 0) { DataRow Inner_Dr_Selected = Inner_Dt_Selected.Rows[0]; DataRow[] Inner_ArrDr; DataRow Inner_Dr_Target = null; bool Inner_IsFound = false; Inner_ArrDr = Dt_Target.Select(Target_Key + " = " + Convert.ToInt64(Inner_Dr_Selected[Query_Selected_Key])); if (Inner_ArrDr.Length > 0) { Inner_Dr_Target = Inner_ArrDr[0]; if ((bool)Do_Methods.IsNull(Inner_Dr_Target["IsDeleted"], false)) { Inner_Dr_Target["IsDeleted"] = DBNull.Value; Inner_IsFound = true; } } if (!Inner_IsFound) { Int64 Ct = 0; Inner_ArrDr = Dt_Target.Select("", "TmpKey Desc"); if (Inner_ArrDr.Length > 0) { Ct = (Int64)Inner_ArrDr[0]["TmpKey"]; } Ct++; DataRow Nr = Dt_Target.NewRow(); Nr["TmpKey"] = Ct; Nr["Item_Style"] = ""; Nr[Target_Key] = (Int64)Inner_Dr_Selected[Query_Selected_Key]; Dt_Target.Rows.Add(Nr); Inner_Dr_Target = Nr; } if (Obj_Fields != null) { foreach (Str_AddSelectedFields Inner_Obj in Obj_Fields) { Inner_Dr_Target[Inner_Obj.Field_Target] = Inner_Dr_Selected[Inner_Obj.Field_Selected]; } } if (Obj_FieldsDefault != null) { foreach (Str_AddSelectedFieldsDefault Inner_Obj in Obj_FieldsDefault) { Inner_Dr_Target[Inner_Obj.Field_Target] = Inner_Obj.Value; } } } } }
public static DateTime GetServerDate() { using (Interface_DataAccess Da = Do_Methods.CreateDataAccess()) { return(GetServerDate(Da)); } }