コード例 #1
0
 /// <summary>
 /// Metoda dodająca rekord (IdActions = -1) lub aktualizująca wskazany rekord (IdActions = id wskazanego rekordu) do bazy danych
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdActions"></param>
 /// <param name="IdType_Of_Event"></param>
 /// <param name="IdProduct"></param>
 /// <param name="Operator"></param>
 /// <param name="Client"></param>
 /// <param name="Quantity"></param>
 /// <param name="Suggest_Date"></param>
 /// <param name="IdActionStart"></param>
 /// <param name="Date_Added"></param>
 /// <param name="ActionsCol"></param>
 /// <returns></returns>
 public static bool AddOrUpdate(Database.Client dbClient,
                                int IdActions, int IdType_Of_Event, int IdProduct, int Operator, int Client, int Quantity, DateTime Suggest_Date, int IdActionStart, DateTime Date_Added, string ActionsCol)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("ActionsAddOrUpdate", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdActions", IdActions);
         mySqlCmd.Parameters.AddWithValue("_IdType_Of_Event", IdType_Of_Event);
         mySqlCmd.Parameters.AddWithValue("_IdProduct", IdProduct);
         mySqlCmd.Parameters.AddWithValue("_Operator", Operator);
         mySqlCmd.Parameters.AddWithValue("_Client", Client);
         mySqlCmd.Parameters.AddWithValue("_Quantity", Quantity);
         mySqlCmd.Parameters.AddWithValue("_Suggest_Date", Suggest_Date);
         mySqlCmd.Parameters.AddWithValue("_IdActionStart", IdActionStart);
         mySqlCmd.Parameters.AddWithValue("_Date_Added", Date_Added);
         mySqlCmd.Parameters.AddWithValue("_ActionsCol", ActionsCol);
         mySqlCmd.ExecuteNonQuery();
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #2
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL pojedynczy rekord o podanym identyfikatorze (IdPlatform) i przypisująca go do podanej strukturze tabeli (tablePlatformsItem).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdPlatform"></param>
 /// <param name="tablePlatformsItem"></param>
 /// <returns></returns>
 public static bool Get(Database.Client dbClient, int IdPlatform, Database.Structure.Tables.Platforms tablePlatformsItem)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("PlatformsGet", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdPlatform", IdPlatform);
         mySqlCmd.ExecuteNonQuery();
         MySqlDataReader reader = mySqlCmd.ExecuteReader();
         if (reader.Read())
         {
             int i = 0;
             tablePlatformsItem.Idplatform = (int)reader[i++];
             tablePlatformsItem.Desc       = reader[i].ToString();
             reader.Close();
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #3
0
 /// <summary>
 /// Metoda usuwająca z bazy danych MySQL rekord o podanym identyfikatorze (IdActions).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdActions"></param>
 /// <returns></returns>
 public static bool Remove(Database.Client dbClient, int IdActions)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("ActionsRemove", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdActions", IdActions);
         mySqlCmd.ExecuteNonQuery();
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #4
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL wszystkie rekordy z tabeli i przypisująca je do podanej tabeli (tablePlatforms).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="tablePlatforms"></param>
 /// <returns></returns>
 public static bool GetAll(Database.Client dbClient, List <Database.Structure.Tables.Platforms> tablePlatforms)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlDataAdapter mySqlDa = new MySqlDataAdapter("PlatformsGetAll", dbClient.Connection());
         mySqlDa.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
         System.Data.DataTable dtPlatforms = new System.Data.DataTable();
         mySqlDa.Fill(dtPlatforms);
         tablePlatforms.Clear();
         for (int i = 0; i < dtPlatforms.Rows.Count; i++)
         {
             Database.Structure.Tables.Platforms tableItem = new Database.Structure.Tables.Platforms();
             int j = 0;
             tableItem.Idplatform = (int)dtPlatforms.Rows[i].ItemArray[j++];
             tableItem.Desc       = dtPlatforms.Rows[i].ItemArray[j].ToString();
             tablePlatforms.Add(tableItem);
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #5
0
 /// <summary>
 /// Metoda dodająca rekord (IdUser = -1) lub aktualizująca wskazany rekord (IdUser = id wskazanego rekordu) do bazy danych
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdUser"></param>
 /// <param name="Name"></param>
 /// <param name="Surname"></param>
 /// <param name="UserName"></param>
 /// <param name="EMail"></param>
 /// <param name="Password"></param>
 /// <param name="IdRole"></param>
 /// <param name="Create_Time"></param>
 /// <returns></returns>
 public static bool AddOrUpdate(Database.Client dbClient,
                                int IdUser, string Name, string Surname, string UserName, string EMail, string Password, int IdRole, DateTime Create_Time)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("UserAddOrUpdate", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdUser", IdUser);
         mySqlCmd.Parameters.AddWithValue("_Name", Name);
         mySqlCmd.Parameters.AddWithValue("_Surname", Surname);
         mySqlCmd.Parameters.AddWithValue("_UserName", UserName);
         mySqlCmd.Parameters.AddWithValue("_EMail", EMail);
         mySqlCmd.Parameters.AddWithValue("_Password", Password);
         mySqlCmd.Parameters.AddWithValue("_IdRole", IdRole);
         mySqlCmd.Parameters.AddWithValue("_Create_Time", Create_Time);
         mySqlCmd.ExecuteNonQuery();
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #6
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL pojedynczy rekord o podanym identyfikatorze (IdInventory) i przypisująca go do podanej strukturze tabeli (tableInventoryItem).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdInventory"></param>
 /// <param name="tableInventoryItem"></param>
 /// <returns></returns>
 public static bool Get(Database.Client dbClient, int IdInventory, Database.Structure.Tables.Inventory tableInventoryItem)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("InventoryGet", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdInventory", IdInventory);
         mySqlCmd.ExecuteNonQuery();
         MySqlDataReader reader = mySqlCmd.ExecuteReader();
         if (reader.Read())
         {
             int i = 0;
             tableInventoryItem.Idinventory   = (int)reader[i++];
             tableInventoryItem.Idproduct     = (int)reader[i++];
             tableInventoryItem.Qty           = (int)reader[i++];
             tableInventoryItem.Last_activity = OperationHelper.PrepareDateTimeValue(reader[i].ToString());
             reader.Close();
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #7
0
 /// <summary>
 /// Metoda dodająca rekord (IdInventory = -1) lub aktualizująca wskazany rekord (IdInventory = id wskazanego rekordu) do bazy danych
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdInventory"></param>
 /// <param name="IdProduct"></param>
 /// <param name="Qty"></param>
 /// <param name="Last_Activity"></param>
 /// <returns></returns>
 public static bool AddOrUpdate(Database.Client dbClient,
                                int IdInventory, int IdProduct, int Qty, DateTime Last_Activity)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("InventoryAddOrUpdate", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdInventory", IdInventory);
         mySqlCmd.Parameters.AddWithValue("_IdProduct", IdProduct);
         mySqlCmd.Parameters.AddWithValue("_Qty", Qty);
         mySqlCmd.Parameters.AddWithValue("_Last_Activity", Last_Activity);
         mySqlCmd.ExecuteNonQuery();
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #8
0
 /// <summary>
 /// Metoda dodająca rekord (IdProduct = -1) lub aktualizująca wskazany rekord (IdProduct = id wskazanego rekordu) do bazy danych
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdProduct"></param>
 /// <param name="IdType"></param>
 /// <param name="IdPlatform"></param>
 /// <param name="Name"></param>
 /// <param name="Subname"></param>
 /// <param name="Buy_Price"></param>
 /// <param name="Sell_Price"></param>
 /// <param name="Rent_Price"></param>
 /// <param name="Date_Added"></param>
 /// <param name="Last_Update"></param>
 /// <returns></returns>
 public static bool AddOrUpdate(Database.Client dbClient,
                                int IdProduct, int IdType, int IdPlatform, string Name, string Subname, int Buy_Price, int Sell_Price, int Rent_Price, DateTime Date_Added, DateTime Last_Update)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("ProductsAddOrUpdate", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdProduct", IdProduct);
         mySqlCmd.Parameters.AddWithValue("_IdType", IdType);
         mySqlCmd.Parameters.AddWithValue("_IdPlatform", IdPlatform);
         mySqlCmd.Parameters.AddWithValue("_Name", Name);
         mySqlCmd.Parameters.AddWithValue("_Subname", Subname);
         mySqlCmd.Parameters.AddWithValue("_Buy_Price", Buy_Price);
         mySqlCmd.Parameters.AddWithValue("_Sell_Price", Sell_Price);
         mySqlCmd.Parameters.AddWithValue("_Rent_Price", Rent_Price);
         mySqlCmd.Parameters.AddWithValue("_Date_Added", Date_Added);
         mySqlCmd.Parameters.AddWithValue("_Last_Update", Last_Update);
         mySqlCmd.ExecuteNonQuery();
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #9
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL wszystkie rekordy z tabeli i przypisująca je do podanej tabeli (tableActions).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="tableActions"></param>
 /// <returns></returns>
 public static bool GetAll(Database.Client dbClient, /*ref*/ List <Database.Structure.Tables.Actions> tableActions)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlDataAdapter mySqlDa = new MySqlDataAdapter("ActionsGetAll", dbClient.Connection());
         mySqlDa.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
         System.Data.DataTable dtActions = new System.Data.DataTable();
         mySqlDa.Fill(dtActions);
         tableActions.Clear();
         for (int i = 0; i < dtActions.Rows.Count; i++)
         {
             Database.Structure.Tables.Actions tableItem = new Database.Structure.Tables.Actions();
             int j = 0;
             tableItem.Idactions       = (int)dtActions.Rows[i].ItemArray[j++];
             tableItem.Idtype_of_event = (int)dtActions.Rows[i].ItemArray[j++];
             tableItem.Idproduct       = (int)dtActions.Rows[i].ItemArray[j++];
             tableItem.Operator        = (int)dtActions.Rows[i].ItemArray[j++];
             tableItem.Client          = (int)dtActions.Rows[i].ItemArray[j++];
             tableItem.Quantity        = OperationHelper.PrepareInt32Value(dtActions.Rows[i].ItemArray[j++].ToString());
             tableItem.Suggest_date    = OperationHelper.PrepareDateTimeValue(dtActions.Rows[i].ItemArray[j++].ToString());
             tableItem.Idactionstart   = OperationHelper.PrepareInt32Value(dtActions.Rows[i].ItemArray[j++].ToString());
             tableItem.Date_added      = OperationHelper.PrepareDateTimeValue(dtActions.Rows[i].ItemArray[j++].ToString());
             tableItem.Actionscol      = dtActions.Rows[i].ItemArray[j].ToString();
             tableActions.Add(tableItem);
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #10
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL wszystkie rekordy z tabeli i przypisująca je do podanej tabeli (tableProducts).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="tableProducts"></param>
 /// <returns></returns>
 public static bool GetAll(Database.Client dbClient, List <Database.Structure.Tables.Products> tableProducts)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlDataAdapter mySqlDa = new MySqlDataAdapter("ProductsGetAll", dbClient.Connection());
         mySqlDa.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
         System.Data.DataTable dtProducts = new System.Data.DataTable();
         mySqlDa.Fill(dtProducts);
         tableProducts.Clear();
         for (int i = 0; i < dtProducts.Rows.Count; i++)
         {
             Database.Structure.Tables.Products tableItem = new Database.Structure.Tables.Products();
             int j = 0;
             tableItem.Idproduct   = (int)dtProducts.Rows[i].ItemArray[j++];
             tableItem.Idtype      = (int)dtProducts.Rows[i].ItemArray[j++];
             tableItem.Idplatform  = (int)dtProducts.Rows[i].ItemArray[j++];
             tableItem.Name        = dtProducts.Rows[i].ItemArray[j++].ToString();
             tableItem.Subname     = dtProducts.Rows[i].ItemArray[j++].ToString();
             tableItem.Buy_price   = OperationHelper.PrepareInt32Value(dtProducts.Rows[i].ItemArray[j++].ToString());
             tableItem.Sell_price  = OperationHelper.PrepareInt32Value(dtProducts.Rows[i].ItemArray[j++].ToString());
             tableItem.Rent_price  = OperationHelper.PrepareInt32Value(dtProducts.Rows[i].ItemArray[j++].ToString());
             tableItem.Date_added  = OperationHelper.PrepareDateTimeValue(dtProducts.Rows[i].ItemArray[j++].ToString());
             tableItem.Last_update = OperationHelper.PrepareDateTimeValue(dtProducts.Rows[i].ItemArray[j].ToString());
             tableProducts.Add(tableItem);
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #11
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL pojedynczy rekord o podanym identyfikatorze (IdActions) i przypisująca go do podanej strukturze tabeli (tableActionsItem).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdActions"></param>
 /// <param name="tableActionsItem"></param>
 /// <returns></returns>
 public static bool Get(Database.Client dbClient, int IdActions, Database.Structure.Tables.Actions tableActionsItem)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("ActionsGet", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdActions", IdActions);
         mySqlCmd.ExecuteNonQuery();
         MySqlDataReader reader = mySqlCmd.ExecuteReader();
         if (reader.Read())
         {
             int i = 0;
             tableActionsItem.Idactions       = (int)reader[i++];
             tableActionsItem.Idtype_of_event = (int)reader[i++];
             tableActionsItem.Idproduct       = (int)reader[i++];
             tableActionsItem.Operator        = (int)reader[i++];
             tableActionsItem.Client          = (int)reader[i++];
             tableActionsItem.Quantity        = OperationHelper.PrepareInt32Value(reader[i++].ToString());
             tableActionsItem.Suggest_date    = OperationHelper.PrepareDateTimeValue(reader[i++].ToString());
             tableActionsItem.Idactionstart   = OperationHelper.PrepareInt32Value(reader[i++].ToString());
             tableActionsItem.Date_added      = OperationHelper.PrepareDateTimeValue(reader[i++].ToString());
             tableActionsItem.Actionscol      = reader[i].ToString();
             reader.Close();
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #12
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL pojedynczy rekord o podanym identyfikatorze (IdProduct) i przypisująca go do podanej strukturze tabeli (tableProductsItem).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdProduct"></param>
 /// <param name="tableProductsItem"></param>
 /// <returns></returns>
 public static bool Get(Database.Client dbClient, int IdProduct, Database.Structure.Tables.Products tableProductsItem)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("ProductsGet", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdProduct", IdProduct);
         mySqlCmd.ExecuteNonQuery();
         MySqlDataReader reader = mySqlCmd.ExecuteReader();
         if (reader.Read())
         {
             int i = 0;
             tableProductsItem.Idproduct   = (int)reader[i++];
             tableProductsItem.Idtype      = (int)reader[i++];
             tableProductsItem.Idplatform  = (int)reader[i++];
             tableProductsItem.Name        = reader[i++].ToString();
             tableProductsItem.Subname     = reader[i++].ToString();
             tableProductsItem.Buy_price   = OperationHelper.PrepareInt32Value(reader[i++].ToString());
             tableProductsItem.Sell_price  = OperationHelper.PrepareInt32Value(reader[i++].ToString());
             tableProductsItem.Rent_price  = OperationHelper.PrepareInt32Value(reader[i++].ToString());
             tableProductsItem.Date_added  = OperationHelper.PrepareDateTimeValue(reader[i++].ToString());
             tableProductsItem.Last_update = OperationHelper.PrepareDateTimeValue(reader[i].ToString());
             reader.Close();
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #13
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL wszystkie rekordy z tabeli i przypisująca je do podanej tabeli (tableUser).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="tableUser"></param>
 /// <returns></returns>
 public static bool GetAll(Database.Client dbClient, List <Database.Structure.Tables.User> tableUser)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlDataAdapter mySqlDa = new MySqlDataAdapter("UserGetAll", dbClient.Connection());
         mySqlDa.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
         System.Data.DataTable dtUser = new System.Data.DataTable();
         mySqlDa.Fill(dtUser);
         tableUser.Clear();
         for (int i = 0; i < dtUser.Rows.Count; i++)
         {
             Database.Structure.Tables.User tableItem = new Database.Structure.Tables.User();
             int j = 0;
             tableItem.Iduser      = (int)dtUser.Rows[i].ItemArray[j++];
             tableItem.Name        = dtUser.Rows[i].ItemArray[j++].ToString();
             tableItem.Surname     = dtUser.Rows[i].ItemArray[j++].ToString();
             tableItem.Username    = dtUser.Rows[i].ItemArray[j++].ToString();
             tableItem.Email       = dtUser.Rows[i].ItemArray[j++].ToString();
             tableItem.Password    = dtUser.Rows[i].ItemArray[j++].ToString();
             tableItem.Idrole      = (int)dtUser.Rows[i].ItemArray[j++];
             tableItem.Create_time = OperationHelper.PrepareDateTimeValue(dtUser.Rows[i].ItemArray[j].ToString());
             tableUser.Add(tableItem);
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #14
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL pojedynczy rekord o podanym identyfikatorze (IdUser) i przypisująca go do podanej strukturze tabeli (tableUserItem).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="IdUser"></param>
 /// <param name="tableUserItem"></param>
 /// <returns></returns>
 public static bool Get(Database.Client dbClient, int IdUser, Database.Structure.Tables.User tableUserItem)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlCommand mySqlCmd = new MySqlCommand("UserGet", dbClient.Connection());
         mySqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         mySqlCmd.Parameters.AddWithValue("_IdUser", IdUser);
         mySqlCmd.ExecuteNonQuery();
         MySqlDataReader reader = mySqlCmd.ExecuteReader();
         if (reader.Read())
         {
             int i = 0;
             tableUserItem.Iduser      = (int)reader[i++];
             tableUserItem.Name        = reader[i++].ToString();
             tableUserItem.Surname     = reader[i++].ToString();
             tableUserItem.Username    = reader[i++].ToString();
             tableUserItem.Email       = reader[i++].ToString();
             tableUserItem.Password    = reader[i++].ToString();
             tableUserItem.Idrole      = (int)reader[i++];
             tableUserItem.Create_time = OperationHelper.PrepareDateTimeValue(reader[i].ToString());
             reader.Close();
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }
コード例 #15
0
 /// <summary>
 /// Metoda pobierająca z bazy danych MySQL wszystkie rekordy z tabeli i przypisująca je do podanej tabeli (tableInventory).
 /// </summary>
 /// <param name="dbClient"></param>
 /// <param name="tableInventory"></param>
 /// <returns></returns>
 public static bool GetAll(Database.Client dbClient, List <Database.Structure.Tables.Inventory> tableInventory)
 {
     if (dbClient == null || dbClient.Connection() == null)
     {
         return(false);
     }
     if (!dbClient.OpenConnection()) // próba nawiązania połączenia z bazą
     {
         return(false);
     }
     try
     {
         MySqlDataAdapter mySqlDa = new MySqlDataAdapter("InventoryGetAll", dbClient.Connection());
         mySqlDa.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
         System.Data.DataTable dtInventory = new System.Data.DataTable();
         mySqlDa.Fill(dtInventory);
         tableInventory.Clear();
         for (int i = 0; i < dtInventory.Rows.Count; i++)
         {
             Database.Structure.Tables.Inventory tableItem = new Database.Structure.Tables.Inventory();
             int j = 0;
             tableItem.Idinventory   = (int)dtInventory.Rows[i].ItemArray[j++];
             tableItem.Idproduct     = (int)dtInventory.Rows[i].ItemArray[j++];
             tableItem.Qty           = (int)dtInventory.Rows[i].ItemArray[j++];
             tableItem.Qty           = (int)dtInventory.Rows[i].ItemArray[j++];
             tableItem.Last_activity = OperationHelper.PrepareDateTimeValue(dtInventory.Rows[i].ItemArray[j].ToString());
             tableInventory.Add(tableItem);
         }
         return(true);
     }
     catch (MySqlException ex)
     {
         Trace.WriteLine(ex.Message);
         return(false);
     }
     // pamiętać, aby zamykać połączenie
 }