예제 #1
0
파일: Cart.cs 프로젝트: fhoner/Kasse
 private void OnCartChanged(object sender, CartChangedEventArgs e)
 {
     if (CartChanged != null)
     {
         CartChanged(this, e);
     }
 }
예제 #2
0
        void RefreshCartGUI(object sender, CartChangedEventArgs e)
        {
            switch (e.Action)
            {
                case CartChangedEventArgs.Reason.Add:
                    bool tableContains = false;
                    int rowIndex = -1;

                    foreach (DataGridViewRow row in dgvCartTable.Rows)
                    {
                        if (row.Cells["colObject"].Value == e.Article)
                        {
                            tableContains = true;
                            rowIndex = row.Index;
                        }
                    }

                    if (!tableContains)
                        dgvCartTable.Rows.Insert(0, e.Article, e.Article.Deposit.Name, cart[e.Article].Count, e.Article.Deposit.AmountString, cart[e.Article].Count * (e.Article.PriceWithDeposit - e.Article.Price), "-", "x");
                    else
                    {
                        dgvCartTable.Rows.RemoveAt(rowIndex);
                        dgvCartTable.Rows.Insert(0, e.Article, e.Article.Deposit.Name, cart[e.Article].Count, e.Article.Deposit.AmountString, cart[e.Article].Count * (e.Article.PriceWithDeposit - e.Article.Price), "-", "x");
                    }
                    break;

                case CartChangedEventArgs.Reason.Remove:
                    foreach (DataGridViewRow row in dgvCartTable.Rows)
                    {
                        if (((Article)row.Cells["colObject"].Value) == e.Article)
                        {
                            dgvCartTable.Rows.Remove(row);
                            break;
                        }
                    }
                    break;

                case CartChangedEventArgs.Reason.Decrement:
                    foreach (DataGridViewRow row in dgvCartTable.Rows)
                    {
                        Article art = (Article)row.Cells["colObject"].Value;
                        if (art.ArticleID == e.Article.ArticleID)
                        {
                            dgvCartTable.Rows.Remove(row);
                            break;
                        }
                    }
                    dgvCartTable.Rows.Insert(0, e.Article, e.Article.Deposit.Name, cart[e.Article].Count, e.Article.Deposit.Amount, cart[e.Article].Count * (e.Article.PriceWithDeposit - e.Article.Price), "-", "x");
                    break;

                case CartChangedEventArgs.Reason.Clear:
                    dgvCartTable.Rows.Clear();
                    foreach (Article a in primaryProfile.Articles)
                    {
                        a.Button.Count = 0;
                    }
                    break;
            }

            if (printDevice.PrintStatus == PrintStatus.Printing)
                btnPrint.Enabled = false;
            else
                btnPrint.Enabled = cart.Count > 0;
            btnReset.Enabled = btnPrint.Enabled;

            txtTotalSum.Text = string.Format("{0:0.00}", cart.AmountWithDeposit);
        }
예제 #3
0
 private void CartChanged(object sender, CartChangedEventArgs e)
 {
     if (cart.Contains(article))
         this.Count = cart[article].Count;
     else
         this.Count = 0;
 }