public override object getAll(Type type = null) { List <BillEntity> listBillEntities = new List <BillEntity>(); try { using (StoreManagementEntities context = new StoreManagementEntities()) { foreach (BillHistory bill in context.BillHistories) { Dictionary <int, int> lstProduct = context.BillDetails.AsParallel() .Where(temp => temp.BillID == bill.BillID) .ToDictionary(t => t.ProductID, t => t.Quantity); BillEntity entity = new BillEntity() { BillDate = bill.BillDate, BillID = bill.BillID, CashierID = bill.CashierID, ListProduct = lstProduct, TotalPrice = bill.TotalPrice }; listBillEntities.Add(entity); } } } catch (Exception e) { CustomException ex = new CustomException(GetType().Name + " : GetAll \n" + e.Message); ex.showPopupError(); } return(listBillEntities); }
public ActionResult Edit(FormCollection formCollection, [FetchBill(KeyName = "billid")] BillEntity model, BillViewModel vo) { var jsonResult = new JsonResult { ContentEncoding = Encoding.UTF8 }; var result = new ExecuteResult <int>(); if (ModelState.IsValid) { var tmp = Mapper.Map <BillViewModel, BillEntity>(vo); tmp.UpdatedDate = DateTime.Now; tmp.UpdatedUser = CurrentUser.CustomerId; tmp.Status = model.Status; tmp.CreatedDate = model.CreatedDate; tmp.CreatedUser = model.CreatedUser; tmp.Status = model.Status; tmp.IsDeleted = model.IsDeleted; Mapper.Map(tmp, model); Update(model); } else { result.StatusCode = StatusCode.ClientError; result.Message = "参数验证错误"; } jsonResult.Data = result; return(jsonResult); }
public IActionResult AddBill(AddEditBillViewModel model) { if (model != null && model.Bill != null && ModelState.IsValid) { if (float.TryParse(model.Bill.Amount.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var amount)) { var entity = new BillEntity { CreatedBy = HttpContext.User.Identity.Name, CreatedDate = DateTime.Now, Description = model.Bill.Description, PersonId = model.Bill.PersonId, Amount = amount, BillDate = model.Bill.BillDate.Value, BillId = model.Bill.Id }; if (entity.BillId > 0) { _billsService.UpdateBill(entity); } else { _billsService.AddBill(entity); } } } return(RedirectToAction(nameof(BillsList))); }
public BillEntity AddBill(BillEntity bill) { dbContext.Add(bill); dbContext.SaveChanges(); return(bill); }
private void Edit_Click(object sender, RoutedEventArgs e) { try { Button btn = sender as Button; BillEntity tmp = btn.DataContext as BillEntity; updatedetailbill window = new updatedetailbill(tmp); window.ShowDialog(); if (updatedetailbill.isUpdate) { // ListBill = dao.getAll(typeof(BillEntity)) as List<BillEntity>; int index = ListBill.IndexOf(ListBill.Find(entity => tmp.BillID == entity.BillID)); BillEntity updBill = dao.get(tmp.BillID) as BillEntity; ListBill[index].TotalPrice = updBill.TotalPrice; GetBill(); updatedetailbill.isUpdate = false; Task.Run(() => Dispatcher.Invoke(ChartsLayout.ReloadChart)); } } catch { MessageBox.Show("Error Occurred. Please Try Again", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public BillEntity ConvertBill(BillModel originalBill) { BillEntity convertedBill = new BillEntity { BillId = originalBill.BillId, CustomerId = originalBill.CustomerId, CustomerName = originalBill.CustomerName, Month = originalBill.Month, Year = originalBill.Year, TotalPrice = originalBill.TotalPrice, Lines = new List <string>(), PackagesIds = new List <int>() }; foreach (var line in originalBill.Lines) { convertedBill.Lines.Add(line.LineNumber); } foreach (var package in originalBill.Packages) { convertedBill.PackagesIds.Add(package.PackageId); } return(convertedBill); }
public updatedetailbill(BillEntity tmp) { InitializeComponent(); if (LoginForm.currentUser.Role == 1) { update.Visibility = Visibility.Collapsed; } billdetail = tmp; //Chuyen Dictionary thanh dạng list<value> Dictionary <int, int> listproductbill = billdetail.ListProduct; //Lay Product để lay quantity BaseDAO dao = new ProductDAO(); List <int> array1 = new List <int>(listproductbill.Keys.ToList()); List <int> array2 = new List <int>(listproductbill.Values.ToList()); for (int i = 0; i < array1.Count; i++) { ProductEntity product = dao.get(array1[i], typeof(ProductEntity)) as ProductEntity; array.Add(new info(array1[i], array2[i], product.Quantity, product.ProductName)); } listdetailbill.ItemsSource = array; }
public override void update(object obj) { try { BillEntity entity = obj as BillEntity; using (StoreManagementEntities context = new StoreManagementEntities()) { BillHistory billHistory = context.BillHistories.Find(entity.BillID); context.Entry(billHistory).CurrentValues.SetValues(entity); billHistory.TotalPrice = CalculateTotalPrice(entity.ListProduct); Dictionary <int, int> listProduct = entity.ListProduct; foreach (KeyValuePair <int, int> product in listProduct) { BillDetail billDetail = context.BillDetails.Find(entity.BillID, product.Key); if (billDetail != null && billDetail.Quantity != product.Value) { Product pro = context.Products.Find(product.Key); pro.Quantity = pro.Quantity + billDetail.Quantity - product.Value; context.Entry(billDetail) .CurrentValues.SetValues(new { BillID = billDetail.BillID, ProductID = product.Key, Quantity = product.Value }); } else if (billDetail == null) { Product pro = context.Products.Find(product.Key); pro.Quantity = pro.Quantity - product.Value; BillDetail detail = new BillDetail() { BillID = entity.BillID, ProductID = product.Key, Quantity = product.Value }; context.BillDetails.Add(detail); } } context.SaveChanges(); } } catch (Exception e) { CustomException ex = new CustomException(GetType().Name + " : Update " + obj.ToString() + "\n" + e.Message); ex.showPopupError(); } }
private void Confirm_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: //cap nhat database //cap nhat BillHistory //cap nhat Detail Bill //init //BaseDAO dao1 = BaseDAO int tmpIdCashier = LoginForm.Idcashier; //chuyen sale.basket sang dang directory Dictionary <int, int> tmpbasket = new Dictionary <int, int>(); foreach (infobasket t in sale.baskets) { tmpbasket.Add(t.ProductID, t.size); } //create new bill BillEntity bill = new BillEntity() { //set date BillDate = DateTime.Today, //add list product ListProduct = tmpbasket, //set ID cashier CashierID = tmpIdCashier }; //insert and get new bill ID BaseDAO dao = new BillDAO(); int billID = dao.insert(bill); //bao hieu cap nhat listitems flag = true; MessageBox.Show("Thanh toán thành công", "Result", MessageBoxButton.OK, MessageBoxImage.Information); Close(); sale.baskets.Clear(); break; case MessageBoxResult.No: break; } }
public void SubmitForm(BillEntity applyEntity, int?keyValue = null) { if (keyValue != null) { applyEntity.id = keyValue.Value; service.Update(applyEntity); } else { service.Insert(applyEntity); } }
public BillEntity GetBill(int id, int month, int year) { var bill = new BillEntity(); using (var db = new CellularDbContext()) { bill = (from b in db.Bills where b.CustomerId == id && b.Month == month && b.Year == year select b).FirstOrDefault(); } return(bill); }
public bool AddBill(BillEntity bill) { try { using (var db = new CellularDbContext()) { db.Bills.Add(bill); db.SaveChanges(); return(true); } } catch { /* write to log */ return(false); } }
/// <summary> /// 逻辑删 /// </summary> /// <param name="entity"></param> /// <param name="updateUserId"></param> /// <returns></returns> private bool Del(BillEntity entity, int updateUserId) { return(ServiceInvoke <bool>(service => { entity.IsDeleted = true; entity.UpdatedDate = DateTime.Now; entity.UpdatedUser = updateUserId; service.BillRepository.Update(entity); return true; })); }
public ActionResult PickingForm(string keyValue) { try { var dep = OperatorProvider.Provider.GetCurrent().DepartmentId; var depName = organizeApp.GetForm(dep).F_FullName; string[] Ids = keyValue.Split(','); if (Ids.Length == 1) { int ID = Convert.ToInt32(Ids[0]); var apply = applyBillApp.GetForm(ID); if (((apply.yiJiaoNum ?? 0) - (apply.takeNum ?? 0)) <= 0) { return(Error("暂时不能领料。")); } } foreach (var Id in Ids) { int ID = Convert.ToInt32(Id); var apply = applyBillApp.GetForm(ID); if (((apply.yiJiaoNum ?? 0) - (apply.takeNum ?? 0)) > 0) { BillEntity billEntity = new BillEntity(); billEntity.billType = "D"; billEntity.num = (apply.yiJiaoNum ?? 0) - (apply.takeNum ?? 0); billEntity.prtTag = "F"; billEntity.purSup = apply.purSup; var price = priceApp.GetFormJson(apply.priNO); billEntity.billNo = billApp.ProduceBillNO(apply.purSup, "pick", price.currency.Value, depName); billEntity.caseTag = "F"; billEntity.chkDate = DateTime.Now; billEntity.fromID = apply.ID; billEntity.viceNum = billApp.GetViceNum(billEntity.fromID); billApp.SubmitForm(billEntity); apply.takeNum = (apply.takeNum ?? 0) + billEntity.num; if (apply.takeNum == apply.appNum) { apply.caseTag = "T"; } applyBillApp.SubmitForm(apply, apply.ID); } } return(Success("操作成功!")); } catch (Exception ex) { return(Error("操作失败!")); } }
public ActionResult Delete(FormCollection formCollection, [FetchBill(KeyName = "billid")] BillEntity model) { Del(model, CurrentUser.CustomerId); var jsonResult = new JsonResult { ContentEncoding = Encoding.UTF8 }; var result = new ExecuteResult <int>(); jsonResult.Data = result; return(jsonResult); }
public void UpdateOrders(BillEntity en) { var sql = "update test set name = '" + en.Name + "', age = '" + en.Age + "', sex = '" + en.Sex + "', reference = '" + en.Reference + "', date = '" + en.Date + "',time = '" + en.Time + "' where id = '" + en.Id + "';"; int exe = DataAccess.ExecuteQuery(sql); if (exe == 1) { MessageBox.Show("Updated"); } else { MessageBox.Show("Not Updated"); } }
public override int insert(object obj) { try { if (obj == null) { throw new CustomException(GetType().Name + " : Inserting Null Value"); } BillEntity newBill = obj as BillEntity; BillHistory billHistory = new BillHistory { CashierID = newBill.CashierID, BillDate = newBill.BillDate, TotalPrice = CalculateTotalPrice(newBill.ListProduct) }; using (StoreManagementEntities context = new StoreManagementEntities()) { context.BillHistories.Add(billHistory); foreach (KeyValuePair <int, int> product in newBill.ListProduct) { BillDetail billDetail = new BillDetail { BillID = billHistory.BillID, ProductID = product.Key, Quantity = product.Value }; Product pro = context.Products.Find(product.Key); pro.Quantity -= product.Value; context.BillDetails.Add(billDetail); } context.SaveChanges(); } return(billHistory.BillID); } catch (Exception e) { CustomException ex = new CustomException(GetType().Name + " : Insert " + obj.ToString() + "\n" + e.Message); ex.showPopupError(); } return(-1); }
private void Xoa_Click(object sender, RoutedEventArgs e) { try { MessageBoxResult result = MessageBox.Show("Are You Sure?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question); switch (result) { case MessageBoxResult.Yes: { try { BillEntity tmp = (sender as Button).DataContext as BillEntity; Task.Run(() => { dao.delete(tmp); Dispatcher.Invoke(ChartsLayout.ReloadChart); }); Infobill.flag = true; BillEntity delObject = ListBill.Find(entity => tmp.BillID == entity.BillID); ListBill.Remove(delObject); MessageBox.Show("Delete Bill Success", "Result", MessageBoxButton.OK, MessageBoxImage.Information); GetBill(); } catch { } } break; case MessageBoxResult.No: break; } } catch { MessageBox.Show("Error Occurred. Please Try Again", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnUpdate_Click(object sender, EventArgs e) { BillEntity en = new BillEntity(); BillRepo re = new BillRepo(); en.Id = txtTestNo.Text; en.Name = txtPatient.Text; en.Date = dtpDate.Value.ToString("yyyy-MM-dd"); en.Age = int.Parse(txtAge.Text); en.Sex = txtSex.Text; en.Time = dtpTime.Value.ToString("hh:mm tt"); en.Reference = txtReference.Text; re.UpdateOrders(en); }
private void View(string no) { BillRepo re = new BillRepo(); BillEntity en = re.Credentials(no); txtPatient.Text = en.Name; txtAge.Text = en.Age.ToString(); txtSex.Text = en.Sex; txtReference.Text = en.Reference; txtTests.Text = en.Tests; txtPrice.Text = en.Price; txtTotal.Text = en.Total; txtDiscount.Text = en.Discount; dtpDate.Text = en.Date; dtpTime.Text = en.Time; }
public BillModel ConvertBill(BillEntity originalBill) { BillModel convertedBill = new BillModel { BillId = originalBill.BillId, CustomerId = originalBill.CustomerId, CustomerName = originalBill.CustomerName, Month = originalBill.Month, Year = originalBill.Year, TotalPrice = originalBill.TotalPrice, Lines = new List <LineModel>(), Packages = new List <PackageModel>() }; return(convertedBill); }
public async Task <CommandResult> Handle(CreateBillCommand request, CancellationToken cancellationToken) { try { BillEntity bill = new BillEntity( request.client, request.telephone, new Email(request.email), request.paymentType); var result = await _service.Post(bill); if (result != null) { foreach (var item in request.detail) { DetailEntity detail = new DetailEntity( result.Id, item.productId, new ProductName(item.productName), item.quantity, new Price(item.price) ); await _serviceDetail.Post(detail); } await _mediator.Publish(new CreatedBillEvent { id = result.Id, client = result.Client, telephone = result.Telephone, email = result.Email.Address, paymentType = result.PaymentType }); return(CommandResult.Success(result)); // return Created(new Uri(Url.Link("GetWithId", new { id = result.Id })), result); } else { return(CommandResult.Fail("Hubo un error al registrar la Factura")); } } catch (ArgumentException e) { return(CommandResult.Fail(e.Message)); } }
partial void BeforeCopyProperties(IBillExpense other, ref bool handled) { other.CheckArgument(nameof(other)); other.Bill.CheckArgument(nameof(other.Bill)); other.Expenses.CheckArgument(nameof(other.Expenses)); handled = true; BillEntity.CopyProperties(other.Bill); ExpenseEntities.Clear(); foreach (var item in other.Expenses) { var expense = new Expense(); expense.CopyProperties(item); ExpenseEntities.Add(expense); } }
private void Bill_Load(object sender, EventArgs e) { txtTestNo.Text = Id; en = re.Credentials(Id); txtPatient.Text = en.Name; txtAge.Text = en.Age.ToString(); txtSex.Text = en.Sex; txtReference.Text = en.Reference; txtTests.Text = en.Tests; txtPrice.Text = en.Price; txtTotal.Text = en.Total; txtDiscount.Text = en.Discount; dtpDate.Text = en.Date; dtpTime.Text = en.Time; }
/// <summary> /// 新增记录 /// </summary> /// <param name="params"></param> /// <returns></returns> public ServiceResult CreateBill(BillEntity @params) { try { using (KeepDbContext context = new KeepDbContext()) { @params.Id = Guid.NewGuid(); @params.CreateDate = DateTime.Now; context.Bill.Add(@params); context.SaveChanges(); return(new ServiceResult()); } } catch (Exception ex) { ComLogger.ErrorTag("CreateBill", ex.InnerException.StackTrace); return(new ServiceResult(1, ex.Message)); } }
public BillEntity UpdateBill(BillEntity bill) { var billToUpdate = dbContext.Bills.AsQueryable().FirstOrDefault(x => x.BillId == bill.BillId); if (billToUpdate == null) { return(null); } billToUpdate.Amount = bill.Amount; billToUpdate.ModifiedBy = bill.ModifiedBy; billToUpdate.ModifiedDate = DateTime.Now; billToUpdate.PersonId = bill.PersonId; billToUpdate.Description = bill.Description; dbContext.SaveChanges(); return(billToUpdate); }
internal void printLabel(string content) { if (string.IsNullOrEmpty(content)) { return; } BillEntity billEntity = JsonConvert.DeserializeObject <BillEntity>(content); if (billEntity == null) { return; } List <BillCommodityEntity> commoditys = billEntity.commoditys; if (commoditys != null && commoditys.Count > 0) { foreach (BillCommodityEntity billCommodityEntity in commoditys) { if ("1".Equals(billCommodityEntity.pricing)) {//称重商品 PrintOneLable(billCommodityEntity, ""); } else { Double doubleCount = Double.Parse(billCommodityEntity.salenums); int count = (int)doubleCount;//Int32.Parse(billCommodityEntity.salenums); if (count > 1) { for (int m = 1; m <= count; m++) { PrintOneLable(billCommodityEntity, " (" + m + "/" + count + ")"); } } else { PrintOneLable(billCommodityEntity, ""); } } } NewUsb.CloseUSBPort(); } }
public IActionResult AddBill(AddBillViewModel model) { if (!ModelState.IsValid) { return(View()); } var entity = new BillEntity { CreatedBy = HttpContext.User.Identity.Name, CreatedDate = DateTime.Now, Description = model.Description, PersonId = model.PersonId, Amount = model.Amount, BillDate = model.BillDate }; _billsService.AddBill(entity); return(View(new AddBillViewModel())); }
public BillEntity ConvertToEntity(DataRow row) { if (row == null) { return(null); } var en = new BillEntity(); en.Name = row["name"].ToString(); en.Age = int.Parse(row["age"].ToString()); en.Sex = row["sex"].ToString(); en.Reference = row["reference"].ToString(); en.Tests = row["tests"].ToString(); en.Price = row["price"].ToString(); en.Discount = row["discount"].ToString(); en.Total = row["total"].ToString(); en.Date = row["date"].ToString(); en.Time = row["time"].ToString(); return(en); }