public IActionResult Post([FromBody] DTO.Transaction transactionDTO) { var newTransaction = _mapper.Map <Transaction>(transactionDTO); _transactionRepo.Add(newTransaction); return(Created(string.Format("/api/transaction/{0}", newTransaction.ID), _mapper.Map <DTO.Transaction>(newTransaction))); }
public async Task <ActionResult <bool> > DoTransaction(DTO.Transaction transaction) { if (transaction.FromAccountId == transaction.ToAccountId) { return(BadRequest("Not Makes sense to transfer to yourself")); } var res = await _transactionService.DoTransactionAsync(_mapper.Map <Services.Models.Transaction>(transaction)); return(res); }
private void btnPrint_Click(object sender, EventArgs e) { string printerName = "Posiflex PP6900 Partial Cut v3.01"; // Your Printer Name System.Drawing.Printing.PrintDocument doctoprint = new System.Drawing.Printing.PrintDocument(); doctoprint.PrinterSettings.PrinterName = printerName; int rawKind = 0; for (int i = 0; i <= doctoprint.PrinterSettings.PaperSizes.Count - 1; i++) { if (doctoprint.PrinterSettings.PaperSizes[i].PaperName == "3.14 x 6 in") // "LXP : Your Page Size" { rawKind = Convert.ToInt32(doctoprint.PrinterSettings.PaperSizes[i].GetType().GetField ("kind", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes[i])); break; } } if (txtRecieve.Text != "") { //MakeOver_Paris.rpt_saleinvoice rpt = new rpt_saleinvoice(); MakeOver_Paris.rpt_test rpt = new rpt_test(); rpt.Refresh(); rpt.SetParameterValue("p_invoiceid", invoiceid); rpt.SetParameterValue("p_received", decimal.Parse(txtRecieve.Text)); try { rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA5; rpt.PrintToPrinter(1, false, 0, 0); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } DTO.Transaction transaction = new DTO.Transaction(); transaction.Incomeamount = decimal.Parse(txtTotal.Text); transaction.Createdby = UserSession.Session.Staff; transaction.Remark = "InvoiceID: " + invoiceid; new DAO.TransactionDAO().AddTransaction(transaction); this.Dispose(); } }
private void btnSave_Click(object sender, EventArgs e) { if (id == 0) { if (txtExpenseAmount.Text == "" && txtIncomeAmount.Text == "") { MessageBox.Show("សូមបំពេញពត៏មានឲ្យបានត្រឹមត្រូវ!!!"); } else { DTO.Staff staff = new DTO.Staff(); // GET FROM USER SESSION staff.Staffid = UserSession.Session.Staff.Staffid; // CONVERTING VALIDATION decimal incomeAmount = 0; decimal expenseAmount = 0; if (txtIncomeAmount.Text != "") incomeAmount = System.Convert.ToDecimal(txtIncomeAmount.Text); else incomeAmount = 0; if (txtExpenseAmount.Text != "") expenseAmount = System.Convert.ToDecimal(txtExpenseAmount.Text); else expenseAmount = 0; DTO.Transaction tran = new DTO.Transaction(incomeAmount , expenseAmount , staff , txtRemark.Text); if (new TransactionDAO().AddTransaction(tran)) { txtIncomeAmount.Clear(); txtExpenseAmount.Clear(); txtRemark.Clear(); txtIncomeAmount.Enabled = true; txtExpenseAmount.Enabled = true; dgvTransaction.DataSource = new DAO.TransactionDAO().GetAllTransactions().Tables[0]; id = 0; } else { MessageBox.Show("ប្រតិបត្តិការណ៍បរាជ័យ!!!"); } } } else { DTO.Staff staff = new DTO.Staff(); // GET FROM USER SESSION staff.Staffid = UserSession.Session.Staff.Staffid; // CONVERTING VALIDATION decimal incomeAmount = 0; decimal expenseAmount = 0; if (txtIncomeAmount.Text != "") incomeAmount = System.Convert.ToDecimal(txtIncomeAmount.Text); else incomeAmount = 0; if (txtExpenseAmount.Text != "") expenseAmount = System.Convert.ToDecimal(txtExpenseAmount.Text); else expenseAmount = 0; DTO.Transaction tran = new DTO.Transaction(incomeAmount , expenseAmount , staff , txtRemark.Text); tran.Transactionid = id; if (new TransactionDAO().UpdateTransaction(tran)) { txtIncomeAmount.Clear(); txtExpenseAmount.Clear(); txtRemark.Clear(); txtIncomeAmount.Enabled = true; txtExpenseAmount.Enabled = true; dgvTransaction.DataSource = new DAO.TransactionDAO().GetAllTransactions().Tables[0]; id = 0; } else { } } getBalance(); }
public Task SaveIncome(DTO.Transaction income) { return(_incomeBusiness.SaveIncome(_mapperService.Map <Transaction>(income))); }
public IActionResult CheckOut([Bind("DeliveryAddress", "DeliveryPhone")] DTO.Transaction tran) { string generateAccTranID() { string id; Random rd = new Random(); TransactionDAO dao = new TransactionDAO(_context); do { id = "AT"; for (int i = 0; i < 4; i++) { id += rd.Next(10); } } while (dao.CheckExisted(id)); return(id); } AccessoryDAO accDAO = new AccessoryDAO(_context); string userName = HttpContext.Session.GetString("USER"); Dictionary <string, DTO.Accessory> shoppingCart = HttpContext.Session.GetCollectionFromJson <Dictionary <string, DTO.Accessory> >("cart"); foreach (var item in shoppingCart) { string id = item.Key; DTO.Accessory dtoSession = item.Value; DTO.Accessory accDTO = accDAO.FindByPrimaryKey(id); if (accDTO.IsDelete || accDTO.AvailableQuantity == 0 || accDTO.AvailableQuantity < dtoSession.Quantity) { return(RedirectToAction("Index", "ShoppingCart")); } } TransactionDAO tranDAO = new TransactionDAO(_context); string accTranID = generateAccTranID(); DTO.Transaction tranDTO = new DTO.Transaction(accTranID, userName, tran.DeliveryPhone, tran.DeliveryAddress, 0); tranDAO.Insert(tranDTO); double total = 0; List <DTO.Accessory> list = new List <DTO.Accessory>(); foreach (var item in shoppingCart) { string id = item.Key; DTO.Accessory dtoSession = item.Value; DTO.Accessory accDTO = accDAO.FindByPrimaryKey(id); DTO.TransactionRel tranRelDTO = new DTO.TransactionRel(id, accTranID, accDTO.AccName, accDTO.AccCatId, accDTO.Brand, accDTO.Description, accDTO.Image, accDTO.Price, accDTO.SalePercent, accDTO.StartSellingDate, dtoSession.Quantity, accDTO.AccCatName); TransactionRelDAO tranRelDAO = new TransactionRelDAO(_context); tranRelDAO.Insert(tranRelDTO); accDTO.AvailableQuantity -= dtoSession.Quantity; total += dtoSession.Quantity * accDTO.Price * (1 - accDTO.SalePercent); list.Add(accDTO); } accDAO.Update(list); total = (double)Math.Round(total * 100) / 100; tranDTO.TotalPrice = total; tranDAO.UpdateTotalPrice(total, accTranID); shoppingCart.Clear(); HttpContext.Session.SetCollectionAsJson("cart", shoppingCart); return(RedirectToAction("UserDetails", "Principal")); }
public Task SaveExpense(DTO.Transaction expense) { return(_expenseBusiness.SaveExpense(_mapperService.Map <Transaction>(expense))); }
public Task SaveIncome(DTO.Transaction income) { return(_budgetBusiness.SaveIncome(_mapperService.Map <Business.Models.Transaction>(income))); }
public Task SaveExpense(DTO.Transaction expense) { return(_budgetBusiness.SaveExpense(_mapperService.Map <Business.Models.Transaction>(expense))); }