Пример #1
0
        private void LoadListChosen(BusinessProductUC para)
        {
            bool flag = true;
            int  id   = int.Parse(para.txbId.Text);

            if (ListProductChosen != null)
            {
                foreach (Product item in ListProductChosen)
                {
                    if (item.ID == id)
                    {
                        flag = false;
                        break;
                    }
                }
            }
            else
            {
                ListProductChosen = new List <Product>();
            }

            if (flag == true)
            {
                Product item = DataProvider.Instance.DB.Products.Where(x => x.ID == id).First();
                ListProductChosen.Add(item);
                BusinessProductChosenUC uc = new BusinessProductChosenUC();

                uc.txbID.Text     = item.ID.ToString();
                uc.txbName.Text   = item.Name.ToString();
                uc.txbPrice.Text  = SeparateThousands(item.ExportPrice.Value.ToString());
                uc.txbUnit.Text   = item.Unit;
                uc.txbAmount.Text = "1";
                uc.txbTotal.Text  = SeparateThousands(item.ExportPrice.Value.ToString());

                this.HomeWindow.stkListProductChosenBusiness.Children.Add(uc);
            }
            else
            {
                foreach (BusinessProductChosenUC item in this.HomeWindow.stkListProductChosenBusiness.Children)
                {
                    if (item.txbID.Text == id.ToString())
                    {
                        int  amount = int.Parse(item.txbAmount.Text) + 1;
                        long total  = ConvertToNumber(item.txbPrice.Text) * amount;
                        item.txbAmount.Text = amount.ToString();
                        item.txbTotal.Text  = SeparateThousands(total.ToString());
                    }
                }
            }
            LoadTotalofPayment();
            LoadPayment(this.HomeWindow.txtRetainerPaymment);
        }
Пример #2
0
        private void RemovefromListChosen(BusinessProductChosenUC para)
        {
            this.HomeWindow.stkListProductChosenBusiness.Children.Remove(para);

            int id = int.Parse(para.txbID.Text);

            Product item = DataProvider.Instance.DB.Products.Where(x => x.ID == id).First();

            ListProductChosen.Remove(item);
            LoadTotalofPayment();
            this.HomeWindow.txbChangePayment.Text    = "";
            this.HomeWindow.txtRetainerPaymment.Text = "";
        }