public static bool readBillOutList(List <Model.BillOut> _myList) { try { openConnection(); string strCmd = string.Format("select * from HD_BAN"); SqlCommand myCmd = new SqlCommand(strCmd, conn); SqlDataReader myReader = myCmd.ExecuteReader(); while (myReader.Read()) { string id = myReader.GetString(0); DateTime date = myReader.GetDateTime(1); string employId = myReader.GetString(2); string guessId = myReader.GetString(3); int totalPrice = myReader.GetInt32(4); Model.BillOut b = new BillOut(id, date, employId, guessId, totalPrice); _myList.Add(b); } closeConnection(); return(true); } catch (Exception) { return(false); } }
public decimal Dequeue() { decimal sum = 0; if (queue.Count == 0) { return(sum); } Cart cart = queue.Dequeue(); if (cart != null) { Bill bill = new Bill { Customer = cart.Customer, Date = DateTime.Now, Seller = this.seller, CustomerId = cart.Customer.CustomerId, SellerId = seller.SellerId, Price = sum }; if (!isModel) { db.Bills.Add(bill); db.SaveChanges(); } List <Sell> sells = new List <Sell>(); foreach (Product product in cart) { if (product.Count > 1) { Sell sell = new Sell() { Product = product, ProductId = product.ProductId, Bill = bill, BillId = bill.BillId }; product.Count--; sum += product.Price; sells.Add(sell); } } bill.Price = sum; if (!isModel) { db.Sells.AddRange(sells); db.SaveChanges(); } BillOut?.Invoke(this, bill); } return(sum); }
private void btnPay_Click(object sender, EventArgs e) { if (isPay) { if (MessageBox.Show("Hóa đơn đã thanh toán, bạn có muốn xuất file Excel?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { exportToExcel(); } return; } // Nhấn nút sẽ cập nhật dữ liệu vào csdl List <Model.BillOutDetail> myBillOutDetailList = new List <BillOutDetail>(); foreach (DataRow dr in dtDgv.Rows) { Model.BillOutDetail b = new BillOutDetail(curBillID, dr["id"].ToString(), int.Parse(dr["outPrice"].ToString()), int.Parse(dr["num"].ToString())); myBillOutDetailList.Add(b); } BillOut bill = new BillOut(System.DateTime.Today.Date, CurEmployee.IdString, curGuess.IdString, truePrice, myBillOutDetailList); Connector.insertBillOut(bill); isPay = true; // Hiện hộp thoại hỏi có xuất file excel hay không? if (MessageBox.Show("Thanh toán thành công, bạn có muốn xuất file Excel?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { exportToExcel(); } }
public async Task <IActionResult> PutAsync(int id, [FromBody] BillOut resource) { var result = await _billoutRepository.UpdateAsync(id, resource); return(Ok(result)); }
public async Task <IActionResult> DeleteWithName([FromBody] BillOut resource) { var result = await _billoutRepository.DeleteWithName(resource.Tenvtxuat); return(Ok(result)); }
public async Task <IActionResult> PostAsync([FromBody] BillOut resource) { var result = await _billoutRepository.SaveAsync(resource); return(Ok(result)); }
public async Task <BillOut> SaveAsync(BillOut _obj) { await _context.BillOuts.AddAsync(_obj); await _context.SaveChangesAsync(); return(_obj); }
public async Task <BillOut> UpdateAsync(int id, BillOut resource) { var _obj = await _context.BillOuts.Where(o => o.Id == id).FirstOrDefaultAsync(); if (_obj != null) { _obj.Tenvtxuat = resource.Tenvtxuat; _obj.Ngayxuat = resource.Ngayxuat; _obj.Soluongxuat = resource.Soluongxuat; _obj.Dongiaxuat = resource.Dongiaxuat; _obj.Tinhtrang = resource.Tinhtrang; await _context.SaveChangesAsync(); } return(_obj); }