// Reject the book request. public ActionResult RejectRequest(int?tranId) { /*try * {*/ if (tranId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblTransaction transaction = transDb.tblTransactions.FirstOrDefault(t => t.TranId == tranId); if (transaction == null) { return(HttpNotFound()); } transaction.TranStatus = "Rejected"; transaction.TranDate = DateTime.Now.ToShortDateString(); tblBook book = bookDb.tblBooks.FirstOrDefault(b => b.BookId == transaction.BookId); book.BookCopies = book.BookCopies + 1; bookDb.SaveChanges(); transDb.SaveChanges(); return(View("Requests")); /*} * catch (Exception) * { * return new HttpStatusCodeResult(HttpStatusCode.BadRequest); * }*/ }
/// <summary> /// Insert TransactionType Information /// </summary> /// <param name="data">Transaction Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, int> Transaction(tblTransaction data) { erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { int propertyFind = db.tblTransaction.Count(); if (propertyFind > 0) { data.id = db.tblTransaction.Max(s => s.id); } else { data.id = 1; } db.tblTransaction.Add(data); result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); if (result > 0) { return(new Tuple <ErrorObject, int>(erros.IfError(false), data.id)); } else { return(new Tuple <ErrorObject, int>(erros.IfError(false), result)); } } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, int>(erros, 0)); } }
// Accepts the book return request. public ActionResult AcceptReturn(int?tranId) { /*try * {*/ if (tranId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblTransaction transaction = transDb.tblTransactions.FirstOrDefault(t => t.TranId == tranId); if (transaction == null) { return(HttpNotFound()); } tblBook book = bookDb.tblBooks.FirstOrDefault(b => b.BookId == transaction.BookId); book.BookCopies = book.BookCopies + 1; bookDb.SaveChanges(); transDb.tblTransactions.Remove(transaction); transDb.SaveChanges(); return(View("Return")); /*} * catch (Exception) * { * return new HttpStatusCodeResult(HttpStatusCode.BadRequest); * }*/ }
public int GetTripId_new(string wbid, string vartripid, string vartruck) { tblTransaction trans = db.tblTransactions.FirstOrDefault(x => x.WeighbridgeId == wbid && x.TruckNo == vartruck && x.TripId == Convert.ToInt32(vartripid)); if (trans != null) { if (db.tblTransactions.Count() > 0) { //int RowId = db.tblTransactions.OrderByDescending(x => x.WeighbridgeId == wbid).FirstOrDefault().Id; //return RowId; tblTransaction wei = (from a in db.tblTransactions join b in db.tblTransactions on a.Id equals b.TripId where a.WeighbridgeId == wbid && a.TruckNo == vartruck && a.TripId == Convert.ToInt32(vartripid) select b).ToList().Last(); return(wei.Id); } else { return(0); } } else { return(0); } }
public string CreatePendingRecord(string TripId, string truckNo) { TruckMaster _tmaster = _truckRepo.GetTruckMasterByTruckNo(truckNo); tblTransaction _trans = new tblTransaction(); tblTransaction trans = db.tblTransactions.Where(x => x.TruckNo == truckNo && x.TransactionStatus == 1).FirstOrDefault(); if (trans == null) { _trans.TripId = Convert.ToInt32(TripId); _trans.TruckNo = truckNo; _trans.TransporterCode = _tmaster.TransporterCode; _trans.TransporterName = _tmaster.TransporterName; _trans.WeighingUnit = _tmaster.UOMWeight; //_trans.CompanyCode = Session["CompanyCode"].ToString(); //_trans.PlantCode = Session["PlantID"].ToString(); _trans.TripType = 2; _trans.CreateDate = DateTime.Now; _trans.TransactionStatus = 1; _trans.IsMultiProduct = false; _trans.FirstWeight = Convert.ToDecimal(_tmaster.StoredTareWeight); _trans.FirstWtDateTime = _tmaster.StoredTareDateTime; db.tblTransactions.InsertOnSubmit(_trans); db.SubmitChanges(); } string myJsonString = (new JavaScriptSerializer()).Serialize(_trans); return(myJsonString); }
public int GetTripId(string wbid) { tblTransaction trans = db.tblTransactions.FirstOrDefault(x => x.WeighbridgeId == wbid); if (trans != null) { if (db.tblTransactions.Count() > 0) { //int RowId = db.tblTransactions.OrderByDescending(x => x.WeighbridgeId == wbid).FirstOrDefault().Id; //return RowId; tblTransaction wei = (from a in db.tblTransactions join b in db.tblTransactions on a.Id equals b.TripId where a.WeighbridgeId == wbid select b).ToList().Last(); return(wei.Id); } else { return(0); } } else { return(0); } }
public object SetPayment(string FlatNo, int PaymentID, string PaymentMode, string ChequeNo, decimal Amount, decimal Penalty) { var DC = new DataClassesDataContext(); tblTransaction TransactionObj = new tblTransaction(); TransactionObj.PaymentID = PaymentID; TransactionObj.PaymentMode = PaymentMode; TransactionObj.Penalty = Convert.ToDecimal(Penalty); TransactionObj.TransactionType = "Income"; TransactionObj.TransactionOn = DateTime.Now; TransactionObj.FlatNo = FlatNo; TransactionObj.Amount = Amount; if (ChequeNo != "") { TransactionObj.ChequeNo = ChequeNo; } DC.tblTransactions.InsertOnSubmit(TransactionObj); tblIncome IncomeObj = new tblIncome(); IncomeObj.Amount = Amount; IncomeObj.Description = "Maintenance from " + FlatNo + " with " + Penalty + " Penalty"; IncomeObj.IncomeName = "Maintenance from " + FlatNo; IncomeObj.PaymentMode = PaymentMode; IncomeObj.IncomeType = "Maintenance"; IncomeObj.IsDeleted = false; DC.tblIncomes.InsertOnSubmit(IncomeObj); DC.SubmitChanges(); return("True"); }
public void Update() { try { WealthDataContext oDc = new WealthDataContext(); tblTransaction transaction = oDc.tblTransactions.FirstOrDefault(p => p.Id == this.Id); if (transaction != null) { transaction.TransDate = this.TransDate; transaction.Buy = this.Buy; transaction.StockId = this.StockId; transaction.Quantity = this.Quantity; transaction.PricePerSharePaid = this.PricePerSharePaid; oDc.SubmitChanges(); } else { throw new Exception("Row not found. (Id : " + this.Id + ")"); } } catch (Exception ex) { CErrorLog err = new CErrorLog(); err.LogError(ex.Message); throw ex; } }
// Return book public ActionResult ReturnReceived(int?tranId) { /*try * {*/ if (tranId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblTransaction transaction = transDb.tblTransactions.FirstOrDefault(t => t.TranId == tranId); if (transaction == null) { return(HttpNotFound()); } transaction.TranDate = DateTime.Now.ToShortDateString(); transaction.TranStatus = "Returned"; transDb.SaveChanges(); return(RedirectToAction("Received", "UserTransaction", new { userId = userId })); /* } * catch (Exception) * { * return new HttpStatusCodeResult(HttpStatusCode.BadRequest); * }*/ }
/// <summary> /// Return Affected Row Or Error If Exist /// </summary> /// <param name="request">Transaction Information</param> /// <returns>Affected Row Or Error If Exist</returns> public static GetTransactionResponse Transaction(GetTransactionResponse request) { GetTransactionResponse response = new GetTransactionResponse(); try { tblTransaction bussines = new tblTransaction() { id = request.Transaction.id, amount = request.Transaction.amount, detail = request.Transaction.detail, idProvide = request.Transaction.idProvide, createDate = DateTime.Now, upDateDate = null, deleteDate = null, state = "Active" }; var result = TransactionData.Update.Transaction(bussines); if (result.Item1.Error) { response.Error.InfoError(result.Item1); } else { response.Message = result.Item2; } } catch (Exception ex) { response.Error.InfoError(ex); } return(response); }
// Cancel book request, redirected to requested public ActionResult DeleteRequest(int?tranId) { /*try * {*/ if (tranId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblTransaction transaction = transDb.tblTransactions.FirstOrDefault(t => t.TranId == tranId); if (transaction == null) { return(HttpNotFound()); } tblBook book = bookDb.tblBooks.FirstOrDefault(b => b.BookId == transaction.BookId); book.BookCopies = book.BookCopies + 1; bookDb.SaveChanges(); transDb.tblTransactions.Remove(transaction); transDb.SaveChanges(); return(RedirectToAction("Requested", "UserTransaction", new { userId = userId })); /* } * catch (Exception) * { * return new HttpStatusCodeResult(HttpStatusCode.BadRequest); * }*/ }
public async Task <IHttpActionResult> PuttblTransaction(int id, tblTransaction tblTransaction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblTransaction.TransationId) { return(BadRequest()); } db.Entry(tblTransaction).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!tblTransactionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Update Transaction Information /// </summary> /// <param name="data">Transaction Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> Transaction(tblTransaction data) { erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { var row = db.tblTransaction.Single(p => p.id == data.id); row.amount = data.amount; row.expeditionDate = data.expeditionDate; row.idConditionProduct = data.idConditionProduct; row.idProvide = data.idProvide; row.state = data.state; row.detail = data.detail; row.upDateDate = data.upDateDate; result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
internal void CloseTicket(int transId) { tblTransaction trans = db.tblTransactions.FirstOrDefault(x => x.TripId == transId); if (trans != null) { trans.TransactionStatus = 2; db.SubmitChanges(); } }
public bool checkTruckIsPendingOrNot(string TruckNo) { bool check = false; tblTransaction trans = db.tblTransactions.Where(x => x.TruckNo == TruckNo && x.TransactionStatus == 1).FirstOrDefault(); if (trans != null) { check = true; } return(check); }
internal bool checkTruckTripClosed(string truckNo) { bool check = false; tblTransaction trans = db.tblTransactions.Where(x => x.TruckNo == truckNo && x.TransactionStatus == 2).FirstOrDefault(); if (trans != null) { check = true; } return(check); }
public async Task <IHttpActionResult> GettblTransaction(int id) { tblTransaction tblTransaction = await db.tblTransactions.FindAsync(id); if (tblTransaction == null) { return(NotFound()); } return(Ok(tblTransaction)); }
// Borrow the book, redirect to index view. public ActionResult Borrow(int?bookId) { /*try * {*/ if (transDb.tblTransactions.Where(t => t.UserId == userId).Count() < 6) { if (bookId != null) { tblBook book = bookDb.tblBooks.FirstOrDefault(b => b.BookId == bookId); if (book == null) { return(HttpNotFound()); } if (book.BookCopies > 0) { book.BookCopies = book.BookCopies - 1; tblTransaction trans = new tblTransaction() { BookId = book.BookId, BookTitle = book.BookTitle, BookISBN = book.BookISBN, TranDate = DateTime.Now.ToShortDateString(), TranStatus = "Requested", UserId = userId, UserName = userName, }; bookDb.SaveChanges(); transDb.tblTransactions.Add(trans); transDb.SaveChanges(); Session["requestMsg"] = "Requested successfully"; } else { Session["requestMsg"] = "Sorry you cant take, Book copy is zero"; } } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } } else { Session["requestMsg"] = "Sorry you cant take more than six books"; } return(RedirectToAction("Index", "Borrow", new { userId = userId, userName = userName })); /*} * catch (Exception) * { * return new HttpStatusCodeResult(HttpStatusCode.BadRequest); * }*/ }
public async Task <IHttpActionResult> PosttblTransaction(tblTransaction tblTransaction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tblTransactions.Add(tblTransaction); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = tblTransaction.TransationId }, tblTransaction)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindPackingDropDown(); BindTransporterDropdown(); BindSupplierDropdown(); if (Request.QueryString["Id"] != null) { int RecordId = 0; try { RecordId = Convert.ToInt32(Request.QueryString["Id"].ToString()); } catch { } tblTransaction trans = _transRepo.getTransactionById(RecordId, 1); if (trans != null) { txtChallanDate.Text = trans.ChallanDate == null ? "" : trans.ChallanDate.Value.ToString(); txtChallanNo.Text = trans.ChallanNo; txtChallanWeight.Text = trans.ChallanWeight; txtCreateDate.Text = trans.CreateDate == null ? "" : trans.CreateDate.Value.ToString(); txtGateEntryNo.Text = trans.GateEntryNo; txtRemarks.Text = trans.Remarks; txtTripID.Text = trans.TripId.ToString(); txtTruckNo.Text = trans.TruckNo; txtWeighBridgeID.Text = trans.WeighbridgeId; ddlPacking.SelectedValue = trans.PackingCode == null ? "" : trans.PackingCode.Trim(); ddlSupplier.SelectedValue = trans.SupplierCode == null? "": trans.SupplierCode.Trim(); ddlTransport.SelectedValue = trans.TransporterCode == null ? "" : trans.TransporterCode.Trim(); ddlTripType.SelectedValue = trans.TripType == null ? "" : trans.TripType.ToString(); txtCreatedBy.Text = trans.CreatedBy; txtWeighBridgeID.Text = trans.WeighbridgeId; txtShift.Text = trans.Shift; //IList<tblTransactionWeight> weights = _transRepo.getWeighingByTransactionId(RecordId); //rptList.DataSource = weights; //rptList.DataBind(); lblFirstWt.Text = trans.FirstWeight.ToString(); lblFirstWtDateTime.Text = trans.FirstWtDateTime.ToString(); //lblSecondWeight.Text = trans.SecondWeight.ToString(); //lblSecondWeightDateTime.Text = trans.SecondWtDateTime.ToString(); //lblNetWeight.Text = trans.NetWeight.ToString(); IList <tblTransactionMaterial> materials = _transRepo.getmaterialsByTransactionId(RecordId); rptMaterials.DataSource = materials; rptMaterials.DataBind(); } } } }
public void DeleteTest() { WealthDataContext wdc = new WealthDataContext(); tblTransaction trans = (from u in wdc.tblTransactions where u.Quantity == 50 select u).FirstOrDefault(); wdc.tblTransactions.DeleteOnSubmit(trans); wdc.SubmitChanges(); tblTransaction transDelete = (from u in wdc.tblTransactions where u.Quantity == 50 select u).FirstOrDefault(); Assert.IsNull(transDelete); }
internal bool DeleteTransactionRecord(int id) { bool res = false; tblTransaction trans = db.tblTransactions.FirstOrDefault(x => x.Id == id); if (trans != null) { db.tblTransactions.DeleteOnSubmit(trans); db.SubmitChanges(); res = true; } return(res); }
internal Model_ManualWeight gettransactionDetail(string truckNo) { Model_ManualWeight model = new Model_ManualWeight(); tblTransaction trans = db.tblTransactions.Where(x => x.TruckNo == truckNo && x.TransactionStatus == 1).FirstOrDefault(); if (trans != null) { model.trans = trans; //IEnumerable<tblTransactionWeight> weightList = db.tblTransactionWeights.Where(x => x.TransactionId == trans.Id); //model.transWeight = weightList; } return(model); }
public async Task <IHttpActionResult> DeletetblTransaction(int id) { tblTransaction tblTransaction = await db.tblTransactions.FindAsync(id); if (tblTransaction == null) { return(NotFound()); } db.tblTransactions.Remove(tblTransaction); await db.SaveChangesAsync(); return(Ok(tblTransaction)); }
public void UpdateTest() { WealthDataContext wdc = new WealthDataContext(); tblTransaction trans = (from u in wdc.tblTransactions where u.PricePerSharePaid == 336 select u).FirstOrDefault(); trans.Quantity = 50; wdc.SubmitChanges(); tblTransaction transUpdate = (from u in wdc.tblTransactions where u.Quantity == 50 select u).FirstOrDefault(); Assert.IsNotNull(transUpdate); }
// GET: Transaction/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblTransaction tran = new tblTransaction(); if (tran == null) { return(HttpNotFound()); } return(View(tran)); }
public invoicePrintReport(tblInvoice myInvoice, tblClaimant myClaimant, tblTransaction myTransaction) { InitializeComponent(); Cursor.Current = Cursors.WaitCursor; invoiceDateLabel.Text = "Issued on: " + String.Format("{0:MM/dd/yyyy}", myTransaction.TranDate); InvoiceNoLabel.Text = "Invoice # : " + myInvoice.InvoiceNo.ToString(); claimantNameLabel.Text = myClaimant.FirstNames + " " + myClaimant.LastName; streetLabel.Text = myClaimant.Address1; suburbLabel.Text = myClaimant.Address2; stateLabel.Text = myClaimant.Address3; postCodeLabel.Text = myClaimant.Postcode; if (myClaimant.Terms.GetValueOrDefault() > 0) { claimantTermsLabel.Text = myClaimant.Terms.ToString() + " " + "days"; } else { claimantTermsLabel.Text = "ASAP"; } var Lines = new dbContextDataContext().getInvoiceLines(myInvoice.InvoiceNo).ToList(); tblPhysio myPhysio = new dbContextDataContext().tblPhysios.Where(p => p.PhysioID == myTransaction.PhysioID).SingleOrDefault(); physioProviderNoLabel.Text = myPhysio.ProviderNo; physioNameLabel.Text = myPhysio.PhysioName; var receipts = new dbContextDataContext().getReceiptsOfSingleInvoice(myInvoice.InvoiceNo).ToList(); this.DataSource = Lines; sessionDateTableCell.DataBindings.Add(new DevExpress.XtraReports.UI.XRBinding("Text", this.DataSource, "Date", "{0:MM/dd/yyyy}")); dobTableCell.DataBindings.Add(new DevExpress.XtraReports.UI.XRBinding("Text", this.DataSource, "DOB", "{0:MM/dd/yyyy}")); feeTableCell.DataBindings.Add("Text", this.DataSource, "Fee", "{0:c2}"); gstTableCell.DataBindings.Add("Text", this.DataSource, "GST", "{0:c2}"); totalTableCell.DataBindings.Add("Text", this.DataSource, "Total", "{0:c2}"); decimal invoiceTotal = decimal.Add( (decimal)Lines.Sum(od => od.Fee), (decimal)Lines.Sum(od => od.GST)); decimal alreadyPaid = (decimal)receipts.Sum(r => r.InvRecAmnt); decimal remaining = decimal.Subtract(invoiceTotal, alreadyPaid); invoiceTotalLabel.Text = string.Format("{0:c2}", invoiceTotal); paidTotalLabel.Text = string.Format("{0:c2}", alreadyPaid); amountToBePaidLabel.Text = string.Format("{0:c2}", remaining); decimal feeTotal = (decimal)Lines.Sum(od => od.Fee); decimal gstTotal = (decimal)Lines.Sum(od => od.GST); //feeTotalLabel.Text = feeTotalLabel.Text + feeTotal; //gstTotalLabel.Text = gstTotalLabel.Text + gstTotal; //totalLabel.Text = totalLabel.Text + decimal.Add(feeTotal, gstTotal); Cursor.Current = Cursors.Default; }
public HttpResponseMessage GetTransaction(int id) { var transaction_Id = entities.sp_SelectTransactionId(id).FirstOrDefault(); if (transaction_Id == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid ID")); } else { tblTransaction transaction = entities.tblTransactions.Where(t => t.transaction_id == transaction_Id).FirstOrDefault(); transaction.from_account = transaction.from_account % 1000; transaction.to_account = transaction.to_account % 1000; return(Request.CreateResponse <tblTransaction>(HttpStatusCode.OK, transaction)); } }
public HttpResponseMessage GetTransaction(int id) { tblTransaction transaction = entities.tblTransactions.Where(t => t.from_account == id).OrderByDescending(t => t.transaction_id).FirstOrDefault(); if (transaction == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid ID")); } else { //tblTransaction transactions = entities.tblTransactions.Where(t => t.transaction_id == transaction).FirstOrDefault(); transaction.from_account = transaction.from_account % 1000; transaction.to_account = transaction.to_account % 1000; return(Request.CreateResponse <tblTransaction>(HttpStatusCode.OK, transaction)); } }
public ActionResult AddTransaction(TranViewModel tvm) { using (RoadsEntities db = new RoadsEntities()) { tblTransaction tt = new tblTransaction(); tt.Trans_Date = tvm.Trans_Date; tt.Emp_No = tvm.Emp_no; tt.Mach_No = tvm.Mach_No; tt.BIA_No = tvm.BIA_No; tt.Activity_Code = tvm.Activity_Code; tt.Hours = tvm.Hours; tt.Lease_Chg = tvm.Lease_Chg; db.tblTransactions.Add(tt); db.SaveChanges(); ModelState.Clear(); } return(RedirectToAction("Index")); }
public async Task <string> AddUpdateTransaction(TransactionDomainModel transaction) { string status = ""; if (transaction.tra_id > 0) { tblTransaction transactionToUpdate = await transactionRepository.SingleOrDefault(t => t.tra_id == transaction.tra_id); if (transactionToUpdate != null) { transactionToUpdate.tra_type = transaction.tra_type; transactionToUpdate.voucherNo = transaction.voucherNo; transactionToUpdate.acc_id = transaction.acc_id; transactionToUpdate.description = transaction.description; transactionToUpdate.totalAmount = transaction.totalAmount; transactionToUpdate.user_id = transaction.user_id; transactionToUpdate.totalQty = transaction.totalQty; transactionToUpdate.barcode = transaction.barcode; await transactionRepository.Update(transactionToUpdate); status = "updated"; } } else { tblTransaction transactionToAdd = new tblTransaction(); transactionToAdd.tra_type = transaction.tra_type; transactionToAdd.voucherNo = transaction.voucherNo; transactionToAdd.acc_id = transaction.acc_id; transactionToAdd.description = transaction.description; transactionToAdd.totalAmount = transaction.totalAmount; transactionToAdd.user_id = transaction.user_id; transactionToAdd.totalQty = transaction.totalQty; transactionToAdd.barcode = transaction.barcode; await transactionRepository.Insert(transactionToAdd); status = "added"; } return(status); }
public void viewInvoice(tblInvoice thisInvoice) { myForm = new invoiceViewForm(); myInvoice = thisInvoice; var newConnection = new dbContextDataContext(); var Lines = newConnection.tblPatientStats.Where(lines => lines.InvoiceNo == thisInvoice.InvoiceNo); foreach (var line in Lines) { myInvoiceLines.Add(line); } myTransaction = newConnection.tblTransactions. Where(transaction => (transaction.InvoiceNo == thisInvoice.InvoiceNo) && (transaction.TranType == "I")).FirstOrDefault(); myClaimant = newConnection.tblClaimants.Where(claimant => claimant.ClaimantID == myTransaction.ClaimantID).FirstOrDefault(); if (myTransaction == null) { myTransaction = new tblTransaction(); } if (myInvoice == null) { myInvoice = new tblInvoice(); } if (myClaimant == null) { myClaimant = new tblClaimant(); } var receiptAmounts = newConnection.tblInvoiceReceipts.Where(rm => rm.InvoiceNo == myInvoice.InvoiceNo); var receipts = from rm in receiptAmounts from r in newConnection.tblReceipts.Where(r => r.ReceiptNo == rm.ReceiptNo) select r; // Second query to get receipts from another table. I might combine the two tables come deployment. var receiptAmounts2 = from rm in newConnection.tblReceiptInvoices where rm.InvoiceNo == myInvoice.InvoiceNo select new { InvoiceNo = rm.InvoiceNo, ReceiptNo = rm.ReceiptNo, InvRecAmnt = rm.Received }; foreach (var receipt in receiptAmounts2) { var receiptAmount = new tblInvoiceReceipt(); receiptAmount.InvoiceNo = receipt.InvoiceNo; receiptAmount.InvRecAmnt = receipt.InvRecAmnt; receiptAmount.ReceiptNo = receipt.ReceiptNo; myReceiptAmounts.Add(receiptAmount); } foreach (var receipt in receipts) { myReceipts.Add(receipt); } foreach (var receiptAmount in receiptAmounts) { myReceiptAmounts.Add(receiptAmount); } myForm.invoiceDateEdit.DateTime = myTransaction.TranDate.Value; registeFormEvents(); updateInvoiceForm(); makeInvoiceOfficial(); myForm.ShowDialog(); Cursor.Current = Cursors.Default; applyPaid(); }
void retrieveInvoiceDetails(tblInvoice MyInvoice) { Cursor.Current = Cursors.WaitCursor; try { myInvoice = MyInvoice; var Lines = myConnection.getInvoiceLines(myInvoice.InvoiceNo).ToList(); foreach (var line in Lines) { AnonInvoiceLines newLine = new AnonInvoiceLines(); newLine.Fee = line.Fee; newLine.GST = line.GST; newLine.RateID = line.RateID; newLine.PatientName = line.Patient; newLine.SessionDate = line.Date; newLine.ItemNo = line.ItemNo; newLine.PatientID = line.PatientID; myLines.Add(newLine); } myTransaction = myConnection.tblTransactions. Where(transaction => (transaction.InvoiceNo == MyInvoice.InvoiceNo) && (transaction.TranType == "I")).FirstOrDefault(); myClaimant = myConnection.tblClaimants.Where(claimant => claimant.ClaimantID == myTransaction.ClaimantID).FirstOrDefault(); myPhysio = myConnection.tblPhysios.Where(physio => physio.PhysioID == myTransaction.PhysioID).FirstOrDefault(); var myReceiptLines = myConnection.getReceiptsOfSingleInvoice(myInvoice.InvoiceNo).ToList(); var myReceiptDetails = myConnection.getReceiptDetailsOfSingleInvoice(myInvoice.InvoiceNo).ToList(); foreach (var line in myReceiptLines) { tblInvoiceReceipt myLine = new tblInvoiceReceipt(); myLine.InvoiceNo = line.InvoiceNo; myLine.InvoiceReceiptID = line.InvoiceNo; myLine.InvRecAmnt = line.InvRecAmnt; myLine.ReceiptNo = line.ReceiptNo; myReceiptAmounts.Add(myLine); } foreach (var line in myReceiptDetails) { tblReceipt myLine = new tblReceipt(); myLine.ReceiptNo = line.ReceiptNo; myLine.ReceiptDate = line.ReceiptDate; myLine.ReceiptComments = line.ReceiptComments; myLine.ReceiptAmnt = line.ReceiptAmnt; myLine.IsMulti = line.IsMulti; myLine.ReceiptCancelled = line.ReceiptCancelled; myReceipts.Add(myLine); } this.claimantBillingAddressMemoEdit.Text = myClaimant.FirstNames + Environment.NewLine + myClaimant.LastName + Environment.NewLine + myClaimant.Address1 + Environment.NewLine + myClaimant.Address2 + Environment.NewLine + myClaimant.Address3 + Environment.NewLine; this.invoiceDateEdit.DateTime = myTransaction.TranDate.Value; this.commentsMemoExEdit.Text = myInvoice.InvoiceComments; if (myInvoice.InvoiceCancelled.GetValueOrDefault(false) != true) { makeInvoiceOfficial(); } else { cancelInvoice(); } this.physioLookUp.EditValue = myPhysio.PhysioID; Cursor.Current = Cursors.Default; } catch (Exception) { MessageBox.Show("Can not display invoice. Data is corrupt."); this.DialogResult = DialogResult.Cancel; this.Close(); return; } }