コード例 #1
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
 }
コード例 #2
0
        private string GetEmailMessage()
        {
            string message = "";

            Database.Client client = device.GetClient();

            foreach (Database.ServiceReport report in serviceReports)
            {
                message +=
                    "Marka: " + device.provider + "\r\n" +
                    "Model: " + device.model + "\r\n" +
                    "Numer Seryjny: " + device.model + "\r\n";

                if (client != null)
                {
                    message += "Klient: " + client.name + "\r\n" +
                               "Addres instalacji urządzenia: " + device.address.ToString();
                }

                message +=
                    "\r\n---------------------------------------------------------------\r\n" +
                    "Serwis z dnia: " + report.DateOfServiceClosed.ToString(Style.DateTimeFormat) + "\r\n" +
                    "Serwisant: " + report.Technican + "\r\n" +
                    "Licznik: " + report.Counter.ToString() + "\r\n\r\n";

                message += "Wykonane czynności: \r\n" + report.Description + "\r\n\r\n";
                message += "Opis usterki: \r\n" + report.ReportedProblem + "\r\n\r\n";
                message += "Zalecenia Serwisu: \r\n" + report.SeviceRecomendation + "\r\n";
            }

            return(message);
        }
コード例 #3
0
ファイル: Blockchain.cs プロジェクト: VictorGaan/OlympiadSTI
        public Block CreateNewBlock(Database.Client miner, Database.Order order)
        {
            Block block = new Block()
            {
                Nonce        = new Random().Next(1, 9999),
                PreviousHash = GetLatestBlock().CurrentHash,
                Mapping      = new Dictionary <string, decimal>(),
                Miner        = miner.PublicKey,
                Data         = ObjectToString(order),
                Transactions = new List <Transaction>(),
                Difficulty   = Difficulty,
                TimeStamp    = DateTime.UtcNow,
            };

            block.CurrentHash = BlockHash(block);
            if (Mine(block))
            {
                block.Mapping.Add("StorageChain", Storage);
                block.Mapping.Add($"{miner.PublicKey}", miner.Wallet);
                block.Signature = SignBlock(block, miner);
                AddBlock(block);
                return(block);
            }
            else
            {
                return(null);
            }
        }
コード例 #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 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
 }
コード例 #6
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
 }
コード例 #7
0
 protected void AddReportsFromClient(Database.Client client)
 {
     foreach (Database.Device dev in client.GetDevices())
     {
         cReports1.fastObjectListView1.AddObjects(dev.GetRecords());
     }
 }
コード例 #8
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
 }
コード例 #9
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
 }
コード例 #10
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
 }
コード例 #11
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
 }
コード例 #12
0
 private void SearchInGoogleMaps(object sender, EventArgs e)
 {
     if (fastObjectListView1.SelectedObjects.Count > 0)
     {
         Database.Client client = (Database.Client)fastObjectListView1.SelectedObjects[0];
         client.GetAddress().SearchInGoogleMaps();
     }
 }
コード例 #13
0
 public void ShowClient()
 {
     try
     {
         Database.Client client = GetDevice().GetClient();
         Forms.FClient   f      = new Forms.FClient(client);
         f.Show();
     } catch (NullReferenceException ex)
     {
         MessageBox.Show("Nie znalazłem klienta.");
     }
 }
コード例 #14
0
        private void FillControl(Database.Client client)
        {
            foreach (string s in client.f_numbers)
            {
                tbCbFax.Items.Add(s);
            }

            foreach (string s in client.p_numbers)
            {
                tbCbPhones.Items.Add(s);
            }

            foreach (string s in client.wwwsites)
            {
                tbCbSites.Items.Add(s);
            }

            foreach (string s in client.emails)
            {
                tbCbMails.Items.Add(s);
            }

            if (tbCbFax.Items.Count > 0)
            {
                tbCbFax.SelectedIndex = tbCbFax.Items.Count - 1;
            }

            if (tbCbPhones.Items.Count > 0)
            {
                tbCbPhones.SelectedIndex = tbCbPhones.Items.Count - 1;
            }

            if (tbCbSites.Items.Count > 0)
            {
                tbCbSites.SelectedIndex = tbCbSites.Items.Count - 1;
            }

            if (tbCbMails.Items.Count > 0)
            {
                tbCbMails.SelectedIndex = tbCbMails.Items.Count - 1;
            }

            this.lName.Text  = client.name;
            this.lNIP.Text   = client.NIP;
            this.tbNote.Text = client.notes;

            this.checkBox1.Checked = client.ser_agr;

            cDeviceList1.fastObjectListView1.AddObjects(client.GetDevices());

            FillAddress();
        }
コード例 #15
0
        public Models.Clients.Client Create(CreateClientRequest createClientRequest)
        {
            Database.AppUser appUser = _mapper.Map <Database.AppUser>(createClientRequest);
            appUser.HashedPassword = HashUtil.ComputeSha256Hash(createClientRequest.Password);
            appUser.CreatedAt      = DateTime.UtcNow;
            appUser.Status         = Database.UserStatus.INACTIVE;

            // add client specific data
            Database.Client client = new Database.Client();
            appUser.Client = client;

            _context.AppUsers.Add(appUser);
            _context.SaveChanges();
            return(_mapper.Map <Models.Clients.Client>(appUser));
        }
コード例 #16
0
        private void SetDevice()
        {
            if (device != null)
            {
                tblProvider.Text     = device.provider;
                tblModel.Text        = device.model;
                tblSerialNumber.Text = device.serial_number;
                monthCalendar1.SetDate(device.instalation_datetime);
                cAddress1.SetAddress(device.address);

                Database.Client client = device.GetClient();
                tblClientName.Text = client.name;
                tblNipName.Text    = client.NIP;
                tblAddress.Text    = client.address;
            }
        }
コード例 #17
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
 }
コード例 #18
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
 }
コード例 #19
0
        private void SetDevice()
        {
            if (device != null)
            {
                tblProvider.Text     = device.provider;
                tblModel.Text        = device.model;
                tblSerialNumber.Text = device.serial_number;
                monthCalendar1.SetDate(device.instalation_datetime);

                Database.Client client = device.GetClient();

                tblBlackAndWhite.Text = device.GetLastRecord().print_counter_black_and_white.ToString();
                tblColor.Text         = device.GetLastRecord().print_counter_color.ToString();
                tblScans.Text         = device.GetLastRecord().scan_counter.ToString();

                serviceReports = Database.DAO.GetServiceReport(device.id);

                FillServiceReportsList();
            }
        }
コード例 #20
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
 }
コード例 #21
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
 }
コード例 #22
0
        private void AddToList(Database.Client c)
        {
            Database.Address ad = c.GetAddress();

            string phone = "";
            string mail  = "";

            if (c.p_numbers.Length > 0)
            {
                phone = c.p_numbers[0];
            }

            if (c.emails.Length > 0)
            {
                mail = c.emails[0];
            }

            TBListViewItem item = new TBListViewItem(new string[] { c.name, c.NIP, ad.street, ad.city, phone, mail, c.notes, c.ser_agr ? "tak" : "nie" }, c);

            this.Items.Add(item);
        }
コード例 #23
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
 }
コード例 #24
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
 }
コード例 #25
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
 }
コード例 #26
0
 private void loadClient(string clientID)
 {
     this.client = Database.DAO.GetClient(clientID);
     this.cDeviceList1.fastObjectListView1.SetObjects(client.GetDevices());
 }
コード例 #27
0
 public FReports(Database.Client client)
 {
     InitializeComponent();
     AddReportsFromClient(client);
 }
コード例 #28
0
 public AddClient()
 {
     Init();
     client = new Database.Client();
 }
コード例 #29
0
 public void setClient(Database.Client client)
 {
     this.client = client;
     FillControl(client);
     Init();
 }
コード例 #30
0
 public FClient(Database.Client client)
 {
     InitializeComponent();
     this.addClient1.setClient(client);
 }