Exemplo n.º 1
0
        double CountPrice(int idBill)
        {
            IEnumerable listBillInfo = _serviceBillInfo.GetListBillInfoByIdBill_S(idBill);
            double      S            = 0;

            foreach (BillInfo item in listBillInfo)
            {
                S += (item.Product.price.GetValueOrDefault() * item.count.GetValueOrDefault());
            }
            return(S);
        }
Exemplo n.º 2
0
        void UpdateProCount(BillInfo BI)
        {
            int         idBill       = _serviceBill.GetUncheckBillByIdTable_S(_idTable);
            IEnumerable listBillInfo = _serviceBillInfo.GetListBillInfoByIdBill_S(idBill);

            foreach (BillInfo item in listBillInfo)
            {
                if (BI.id == item.id)
                {
                    if (_serviceBillInfo.UpdateBillInfo_S(new BillInfo()
                    {
                        id = item.id, idBill = idBill, idProduct = item.idProduct, count = (item.count - BI.count)
                    }))
                    {
                        break;
                    }
                    break;
                }
            }
        }
Exemplo n.º 3
0
        void ShowBill(int idTable)
        {
            int         idBill       = _serviceBill.GetUncheckBillByIdTable_S(idTable);
            IEnumerable listBillInfo = _serviceBillInfo.GetListBillInfoByIdBill_S(idBill);

            lsvBill.Items.Clear();
            double totalPriceOfBill = 0;

            foreach (BillInfo item in listBillInfo)
            {
                ListViewItem lvItem = new ListViewItem(item.Product.name);
                lvItem.SubItems.Add(item.count.ToString());
                lvItem.SubItems.Add(item.Product.price.ToString());

                /*
                 * Ở đây có các cách convert kiểu Nullable (int? , double?) => ValueType (int,double)
                 * Ex : int? p1; int p2;
                 * case 1 : p2 = p1 ?? default(int);
                 * case 2 : p2 = p1.GetValueOrDefault();
                 * case 3 : p2 = p1 == null ? default(int) : p1;
                 * case 4 : if(p1.HasValue) p2 = p1.Value;
                 */
                int    count            = item.count ?? default(int);
                double price            = item.Product.price ?? default(double);
                double totalpricEachPro = count * price;
                lvItem.SubItems.Add(totalpricEachPro.ToString());
                totalPriceOfBill += totalpricEachPro;

                lsvBill.Items.Add(lvItem);
            }

            /*
             * Setting lại cái luồng đang chạy thành culture như trên
             * Thread.CurrentThread.CurrentCulture = culture;
             * Chỉ chạy culture ở dòng hiện tại mà không ảnh hưởng tới luồng(thread)
             */
            CultureInfo culture = new CultureInfo("vi-VN");

            txtTotalPrice.Text = totalPriceOfBill.ToString("C", culture);
        }
Exemplo n.º 4
0
        void LoadListBillInfo(int idBill)
        {
            IEnumerable listBillInfo = _serviceBillInfo.GetListBillInfoByIdBill_S(idBill);
            DataTable   data         = new DataTable();

            data.Columns.Add("STT");
            data.Columns.Add("ID Bill");
            data.Columns.Add("Tên sản phẩm");
            data.Columns.Add("Số lượng");
            int i = 1;

            foreach (BillInfo item in listBillInfo)
            {
                data.Rows.Add(i, item.idBill, item.Product.name, item.count);
                i++;
            }
            dgvListBillInfo.DataSource = data;
        }