private void EditSptInfo(SettingsData returnEditedsettingsData)
        {
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;

            msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlConnection.Open();
                int idSptinfo = 1;
                msqlCommand.CommandText = "UPDATE sptinfo SET name='" + returnEditedsettingsData.Name + "', address='" + returnEditedsettingsData.Address + "', phone='" +
                    returnEditedsettingsData.Phone + "', bill_disclaimer='" + returnEditedsettingsData.BillDisclaimer + "', invoice_prefix='" + returnEditedsettingsData.InvoicePrefix +
                    "' WHERE id_sptinfo='" + idSptinfo + "'; ";

                msqlCommand.ExecuteNonQuery();

            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
 private SettingsData GetGUIValues()
 {
     SettingsData currentData = new SettingsData();
     currentData.Address = addressTextbox.Text;
     currentData.BillDisclaimer = billDisclaimerTextbox.Text;
     currentData.InvoicePrefix = invoicePrefixTextbox.Text;
     currentData.Name = nameTextbox.Text;
     currentData.Phone = phoneTextbox.Text;
     return currentData;
 }
        public static SettingsData FetcheSettingsData()
        {
            SettingsData settingsDataObject = null;
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;

            msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlConnection.Open();

                msqlCommand.CommandText = "Select * from sptinfo;";
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                msqlReader.Read();

                settingsDataObject = new SettingsData();

                settingsDataObject.Address = msqlReader.GetString("address");
                settingsDataObject.Name = msqlReader.GetString("name");
                settingsDataObject.Phone = msqlReader.GetString("phone");
                settingsDataObject.Password = msqlReader.GetString("password");
                settingsDataObject.BillDisclaimer = msqlReader.GetString("bill_disclaimer");
                settingsDataObject.InvoicePrefix = msqlReader.GetString("invoice_prefix");
                //settingsDataObject.sptinfo = msqlReader.GetString("id_sptinfo");

            }
            catch (Exception er)
            {
                //Assert//.Show(er.Message);
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }

            return settingsDataObject;
        }
 private void SetSalesBillingInfoFromSPTSettings()
 {
     sptSettings = FetchSPTSettings.FetcheSettingsData();
     sellernameTb.Text = sptSettings.Name;
     sellerAddressTb.Text += sptSettings.Address;
     sellerPhoneTb.Text += "Ph: " + sptSettings.Phone;
     declarationTextBlock.Text = sptSettings.BillDisclaimer;
 }
 private void SetGUIValuesFromDB(SettingsData settingsData)
 {
     nameTextbox.Text = settingsData.Name;
     addressTextbox.Text = settingsData.Address;
     phoneTextbox.Text = settingsData.Phone.ToString();
     billDisclaimerTextbox.Text = settingsData.BillDisclaimer;
     invoicePrefixTextbox.Text = settingsData.InvoicePrefix;
 }