Пример #1
0
        /// <summary>
        /// delete article event
        /// </summary>
        /// <param name="sender">button</param>
        /// <param name="e">event-args</param>
        void dg_DeleteArticle(object sender, RoutedEventArgs e)
        {
            var         button    = sender as Button;
            var         param     = Convert.ToInt32(button.CommandParameter); // article_id
            DataRowView drv       = (DataRowView)button.DataContext;
            int         header_id = Convert.ToInt32(drv.Row.ItemArray[1]);    // header_id

            var response = MessageBox.Show("Do you want to Delete this article", "Confirm", MessageBoxButton.YesNo);

            if (response == MessageBoxResult.Yes)
            {
                RepoManager.DeleteArticle(param);            // delete from db, delete from table
                RepoManager.RecalcHeaderTable(header_id);    // recalc db, recal head tale
                RefreshDetailsGrid(header_id);               // refresh detail_grid
                MessageBox.Show("article deleted");
            }
        }
Пример #2
0
        /// <summary>
        /// update article event
        /// </summary>
        /// <param name="sender">button</param>
        /// <param name="e">event-args</param>
        void dg_UpdateAttribute(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            var param  = Convert.ToInt32(button.CommandParameter); // id

            DataRowView drv = (DataRowView)button.DataContext;
            var         i0  = drv.Row.ItemArray[0];                   // id
            var         i1  = drv.Row.ItemArray[1];                   // header_id
            var         i2  = drv.Row.ItemArray[2];                   // article_name
            var         i3  = drv.Row.ItemArray[3];                   // quantity
            float       i4  = Convert.ToSingle(drv.Row.ItemArray[4]); // net
            float       i5  = 0.0f;                                   // will be recalculated

            Article article = new Article((int)i0, (int)i1, (string)i2, (int)i3, (float)i4, (float)i5);

            RepoManager.UpdateArticle(article);                     // update db, update table table  //TODO: separate?
            RepoManager.RecalcHeaderTable(Convert.ToInt32(i1));     // recalc db, recalc table
            MessageBox.Show("article updated");
        }