Пример #1
0
        private void add_Click(object sender, RoutedEventArgs e)
        {
            Product prd  = datagridsp.SelectedItem as Product;
            bool    flag = false;

            foreach (var item in listcthd)
            {
                if (item.IdProduct == prd.Id)
                {
                    item.SoLuong++;
                    item.TinhTongGia();
                    flag = true;
                    break;
                }
            }
            if (flag == false)
            {
                InvoiceDetail newCT = new InvoiceDetail()
                {
                    IdProduct = prd.Id,
                    SoLuong   = 1,
                    GiaBan    = float.Parse(prd.Gia.ToString()),
                };
                newCT.TinhTongGia();
                listcthd.Add(newCT);
            }
            double Tongtien = 0;

            foreach (var CT in listcthd)
            {
                Tongtien = Tongtien + CT.TongTien.Value;
            }
            tbltongtienhoadon.Text     = Tongtien.ToString();
            datagridgihang.ItemsSource = listcthd.ToList();
        }
Пример #2
0
        private void tbSL_TextChanged(object sender, TextChangedEventArgs e)
        {
            InvoiceDetail detail = datagridgihang.SelectedItem as InvoiceDetail;

            if (detail != null)
            {
                detail.TinhTongGia();
                double Tongtien = 0;
                foreach (var CT in view)
                {
                    Tongtien = Tongtien + CT.TongTien.Value;
                }
                tbltongtienhoadon.Text = Tongtien.ToString();
            }
        }