public ReceiptModel CreateReceipt(ReceiptModel receipt) { try { OpenConnection(); OleDbCommand command = connection.CreateCommand(); command.CommandText = $"INSERT INTO RECEIPT(Price,Receipt_date,Receipt_Time) " + $"VALUES (@price,@date,@time)"; command.Parameters.AddWithValue("price", receipt.Price); command.Parameters.AddWithValue("date", receipt.Date); command.Parameters.AddWithValue("time", receipt.Time); int result = command.ExecuteNonQuery(); if (result > 0) { command.CommandText = $"SELECT @@IDENTITY AS ID"; int receiptID = int.Parse(command.ExecuteScalar().ToString()); receipt.ID = receiptID; } } catch (Exception ex) { receipt = null; } finally { CloseConnection(); } return(receipt); }
public IActionResult AddReceipt([FromBody] JObject data) { var LoginUserIdentifier = ""; try { //gets the login token from Auth0 LoginUserIdentifier = User.FindFirst(ClaimTypes.NameIdentifier).Value; } catch (Exception e) { LoginUserIdentifier = ""; } var connStr = _config["ConnectionStrings:DefaultConnection"]; ReceiptModel receiptModel = data["receipt"].ToObject <ReceiptModel>(); using (IDbConnection db = new SqlConnection(connStr)) { var SqlStr = @"insert into Receipts(Date,Store,Tax,TotalAmount,ImageGuid,Auth0ID) values (@Date,@Store,@Tax,@TotalAmount,@ImageGuid,@LoginUserIdentifier )"; var result = db.Execute(SqlStr, new { Date = receiptModel.Date, Store = receiptModel.Store, Tax = receiptModel.Tax, TotalAmount = receiptModel.TotalAmount, ImageGuid = receiptModel.ImageGuid, LoginUserIdentifier = LoginUserIdentifier } ); } return(Ok()); }
// GET: Receipt public ActionResult Index(Guid?id) { ReceiptModel receipt = new ReceiptModel(); using (MemberEntities1 entities = new MemberEntities1()) { var r = entities.Orders.Single(x => x.OrderId == id); receipt.FirstName = r.FirstName; receipt.LastName = r.LastName; receipt.saleTotal = r.Cart.saleTotal; receipt.arrivalTime = r.Cart.arrivalTime; receipt.departureTime = r.Cart.departureTime; receipt.origin = r.Cart.origin; receipt.destination = r.Cart.destination; receipt.carrier = r.Cart.carrier; receipt.number = r.Cart.number; receipt.stops = r.Cart.stops; receipt.BillingStreet1 = r.BillingStreet1; receipt.BillingStreet2 = r.BillingStreet2; receipt.BillingCity = r.BillingCity; receipt.BillingState = r.BillingState; receipt.BillingPostalCode = r.BillingPostalCode; receipt.InvoiceDate = r.DateLastModified; } return(View(receipt)); }
public void CreateInvoice(ReceiptModel model) { string connectionString = "Data Source=localhost\\SQLExpress;Initial Catalog=Financials; Integrated Security=true"; string queryString = $@" INSERT INTO Receipt ( ReceiptNumber, Date, Company, Amount, Revenue_Expense) VALUES ( @ReceiptNumber, @Date, @Company, @Amount, @Revenue_Expense)"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(queryString, connection); command.Parameters.AddWithValue("@ReceiptNumber", model.ReceiptNumber); command.Parameters.AddWithValue("@Date", model.Date); command.Parameters.AddWithValue("@Company", model.Company); command.Parameters.AddWithValue("@Amount", model.Amount); command.Parameters.AddWithValue("@Revenue_Expense", (int)model.Revenue_Expense); try { connection.Open(); command.ExecuteNonQuery(); } catch (Exception ex) { throw; } } }
public void PostReceipt(ReceiptModel model) { model.ReceiptNumber = "GRN00001"; // should be taken from LN using (var transaction = _dbContext.Database.BeginTransaction()) { try { var receipt = _dbContext.Receipts.Add(new Receipts { RcptCreatedby = CurrentUserId, RcptCreateddate = DateTime.UtcNow, RcptGetrId = model.GateEntryId, RcptProrId = model.OrderId, RcptReceiptno = model.ReceiptNumber }); if (SaveDbChanges()) { _dbContext.Receiptlines.AddRange(bindReceiptLines(model.ReceiptLines, receipt.Entity.RcptId)); if (SaveDbChanges()) { transaction.Commit(); } else { transaction.Rollback(); } } } catch (Exception ex) { transaction.Rollback(); throw ex; } } }
public ActionResult DoCreateReceipt(string json) { ReceiptModel receiptModel = JsonConvert.DeserializeObject <ReceiptModel>(json); List <ReceiptDetailModel> details = receiptModel.ReceiptDetailModel; double Total = 0; foreach (ReceiptDetailModel detail in details) { Total = Total + detail.TotalAmount * detail.Quantity + detail.TotalAmount_gift * detail.Quantity_gift; } info.InsertReceipt(DateTime.Now, Total, "VND", "Waiting"); int ReceiptID = info.GetLastReceiptID(); foreach (ReceiptDetailModel detail in details) { int IngreID = detail.IngreID; int GiftID = detail.GiftID; if (IngreID != 0) { Ingredient ingre = info.GetIngredientByIngreID(IngreID); bool result = info.InsertReceiptDetailMissGiftID(ReceiptID, IngreID, detail.Quantity, ingre.Unit, ingre.UnitPrice, detail.ReferenceDesc, ingre.Currency, "Waiting"); } if (GiftID != 0) { Gift gift = infoDV.GetGiftByID(GiftID); bool result = info.InsertReceiptDetailMissIngreID(ReceiptID, GiftID, detail.Quantity_gift, gift.UnitPrice, detail.ReferenceDesc_gift, gift.Currency, "Waiting"); } } return(Json(new { SupplierID = receiptModel.SupplierID }, JsonRequestBehavior.AllowGet)); }
public ViewReceiptViewModel(ReceiptModel receipt, bool customer_fixed = false) { Receipt = receipt; // Fill Customers CustomerModel customers = new CustomerModel(); DataTable cs = customers.All(); Customers = customers.GiveCollection(cs); // Fill Seasons SeasonModel sm = new SeasonModel(); DataTable ss = sm.All(); Seasons = sm.GiveCollection(ss); //Fill Currencies CurrencyModel currency = new CurrencyModel(); DataTable cc = currency.All(); Currencies = currency.GiveCollection(cc); FillForm(cs, ss, cc); Enabled = false; MainButtonText = "Enable Editing"; FactureChanged = false; IsCustomerFixed = customer_fixed; if (customer_fixed == false) { IsCustomerEnabled = Enabled; } else { IsCustomerEnabled = false; } }
public bool InsertReceiptDetails(string companyCode, int companyId, ReceiptModel ObjReceipt, string created_by) { bool result = false; try { using (IDbConnection connection = IDbOpenConnection()) { var p = new DynamicParameters(); p.Add("@CompanyCode", companyCode); p.Add("@CompanyId", companyId); p.Add("@OrderId", ObjReceipt.Order_Id); p.Add("@Invoice_Number", ObjReceipt.Invoice_Number); p.Add("@Invoice_Date", ObjReceipt.Invoice_Date); p.Add("@Quantity", ObjReceipt.Quantity); p.Add("@Remarks", ObjReceipt.Remarks); p.Add("@CreatedBy", created_by); connection.Execute(SP_HD_PRM_INSERTRECIEPTDETAILS, p, commandType: CommandType.StoredProcedure); result = true; connection.Close(); } } catch (Exception ex) { throw; } return(result); }
public PurchaseForPurchaseController CreatePurchase(Guid customerId, [FromBody] ReceiptModel receiptModel) { Shop shop = shopRepository.CreateShop( Convert.ToInt64(receiptModel.UserInn), receiptModel.User, receiptModel.RetailPlaceAddress); Customer customer = customerRepository.GetCustomer(customerId); Purchase purchase = purchaseRepository.CreatePurchase( customer.Id, shop.Id, Convert.ToDateTime(receiptModel.DateTime), receiptModel.TotalSum ); foreach (var item in receiptModel.Items) { Product product = productRepository.CreateProduct(item.Name); ProductItem productItem = productItemRepository.CreateProductItem( product.Id, purchase.Id, item.Price / 100, item.Quantity, item.Sum / 100); } PurchaseForPurchaseController purchaseInfo = Mapper.Map <Purchase, PurchaseForPurchaseController>(purchaseRepository.GetUserPurchase(purchase.Id, customerId)); return(purchaseInfo); }
public List <ReceiptModel> GetReceiptModels() { try { var data = tRSEntities.ReceiptMasters.Where(x => x.IsActive == true).ToList(); List <ReceiptModel> receipts = new List <ReceiptModel>(); foreach (var item in data) { ReceiptModel model = new ReceiptModel { id = item.id, BMRno = item.BMRno, BMRdate = item.BMRdate, Cash = item.Cash, Chequeno = item.Chequeno, Chequedate = item.Chequedate, Receivedamount = item.Receivedamount, Billno = item.Billno, Billamount = item.Billamount, TDS = item.TDS, FreightDeduction = item.FreightDeduction, Etc = item.Etc, remark = item.remark, financeeffect = item.financeeffect, IsActive = (bool)item.IsActive, }; receipts.Add(model); } return(receipts); } catch (Exception e) { throw e; } }
public bool UpdateReceipt(ReceiptModel model) { try { var data = tRSEntities.ReceiptMasters.Where(x => x.id == model.id && x.IsActive == true).FirstOrDefault(); if (data != null) { data.BMRno = model.BMRno; data.BMRdate = model.BMRdate; data.Cash = model.Cash; data.Chequeno = model.Chequeno; data.Chequedate = model.Chequedate; data.Receivedamount = model.Receivedamount; data.Billno = model.Billno; data.Billamount = model.Billamount; data.TDS = model.TDS; data.FreightDeduction = model.FreightDeduction; data.Etc = model.Etc; data.remark = model.remark; data.financeeffect = model.financeeffect; data.IsActive = true; tRSEntities.SaveChanges(); return(true); } else { return(false); } } catch (Exception e) { throw e; } }
public async Task <IActionResult> Receipt(int id) { if (id == 0) { return(NotFound()); } var parkedVehicle = await _context.ParkedVehicle.FindAsync(id); if (parkedVehicle == null) { return(NotFound()); } else { var nRM = new ReceiptModel { RegistrationNum = parkedVehicle.RegistrationNum, VehicleType = (VehicleType)parkedVehicle.VehicleType, Id = parkedVehicle.Id, EnteringTime = parkedVehicle.EnteringTime, TotalTimeParked = DateTime.Now - parkedVehicle.EnteringTime, Price = (int)(DateTime.Now - parkedVehicle.EnteringTime).TotalMinutes * 10 / 60, }; return(View(nRM)); } }
public void Update(ReceiptModel model) { var sSql = @" UPDATE Receipt SET Tgl = @Tgl, Jam = @Jam, PurchaseID = @PurchaseID, SupplierID = @SupplierID, Keterangan = @Keterangan, TotalHarga = @TotalHarga, Diskon = @Diskon, BiayaLain = @BiayaLain, GrandTotal = @GrandTotal WHERE ReceiptID = @ReceiptID "; using (var conn = new SqlConnection(_connString)) using (var cmd = new SqlCommand(sSql, conn)) { cmd.AddParam("@ReceiptID", model.ReceiptID); cmd.AddParam("@Tgl", model.Tgl.ToTglYMD()); cmd.AddParam("@Jam", model.Jam); cmd.AddParam("@PurchaseID", model.PurchaseID); cmd.AddParam("@SupplierID", model.SupplierID); cmd.AddParam("@Keterangan", model.Keterangan); cmd.AddParam("@TotalHarga", model.TotalHarga); cmd.AddParam("@Diskon", model.Diskon); cmd.AddParam("@BiayaLain", model.BiayaLain); cmd.AddParam("@GrandTotal", model.GrandTotal); conn.Open(); cmd.ExecuteNonQuery(); } }
public ReceiptViewModel() { // Fill Receipts ReceiptModel receipt = new ReceiptModel(); Receipts = receipt.GiveCollection(receipt.All()); }
public ActionResult Approve(ReceiptModel model) { var receipt = _receiptRepository.GetById(model.Id); Validate(model, receipt, WorkflowActionName.Approve); if (ModelState.IsValid) { receipt = model.ToEntity(receipt); if (receipt.IsNew == true) { string number = _autoNumberService.GenerateNextAutoNumber(_dateTimeHelper.ConvertToUserTime(DateTime.UtcNow, DateTimeKind.Utc), receipt); receipt.Number = number; } //always set IsNew to false when saving receipt.IsNew = false; //update attributes _receiptRepository.Update(receipt); //commit all changes in UI this._dbContext.SaveChanges(); //approve _receiptService.Approve(receipt); //notification SuccessNotification(_localizationService.GetResource("Record.Saved")); return(Json(new { number = receipt.Number, isApproved = receipt.IsApproved })); } else { return(Json(new { Errors = ModelState.SerializeErrors() })); } }
public void Insert(ReceiptModel model) { var sSql = @" INSERT INTO Receipt ( ReceiptID, Tgl, Jam, PurchaseID, SupplierID, Keterangan, TotalHarga, Diskon, BiayaLain, GrandTotal) VALUES ( @ReceiptID, @Tgl, @Jam, @PurchaseID, @SupplierID, @Keterangan, @TotalHarga, @Diskon, @BiayaLain, @GrandTotal) "; using (var conn = new SqlConnection(_connString)) using (var cmd = new SqlCommand(sSql, conn)) { cmd.AddParam("@ReceiptID", model.ReceiptID); cmd.AddParam("@Tgl", model.Tgl.ToTglYMD()); cmd.AddParam("@Jam", model.Jam); cmd.AddParam("@PurchaseID", model.PurchaseID); cmd.AddParam("@SupplierID", model.SupplierID); cmd.AddParam("@Keterangan", model.Keterangan); cmd.AddParam("@TotalHarga", model.TotalHarga); cmd.AddParam("@Diskon", model.Diskon); cmd.AddParam("@BiayaLain", model.BiayaLain); cmd.AddParam("@GrandTotal", model.GrandTotal); conn.Open(); cmd.ExecuteNonQuery(); } }
//查詢單一發票 public ReceiptModel GetReceipt(string ReceiptNumber) { string queryString = $@" SELECT * FROM Receipt WHERE ReceiptNumber = @ReceiptNumber "; List <SqlParameter> dbParameters = new List <SqlParameter>() { new SqlParameter("@ReceiptNumber", ReceiptNumber), }; ReceiptModel model = null; var dt = this.GetDataTable(queryString, dbParameters); if (dt.Rows.Count != 0) { model = new ReceiptModel(); model.ReceiptNumber = (string)dt.Rows[0]["ReceiptNumber"]; model.Date = (DateTime)dt.Rows[0]["Date"]; model.Company = dt.Rows[0]["Company"].ToString(); model.Amount = (Decimal)dt.Rows[0]["Amount"]; model.Revenue_Expense = (Revenue_Expense)dt.Rows[0]["Revenue_Expense"]; } return(model); }
public CreateReceiptViewModel(ReceiptModel receipt = null) { // Fill Customers CustomerModel customers = new CustomerModel(); Customers = customers.GiveCollection(customers.All()); // Fill Seasons SeasonModel sm = new SeasonModel(); Seasons = sm.GiveCollection(sm.All()); //Fill Currencies CurrencyModel currency = new CurrencyModel(); Currencies = currency.GiveCollection(currency.All()); Delivery = DateTime.UtcNow.Date; if (receipt != null) { for (int i = 0; i < Customers.Count; i++) { int id1 = Customers[i].Id; int id2 = (int)receipt.Customer; if (id1 == id2) { Customer = Customers[i]; break; } } IsEnabled = false; } else { IsEnabled = true; } }
private static NdmTransaction MapTransaction(TransactionModel transaction, ReceiptModel receipt) { var isPending = receipt is null; return(new NdmTransaction(transaction.ToTransaction(), isPending, (long)(receipt?.BlockNumber ?? 0), receipt?.BlockHash, (long)(receipt?.GasUsed ?? 0))); }
//修改發票 public void UpdateReceipt(ReceiptModel model) { string queryString = $@" UPDATE Receipt SET ReceiptNumber = @ReceiptNumber, Date = @Date, Company = @Company, Amount = @Amount, Revenue_Expense = @Revenue_Expense, ModifyDate = @ModifyDate, Modifier = @Modifier WHERE ReceiptNumber = @ReceiptNumber; "; List <SqlParameter> parameters = new List <SqlParameter>() { new SqlParameter("@ReceiptNumber", model.ReceiptNumber), new SqlParameter("@Date", model.Date), new SqlParameter("@Company", model.Company), new SqlParameter("@Amount", model.Amount), new SqlParameter("@Revenue_Expense", (int)model.Revenue_Expense), new SqlParameter("@ModifyDate", DateTime.Now), new SqlParameter("@Modifier", "Brian"), }; this.ExecuteNonQuery(queryString, parameters); }
public async Task BillingService_WillPass() { // arrange var order = new OrderModel( "1", "1", 1, PaymentGateway.Braintree.ToString(), "1" ); var receipt = new ReceiptModel("Test"); var paymentProcesorMock = new Mock <IPaymentProcessor>(); var billingService = new BillingService(new List <IPaymentProcessor>() { paymentProcesorMock.Object }); paymentProcesorMock.SetupGet(x => x.PaymentGateway).Returns(PaymentGateway.Braintree); paymentProcesorMock.Setup(x => x.ProcessAsync(It.IsAny <OrderModel>())).ReturnsAsync(receipt); // act var resultReceipt = await billingService.ProcessAsync(order); // assert Assert.AreEqual(receipt, resultReceipt); }
public ReceiptModel GetReceiptModel(int id) { try { var data = tRSEntities.ReceiptMasters.Where(x => x.id == id && x.IsActive == true).FirstOrDefault(); if (data != null) { ReceiptModel model = new ReceiptModel(); model.id = data.id; model.BMRno = data.BMRno; model.BMRdate = data.BMRdate; model.Cash = data.Cash; model.Chequeno = data.Chequeno; model.Chequedate = data.Chequedate; model.Receivedamount = data.Receivedamount; model.Billno = data.Billno; model.Billamount = data.Billamount; model.TDS = data.TDS; model.FreightDeduction = data.FreightDeduction; model.Etc = data.Etc; model.remark = data.remark; model.financeeffect = data.financeeffect; return(model); } else { return(null); } } catch (Exception e) { throw e; } }
private void pbSPAdd_Click(object sender, EventArgs e) { BindingSource bslistSP = (BindingSource)dgvSP.DataSource; BindingList <ReceiptModel> listSP = (BindingList <ReceiptModel>)bslistSP.DataSource; if (seqNo > 0 && modify == true) { var model = (from rcpt in listSP where rcpt.SeqNo == seqNo select rcpt).FirstOrDefault(); if (model != null) { model.TDate = dtDate.Value; model.PCode = Convert.ToString(cmbProductCode.SelectedValue); model.BarCode = txtBarCode.Text.Trim(); model.MetalType = Convert.ToString(cmbMetal.SelectedValue); model.InType = "IN"; model.RefVNo = voucherNo; model.RefVouType = "R"; model.JobNo = Convert.ToInt32(cmbJobeCode.SelectedValue); model.OrderNo = Convert.ToInt32(cmbOrderNo.SelectedValue); model.Pcs = Convert.ToDecimal(txtPCs.Text.Trim()); model.GrossWt = Convert.ToDecimal(txtGsWt.Text.Trim()); model.NetWt = Convert.ToDecimal(txtNetWt.Text.Trim()); model.MakingRate = Convert.ToDecimal(txtMakingRate.Text.Trim()); model.TotalRate = Convert.ToDecimal(txtTotalRate.Text.Trim()); model.SellingRate = Convert.ToDecimal(txtSellingRate.Text.Trim()); model.Photo = pbPhoto.ImageLocation; model.ProdImage = pbPhoto.Image; } } else { ReceiptModel model = new ReceiptModel(); model.SeqNo = listSP.Count + 1; model.TDate = dtDate.Value; model.PCode = Convert.ToString(cmbProductCode.SelectedValue); model.BarCode = txtBarCode.Text.Trim(); model.MetalType = Convert.ToString(cmbMetal.SelectedValue); model.InType = "IN"; model.RefVNo = 0; model.RefVouType = "R"; model.JobNo = Convert.ToInt32(cmbJobeCode.SelectedValue); model.OrderNo = Convert.ToInt32(cmbOrderNo.SelectedValue); model.Pcs = Convert.ToDecimal(txtPCs.Text.Trim()); model.GrossWt = Convert.ToDecimal(txtGsWt.Text.Trim()); model.NetWt = Convert.ToDecimal(txtNetWt.Text.Trim()); model.MakingRate = Convert.ToDecimal(txtMakingRate.Text.Trim()); model.TotalRate = Convert.ToDecimal(txtTotalRate.Text.Trim()); model.SellingRate = Convert.ToDecimal(txtSellingRate.Text.Trim()); model.Photo = pbPhoto.ImageLocation; model.ProdImage = pbPhoto.Image; listSP.Add(model); } var bindingList = new BindingList <ReceiptModel>(listSP); var source = new BindingSource(bindingList, null); dgvSP.DataSource = source; ResetInputControls(); }
public ReceiptGenerator(ReceiptModel receiptModel) { _student = receiptModel.Student; _classTermFee = receiptModel.ClassTermFee; _school = receiptModel.School; _feePayment = _student.FeePayments.FirstOrDefault(x => x.ClassArmTermFeeId == _classTermFee.Id); }
public async Task <ReceiptModel> Post([FromBody] OrderModel order) { await billingService.ProcessOrder(order); ReceiptModel receipt = order.CreateReceipt(); return(receipt); }
public void CreateReceipt() { ReceiptModel receipt = new ReceiptModel { Customer = Customer.Id }; ActivateItem(new CreateReceiptViewModel(receipt)); }
public void Setup() { Task.Run(async() => { await recProc.ExtractReceipt(imageFilePath); }).GetAwaiter().GetResult(); rM = recProc.Receipt; }
public ActionResult Receipt(Vehicle vehicle) { ReceiptModel model = new ReceiptModel(); model.Vehicle = vehicle; model.Cost = Convert.ToInt32((DateTime.Now - vehicle.WhenParked).TotalMinutes).ToString("C", System.Globalization.CultureInfo.CurrentCulture); return(PartialView(model)); }
protected void btnSave_Click(object sender, EventArgs e) { //建立資料model及ReceiptManager的物件 var manager = new ReceiptManager(); var model = new ReceiptModel(); //建立5個變數來存取各個輸入值 string inputRecNo = this.txtReceiptNumber.Text.Trim(); string inputDate = this.lbDate.Text.Trim(); string dplCompany = this.dplCompany.SelectedValue; string inputAmount = this.txtAmount.Text.Trim(); string dplRE = this.dplRE.SelectedValue; //檢查輸入值(發票號碼、日期、金額) if (string.IsNullOrEmpty(inputRecNo) || string.IsNullOrEmpty(inputAmount) || string.Equals(inputDate, "請選擇日期")) { //日期沒輸入會變成紅色 if (string.Equals(inputDate, "請選擇日期")) { this.lbDate.ForeColor = System.Drawing.Color.Red; } this.lblMsg.Text = "請填入完整的發票資料"; return; } else if (ReceiptDetailHelper.checkReceiptNumber(inputRecNo) != string.Empty) { this.lblMsg.Text = "請填入正確的發票格式"; return; } else if (ReceiptDetailHelper.checkAmount(inputAmount) != string.Empty) { this.lblMsg.Text = "金額只能填入數字"; return; } //上面檢查都通過後,將輸入值存入資料model model.ReceiptNumber = inputRecNo; model.Date = DateTime.Parse(inputDate); model.Company = dplCompany; model.Amount = decimal.Parse(inputAmount); model.Revenue_Expense = (Revenue_Expense)Enum.Parse(typeof(Revenue_Expense), dplRE); //分成更新模式及新增模式 //更新模式下將資料model更新至資料庫 //新增模式下將資料model存入資料庫 if (ReceiptDetailHelper.isUpdateMode()) { manager.UpdateReceipt(model); this.lblMsg.Text = "發票更新成功"; } else { manager.CreateReceipt(model); this.lblMsg.Text = "發票新增成功"; } }
public async Task <int> DeleteReceiptAsync(ReceiptModel model) { var receipt = new Receipt { ReceiptId = model.ReceiptId }; using (var dataService = DataServiceFactory.CreateDataService()) { return(await dataService.DeleteReceiptAsync(receipt)); } }
/// <summary> /// Create a new receipt object using all data collected from the order so far, and then store this in a list /// for use later. /// </summary> private void CreateReceipt() { CheckCustomerFields(); CustomerInfo customer = ReceiptLogic.CreateCustomer(txtCustomerName.Text, txtCustomerAddress.Text, txtCustomerPostcode.Text); OrderItems items = ReceiptLogic.PopulateOrderItems(pizzas, sides, drinks); MonetaryValues money = ReceiptLogic.PopulateMonetaryValues(deals, CalculateBasePrice()); ReceiptModel receipt = ReceiptLogic.CreateReceipt(customer, items, money); receipts.Add(receipt); }
private void btnSubmit_Click(object sender, EventArgs e) { var session = cboSession.SelectedValue; var term = cboTerm.SelectedValue; var amount = tboAmount.Text.Replace(",", ""); var paidBy = tboPaidBy.Text; if (session != "" && term != "" && !string.IsNullOrWhiteSpace(paidBy) && !string.IsNullOrWhiteSpace(amount)) { decimal result; if (decimal.TryParse(amount, out result)) { var id = _row.Cells["Id"].Value.ToString(); var classEnum = (ClassEnum)_row.Cells["PresentClassEnum"].Value; // session, class, var classTermFee = _classTermFeeRepository.GetFees(session.ToString(), (TermEnum)term, classEnum); var student = _studentRepository.GetStudentById(id); // Update student fees var feePayment = new FeePayment() { Amount = Convert.ToDecimal(amount), PaidDate = DateTime.Now, ClassArmTermFeeId = classTermFee.Id, HasCollectedReceipt = chkPrintReceipt.Checked, Bank = tboBank.Text == "" ? null : tboBank.Text, ReceiptNumber = tboReceiptNo.Text == "" ? null : tboReceiptNo.Text, ChequeNumber = tboChequeNo.Text == "" ? null : tboChequeNo.Text, Comment = rtboComment.Text == "" ? null : rtboComment.Text, PaidBy = tboPaidBy.Text }; student.FeePayments.Add(feePayment); student.OutstandingFee -= Convert.ToDecimal(amount); student.PaidFee += Convert.ToDecimal(amount); var updateSuccess = _studentRepository.Update(student); if (updateSuccess) { MessageBox.Show(@"Fees paid", @"Pay Fees"); var receiptModel = new ReceiptModel() { ClassTermFee = classTermFee, Student = student, School = _school }; // Generate receipt var receipt = new ReceiptGenerator(receiptModel); var path = receipt.Generate(); Close(); // If print receipt check box is checked, open pdf file(recipt) if (chkPrintReceipt.Checked) { //Process.Start(path); // _printDocument.DocumentName = path; //_printPreviewDialog.Document = _printDocument; // _printPreviewDialog.ShowDialog(); //PrintDialog pDialog = new PrintDialog(); //pDialog.Document = _printDocument; //if (pDialog.ShowDialog() == DialogResult.OK) //{ // _printDocument.DocumentName = path; // _printDocument.Print(); // } Utilities.SendToPrinter(path); } } } else { MessageBox.Show(@"Please, enter correct amount in the amount field.", @"School Accountant"); } } else { MessageBox.Show(@"Please, ensure that the session, paidby, term and the amount is filled", @"School Accountant"); } }