private void createinvoice_Click(object sender, RoutedEventArgs e)
        {
            InvoiceWindow iw = new InvoiceWindow();

            iw.Show();
            this.Hide();
        }
        public void SaveInvoiceToDatabase()
        {
            string connectionstring = null;

            connectionstring = myConnection.connectionString();
            MySqlConnection cnn = new MySqlConnection(connectionstring);

            cnn.Open();
            MySqlCommand command = cnn.CreateCommand();

            command.Parameters.AddWithValue("@userid", LoginWindow.id);
            command.Parameters.AddWithValue("@invoiceid", invoiceid.Text);
            command.Parameters.AddWithValue("@clientname", nameField.Text);
            string[] tokens = paySUM.Text.Split(' ');
            command.Parameters.AddWithValue("@totalpay", float.Parse(tokens[0]));
            command.Parameters.AddWithValue("@totalqu", float.Parse(sumField.Text));
            command.Parameters.AddWithValue("@prevbal", float.Parse(oldBalanceField.Text));
            command.Parameters.AddWithValue("@newbal", float.Parse(newBalanceField.Text));
            command.Parameters.AddWithValue("@date", string.Join("", DateTime.Now.ToString("dd/MM/yyyy HH:mm")));
            bool cb = (bool)cbispaid.IsChecked;

            if (cb == true)
            {
                command.Parameters.AddWithValue("@ispaid", 1);
            }
            else
            {
                command.Parameters.AddWithValue("@ispaid", 0);
            }

            command.CommandText = "INSERT INTO SavedInvoices (userid,InvoiceId,Client_Name,Total_Payment,Total_Quantity,Previous_Balance,New_Balance,Date,IsPaid) VALUES (@userid, @invoiceid, @clientname, @totalpay, @totalqu, @prevbal, @newbal, @date, @ispaid)";
            if (command.ExecuteNonQuery() > 0)
            {
                MessageBox.Show("Invoice was successfuly saved!");
                this.Hide();
                InvoiceWindow iw = new InvoiceWindow();
                iw.Show();
            }
            else
            {
                MessageBox.Show("WARNING!!! [Error: Invoive wasn't saved in database.]");
            }
            cnn.Close();
        }