コード例 #1
0
        public async Task <ActionResult <ChiTietDatBan> > PostChiTietDatBan(ChiTietDatBan chiTietDatBan)
        {
            _context.ChiTietDatBans.Add(chiTietDatBan);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetChiTietDatBan", new { id = chiTietDatBan.Id }, chiTietDatBan));
        }
コード例 #2
0
        public async Task <IActionResult> PutChiTietDatBanDaCo(ChiTietDatBan chiTiet)
        {
            var ct = await _context.ChiTietDatBans.Where(x => x.id_hoadon == chiTiet.id_hoadon && x.id_monan == chiTiet.id_monan).FirstOrDefaultAsync();

            if (ct == null)
            {
                return(NotFound());
            }
            ct.soluong++;
            _context.ChiTietDatBans.Update(ct);
            await _context.SaveChangesAsync();

            return(Ok(ct));
        }
コード例 #3
0
        public async Task <IActionResult> PutChiTietDatBanMoi(int id, ChiTietDatBan chiTietDatBan)
        {
            var ct = await _context.ChiTietDatBans.FindAsync(id);

            if (ct == null)
            {
                return(NotFound());
            }
            ct.soluong = chiTietDatBan.soluong;
            _context.ChiTietDatBans.Update(ct);
            await _context.SaveChangesAsync();

            return(Ok(ct));
        }
コード例 #4
0
 private void listViewBanAn_SelectedIndexChanged(object sender, EventArgs e)
 {
     listViewMonAnDaGoi.Items.Clear();
     lblTongTien.Text       = lblTongTien.Tag.ToString();
     lblTenBan.Text         = lblTenBan.Tag.ToString();
     lblTenKhuVuc.Text      = lblTenKhuVuc.Tag.ToString();
     lblThoiGianDatBan.Text = lblThoiGianDatBan.Tag.ToString();
     _SelectedBanAn         = null;
     _CurrDatBan            = null;
     if (listViewBanAn.SelectedItems.Count > 0)
     {
         var banAnID = int.Parse(listViewBanAn.SelectedItems[0].Name);
         this._SelectedBanAn = _lstBanAn.Find(x => x.BanAnID == banAnID);
         lblTenBan.Text      = _SelectedBanAn.TenBan;
         lblTenKhuVuc.Text   = _SelectedBanAn.TenKhuVuc;
         if (this._SelectedBanAn.TrangThaiID == 1)
         {
             RestaurantServicesSoapClient serv = new RestaurantServicesSoapClient();
             var ds = serv.Lay_DanhSachDatBan(banAnID);
             _CurrDatBan            = new DatBan(ds.Tables[0].Rows[0]);
             lblThoiGianDatBan.Text = _CurrDatBan.NgayDatBan.ToString();
             _lstChiTiet            = new List <ChiTietDatBan>();
             foreach (DataRow dr in ds.Tables[1].Rows)
             {
                 var ct = new ChiTietDatBan(dr);
                 _lstChiTiet.Add(ct);
                 ListViewItem item = new ListViewItem();
                 item.Text = ct.TenMonAn;
                 item.SubItems.Add(ct.DonGia.ToString("#,#"));
                 item.SubItems.Add(ct.SoLuong.ToString());
                 item.SubItems.Add((ct.SoLuong * ct.DonGia).ToString("#,#"));
                 listViewMonAnDaGoi.Items.Add(item);
             }
             _TongTien = 0;
             _lstChiTiet.ForEach(x =>
             {
                 _TongTien += x.DonGia * x.SoLuong;
             });
             _TongTien       *= 1000;
             lblTongTien.Text = _TongTien.ToString("#,#");
         }
     }
 }