示例#1
0
 //Add list of articles to ref & desc Auto-complete text-box
 private void InitAutoComplete()
 {
     try
     {
         articles = articleRepo.Get();
         foreach (var article in articles)
         {
             ArticleReferenceTextBox.AutoCompleteCustomSource.Add(article.Reference);
             ArticleDesignationTextBox.AutoCompleteCustomSource.Add(article.Designation);
         }
     }
     catch
     {
         MessageBox.Show("something went wrong while initialize auto-complete fields !");
     }
 }
示例#2
0
        private void EditBtn_Click(object sender, EventArgs e)
        {
            try
            {
                article.Reference    = ReferenceTextBox.Text;
                article.Designation  = DescriptionTextBox.Text;
                article.Promo        = InPromotionCheckBox.Checked;
                article.DateFinPromo = Convert.ToDateTime(DateEndPromotTimePicker.Text);
                float price;
                article.Prix = float.TryParse(PriceTextBox.Text, out price) ? price : 0;
                if (string.IsNullOrWhiteSpace(QuantityTextBox.Text) || string.IsNullOrEmpty(QuantityTextBox.Text))
                {
                    article.Quantite = null;
                }
                else
                {
                    article.Quantite = Convert.ToInt32(QuantityTextBox.Text);
                }
                if (string.IsNullOrEmpty(article.Reference) || string.IsNullOrWhiteSpace(article.Reference))
                {
                    MessageBox.Show("Reference field is empty.");
                    return;
                }
                if (string.IsNullOrEmpty(article.Designation) || string.IsNullOrWhiteSpace(article.Designation))
                {
                    MessageBox.Show("Description field is empty.");
                    return;
                }

                if (articleRepo.IsExist(article.Reference, article.Id))
                {
                    MessageBox.Show("reference exist. choose another reference.");
                    return;
                }

                articleRepo.Edit(article);
                MessageBox.Show("article updated successfully. ");
                home.ArticleGridView.DataSource = articleRepo.Get();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("failed!");
            }
        }
示例#3
0
 public Details(FacturesForm _facturesForm)
 {
     InitializeComponent();
     try
     {
         facturesForm = _facturesForm;
         facture      = facturesForm.selectedFacture;
         _items       = factureLigneRepo.GetByFactureId(facture.Id);
         items        = _items.Select(p => new FactureLigneViewModel(p, articleRepo.Get(p.IdArticle))).ToList();
         FactureLignesGridView.DataSource          = items;
         FactureLignesGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
         FactureLignesGridView.Columns[nameof(FactureLigneViewModel.Id)].Visible        = false;
         FactureLignesGridView.Columns[nameof(FactureLigneViewModel.IdFacture)].Visible = false;
         FactureLignesGridView.Columns[nameof(FactureLigneViewModel.IdArticle)].Visible = false;
         ReferenceLabel.Text      = facture.Reference;
         DateLabel.Text           = facture.Date.ToString();
         TotalPriceTextBlock.Text = facture.Total.ToString();
     }
     catch
     {
         MessageBox.Show("something went wrong !");
     }
 }
示例#4
0
 public Remove(FacturesForm _facturesForm)
 {
     InitializeComponent();
     try
     {
         facturesForm         = _facturesForm;
         facture              = facturesForm.selectedFacture;
         ReferenceLabel.Text  = facture.Reference;
         TotalPriceLabel.Text = facture.Total.ToString();
         DateLabel.Text       = facture.Date.ToString();
         var factureLignes = factureLigneRepo.GetByFactureId(facture.Id);
         var model         = factureLignes.Select(f => new FactureLigneViewModel(f, articleRepo.Get(f.IdArticle))).ToList();
         FactureLignesGridView.DataSource          = model;
         FactureLignesGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
         FactureLignesGridView.Columns[nameof(FactureLigneViewModel.Id)].Visible        = false;
         FactureLignesGridView.Columns[nameof(FactureLigneViewModel.IdFacture)].Visible = false;
         FactureLignesGridView.Columns[nameof(FactureLigneViewModel.IdArticle)].Visible = false;
     }
     catch
     {
         MessageBox.Show("something went wrong !");
     }
 }