示例#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 !");
            }
        }
示例#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 !");
     }
 }
示例#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;
     }
 }
示例#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();
        }
示例#5
0
 private void FactureGridView_SelectionChanged(object sender, EventArgs e)
 {
     selectedFacture = factureRepo.Get(Convert.ToInt32(FacturesGridView.CurrentRow.Cells["Id"].Value));
 }