Exemplo n.º 1
0
        private void EditBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(ReferenceTextBox.Text) || string.IsNullOrWhiteSpace(ReferenceTextBox.Text))
                {
                    MessageBox.Show("reference non valid");
                    return;
                }

                facture.Reference = ReferenceTextBox.Text;
                if (facturesRepo.IsExist(facture.Reference, facture.Id))
                {
                    MessageBox.Show("reference exist. choose another reference.");
                    return;
                }
                facture.Date = DateDP.Value;
                facturesRepo.Edit(facture);
                facturesForm.FacturesGridView.DataSource = facturesRepo.Get();
                this.Close();
            }
            catch
            {
                MessageBox.Show("something went wrong !");
            }
        }
Exemplo n.º 2
0
 private void RemoveBtn_Click(object sender, EventArgs e)
 {
     try
     {
         facturesRepo.Remove(facture.Id);
         facturesForm.FacturesGridView.DataSource = facturesRepo.Get();
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("something went wrong !");
     }
 }
Exemplo n.º 3
0
 public FacturesForm()
 {
     InitializeComponent();
     factureRepo = new FacturesRepo();
     Factures    = factureRepo.Get();
     FacturesGridView.DataSource            = Factures;
     FacturesGridView.Columns["Id"].Visible = false;
     FacturesGridView.AutoSizeColumnsMode   = DataGridViewAutoSizeColumnsMode.Fill;
     if (Factures?.Count == 0)
     {
         EditBtn.Enabled   = false;
         RemoveBtn.Enabled = false;
     }
 }
Exemplo n.º 4
0
        private void ConfirmBtn_Click(object sender, EventArgs e)
        {
            if (Items.Count == 0)
            {
                MessageBox.Show("Invoice  could not be empty !");
                return;
            }

            string reference = ReferenceTextBox.Text;

            DateTime Date = Convert.ToDateTime(DateDP.Text);

            if (string.IsNullOrEmpty(reference) || string.IsNullOrWhiteSpace(reference))
            {
                MessageBox.Show("Reference non valid");
                return;
            }

            if (facturesRepo.IsExist(reference))
            {
                MessageBox.Show("Reference exist. choose another reference.");
                return;
            }

            Facture facture = new Facture()
            {
                Date      = DateDP.Value,
                Reference = ReferenceTextBox.Text,
                Total     = GetMontant(),
            };

            List <LigneFacture> factureLignes = new List <LigneFacture>();

            foreach (var item in Items)
            {
                factureLignes.Add(new LigneFacture(item));
            }

            List <Article> UpdatedArticles = new List <Article>();

            foreach (var factureLigne in factureLignes)
            {
                UpdatedArticles.Add(new Article()
                {
                    Quantite = factureLigne.Quantite, Id = factureLigne.IdArticle
                });
            }

            if (transactionsRepository.AddFactureWithTransaction(facture, factureLignes, UpdatedArticles))
            {
                MessageBox.Show("Facture added successfully ");
            }
            else
            {
                MessageBox.Show("Something went wrong :( ");
            }

            facturesForm.FacturesGridView.DataSource = facturesRepo.Get();

            this.Close();
        }
Exemplo n.º 5
0
 private void FactureGridView_SelectionChanged(object sender, EventArgs e)
 {
     selectedFacture = factureRepo.Get(Convert.ToInt32(FacturesGridView.CurrentRow.Cells["Id"].Value));
 }