Пример #1
0
        private void articleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddArticleForm form = new AddArticleForm();

            form.ShowDialog();
            RefreshListView();
        }
Пример #2
0
        /// <summary>
        /// Gestion de l'appuie de touche sur le listview des articles
        /// </summary>
        private void ArticleListview_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                if (articleListview.SelectedIndices.Count == 1)
                {
                    int    SelectedIndex      = articleListview.SelectedIndices[0];
                    String refArticleToDelete = this.articleListview.Items[SelectedIndex].SubItems[1].Text;

                    DBManager.GetInstance().DeleteArticle(refArticleToDelete);

                    RefreshListView();
                }
            }

            else if (e.KeyCode == Keys.F5)
            {
                RefreshListView();
            }
            else if (e.KeyCode == Keys.Enter)
            {
                if (articleListview.SelectedIndices.Count == 1)
                {
                    int    SelectedIndex    = articleListview.SelectedIndices[0];
                    String refArticleToEdit = this.articleListview.Items[SelectedIndex].SubItems[1].Text;

                    AddArticleForm form = new AddArticleForm(refArticleToEdit);
                    form.ShowDialog();
                    RefreshListView();
                }
            }
        }
Пример #3
0
        private void ModifierArticleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (articleListview.SelectedIndices.Count == 1)
            {
                int    SelectedIndex    = articleListview.SelectedIndices[0];
                String refArticleToEdit = this.articleListview.Items[SelectedIndex].SubItems[1].Text;

                AddArticleForm form = new AddArticleForm(refArticleToEdit);
                form.ShowDialog();
                RefreshListView();
            }
        }
Пример #4
0
        /// <summary>
        /// Executed when we click on the create article button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void On_Create_Article_Event(object sender, EventArgs e)
        {
            AddArticleForm Aaf    = new AddArticleForm(null);
            DialogResult   Result = Aaf.ShowDialog();

            if (Result == DialogResult.OK)
            {
                // Get the new value.
                Database       DB = Database.GetInstance();
                Models.Article A  = DB.Get_Article(Aaf.Inserted_Id);

                String[]     Row  = { A.Ref_Article, A.Description, A.Sub_Familly_Name, A.Brand_Name, "" + A.Price_HT, "" + A.Quantity };
                ListViewItem Item = new ListViewItem(Row);
                this.Article_List_View.Items.Add(Item);
                this.Status_Label.Text = "Article : " + A.Ref_Article + " ajouté !";
            }
        }
Пример #5
0
        /// <summary>
        /// Open the modify Article form
        /// </summary>
        /// <param name="Article"></param>
        public void Open_Modify_Article(Models.Article Article)
        {
            AddArticleForm Aaf    = new AddArticleForm(Article);
            DialogResult   Result = Aaf.ShowDialog();

            // Refresh the view.
            if (Result == DialogResult.OK)
            {
                // Get the new value.
                Database       DB = Database.GetInstance();
                Models.Article Modified_Article = DB.Get_Article(Article.Ref_Article);

                ListViewItem Lvi = Article_List_View.SelectedItems[0];
                Lvi.SubItems[0].Text = Modified_Article.Ref_Article;
                Lvi.SubItems[1].Text = Modified_Article.Description;
                Lvi.SubItems[2].Text = Modified_Article.Sub_Familly_Name;
                Lvi.SubItems[3].Text = Modified_Article.Brand_Name;
                Lvi.SubItems[4].Text = "" + Modified_Article.Price_HT;
                Lvi.SubItems[5].Text = "" + Modified_Article.Quantity;
            }
        }