private void BtnRemove_Click(object sender, RoutedEventArgs e)
        {
            var         item  = (sender as FrameworkElement).DataContext;
            int         index = ListPayments.Items.IndexOf(item);
            DataRowView row   = ListPayments.Items.GetItemAt(index) as DataRowView;



            ConfirmForm c = new ConfirmForm("Cette Dépense Sera Définitivement Supprimée, Voulez Vous Vraiment Continuer?");

            c.Owner      = this;
            this.Opacity = 0.5;
            this.Effect  = new BlurEffect();
            if ((bool)c.ShowDialog())
            {
                cn.Open();
                cmd.Connection  = cn;
                cmd.CommandText = "delete from Payments where IdPayment = '" + row.Row[0].ToString() + "'";
                cmd.ExecuteNonQuery();
                cn.Close();

                messageContent.Text = "Paiement Bien Supprimée";
                animateBorder(borderMessage);

                ajouter.Content  = "Ajouter";
                NomTextBox.Text  = null;
                PrixTextBox.Text = null;
                ListPayments.UnselectAll();
                loaded();
            }
            coutItems();
            this.Opacity = 1;
            this.Effect  = null;
        }
Esempio n. 2
0
        public async Task <IActionResult> ListAsync(DateTime?start = null, DateTime?end = null, int startIndex = 0, int pageSize = 30)
        {
            if (start == null)
            {
                start = DateHelpers.MonthStart();
            }

            if (end == null)
            {
                end = DateHelpers.MonthEnd();
            }

            startIndex = Math.Max(startIndex, 0);
            pageSize   = Math.Min(pageSize, 100);

            var query  = new ListPayments(start.Value, end.Value, new Paging(startIndex, pageSize));
            var result = await queries.RunAsync(query);

            return(Ok(result));
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (ajouter.Content.ToString() == "Nouveau")
            {
                ajouter.Content  = "Ajouter";
                NomTextBox.Text  = null;
                PrixTextBox.Text = null;
                ListPayments.UnselectAll();
            }
            else if (ajouter.Content.ToString() == "Ajouter")
            {
                if (PrixTextBox.Text == "" || NomTextBox.Text == "")
                {
                    messageContent.Text = "Merci De Remplir tous Les Champs";
                    animateBorder(borderMessage);
                }
                else
                {
                    try
                    {
                        if (ListPayments.SelectedIndex != -1)
                        {
                            DataRowView row1 = ListPayments.Items.GetItemAt(0) as DataRowView;
                            date = DateTime.Parse(row1.Row[4].ToString(), new System.Globalization.CultureInfo("fr"));
                        }


                        cn.Open();
                        cmd.Connection = cn;
                        cmd.Parameters.Clear();
                        cmd.CommandText = "insert into Payments values (@a,'" + id.ToString() + "','" + ConnectedSalle.ToString() + "','" + ConnectedSport.ToString() + "','" + double.Parse(PrixTextBox.Text) + "')";
                        cmd.Parameters.AddWithValue("@a", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr")));

                        cmd.ExecuteNonQuery();


                        messageContent.Text = "Paiement Bien Ajoutée";
                        animateBorder(borderMessage);

                        if (DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr")) > date)
                        {
                            cmd.Parameters.Clear();
                            cmd.CommandText = "update Clients set LastPay = @b  where IdClient = '" + id.ToString() + "'";
                            cmd.Parameters.AddWithValue("@b", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr")));

                            cmd.ExecuteNonQuery();
                        }
                    }
                    catch (Exception ex)
                    {
                        string      msg = ex.Message;
                        MessageForm m   = new MessageForm(msg);
                        m.ShowDialog();
                    }
                    finally
                    {
                        cn.Close();
                        loaded();
                        NomTextBox.Text  = null;
                        PrixTextBox.Text = null;
                    }
                }
            }
        }
        private void Modifier_Click(object sender, RoutedEventArgs e)
        {
            if (ListPayments.SelectedIndex == -1)
            {
                messageContent.Text = "Veuillez Sélectionner Une Ligne";
                animateBorder(borderMessage);
            }
            else
            {
                if (PrixTextBox.Text == "" || NomTextBox.Text == "")
                {
                    messageContent.Text = "Merci De Remplir tous Les Champs";
                    animateBorder(borderMessage);
                }
                else
                {
                    try
                    {
                        DataRowView row1 = ListPayments.Items.GetItemAt(0) as DataRowView;
                        DateTime    date = DateTime.Parse(row1.Row[4].ToString(), new System.Globalization.CultureInfo("fr"));


                        int         index = ListPayments.SelectedIndex;
                        DataRowView row   = ListPayments.Items.GetItemAt(index) as DataRowView;
                        int         idpay = int.Parse(row.Row[0].ToString());

                        cn.Open();
                        cmd.Connection = cn;
                        cmd.Parameters.Clear();
                        cmd.CommandText = "update  Payments set date_Payment =@a, Prix ='" + double.Parse(PrixTextBox.Text) + "' where IdPayment ='" + idpay + "'";
                        cmd.Parameters.AddWithValue("@a", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr")));

                        cmd.ExecuteNonQuery();

                        messageContent.Text = "Paiement Bien Modifiée";
                        animateBorder(borderMessage);

                        if (count == 1)
                        {
                            cmd.Parameters.Clear();
                            cmd.CommandText = "update Clients set LastPay = @b  where IdClient = '" + id.ToString() + "'";
                            cmd.Parameters.AddWithValue("@b", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr")));

                            cmd.ExecuteNonQuery();
                        }

                        else if (DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr")) > date)
                        {
                            cmd.Parameters.Clear();

                            cmd.CommandText = "update Clients set LastPay = @c  where IdClient = '" + id.ToString() + "'";
                            cmd.Parameters.AddWithValue("@c", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr")));

                            cmd.ExecuteNonQuery();
                        }
                    }
                    catch (Exception ex)
                    {
                        string      msg = ex.Message;
                        MessageForm m   = new MessageForm(msg);
                        m.ShowDialog();
                    }
                    finally
                    {
                        cn.Close();
                        ajouter.Content  = "Ajouter";
                        NomTextBox.Text  = null;
                        PrixTextBox.Text = null;
                        ListPayments.UnselectAll();

                        loaded();
                    }
                }
            }

            coutItems();
        }
Esempio n. 5
0
        public void addPaymentToList(Payment p)
        {
            PaymentViewModel payment = new PaymentViewModel(p);

            ListPayments.Add(payment);
        }