private void ButtonAddExpense_Click(object sender, RoutedEventArgs e)
        {
            var messageQueue = SnackbarThree.MessageQueue;

            if (TextBoxValue.Text == string.Empty)
            {
                TextBoxValue.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Informe o valor da saída"));
                return;
            }

            if (DatePickerData.Text == string.Empty)
            {
                DatePickerData.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Informe a data saída"));
                return;
            }

            if (ComboBoxCategory.Text == string.Empty)
            {
                ComboBoxCategory.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Informe a categoria da saída"));
                return;
            }

            if (ComboBoxAccounts.Text == string.Empty)
            {
                ComboBoxAccounts.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Informe a conta da saída"));
                return;
            }

            Double   value    = Double.Parse(TextBoxValue.Text, NumberStyles.Currency);
            DateTime date     = DatePickerData.SelectedDate ?? DateTime.Now;
            var      account  = ComboBoxAccounts.SelectedItem;
            var      goal     = ComboBoxGoals.SelectedItem;
            var      category = ComboBoxCategory.SelectedItem;

            if (goal != null)
            {
                control.DebitGoal(goal, value);
            }

            control.SaveExpense(value, date, account, category);
            LoadExpenses();

            TextBoxValue.Text = string.Empty;
            ComboBoxAccounts.SelectedIndex = -1;
            DatePickerData.Text            = string.Empty;
            ComboBoxGoals.SelectedIndex    = -1;
            ComboBoxCategory.SelectedIndex = -1;
        }
        private void ButtonAddIncoming_Click(object sender, RoutedEventArgs e)
        {
            var messageQueue = SnackbarThree.MessageQueue;

            if (TextBoxValue.Text == string.Empty)
            {
                TextBoxValue.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Saisir la valeur de l'entrée"));
                return;
            }

            if (DatePickerData.Text == string.Empty)
            {
                DatePickerData.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Saisir la date d'entrée"));
                return;
            }

            if (ComboBoxCategory.Text == string.Empty)
            {
                ComboBoxCategory.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Entrez la catégorie d'entrée"));
                return;
            }

            if (ComboBoxAccounts.Text == string.Empty)
            {
                ComboBoxAccounts.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Saisissez la facture d'entrée"));
                return;
            }

            Double   value    = Double.Parse(TextBoxValue.Text, NumberStyles.Currency);
            DateTime date     = DatePickerData.SelectedDate ?? DateTime.Now;
            var      account  = ComboBoxAccounts.SelectedItem;
            var      category = ComboBoxCategory.SelectedItem;

            control.SaveIncoming(value, date, account, category);
            LoadIncomings();

            TextBoxValue.Text = string.Empty;
            ComboBoxAccounts.SelectedIndex = -1;
            DatePickerData.Text            = string.Empty;
            ComboBoxCategory.SelectedIndex = -1;
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtBname.Text == "")
     {
         MessageBox.Show("Please enter Brand Name");
         txtBname.Focus();
         return;
     }
     if (ComboBoxCategory.SelectedIndex == -1)
     {
         MessageBox.Show("Please Select Category Name");
         ComboBoxCategory.Focus();
         return;
     }
     try
     {
         string s = "";
         if (TxtBID.Text == "0")
         {
             s = "insert into brand(bname,cid)values('" + txtBname.Text + "','" + ComboBoxCategory.SelectedValue.ToString() + "')";
         }
         else
         {
             s = "update brand set bname='" + txtBname.Text + "',cid='" + ComboBoxCategory.SelectedValue.ToString() + "' where bid='" + TxtBID.Text + "'";
         }
         o.con.Open();
         SqlCommand cmd = new SqlCommand(s, o.con);
         cmd.ExecuteNonQuery();
         btnClear_Click(sender, e);
         loadgrid();
         o.con.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }