public ActionResult Update([Bind(Include = "ID,Invoice_no,Added_service_id,Payment_status,Payment_type,Due,Date")] tblInvoice tblInvoice, int PaidAmount) { if (ModelState.IsValid) { int status = Convert.ToInt32(tblInvoice.Due - PaidAmount); if (status == 0) { tblInvoice.Payment_status = 1; tblInvoice.Due = 0; } else { tblInvoice.Payment_status = 0; tblInvoice.Due = status; } db.Entry(tblInvoice).State = EntityState.Modified; //db.SaveChanges(); var ClientId = db.tblAdded_service.Where(s => s.ID == tblInvoice.Added_service_id).FirstOrDefault(); tblClient_Transaction.Client_id = ClientId.Client_id; tblClient_Transaction.Invoice_id = tblInvoice.ID; tblClient_Transaction.Paid_amount = PaidAmount; tblClient_Transaction.Paid_date = DateTime.Now; tblClient_Transaction.Payment_type = tblInvoice.Payment_type; db.tblClient_transaction.Add(tblClient_Transaction); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Added_service_id = new SelectList(db.tblAdded_service, "ID", "ID", tblInvoice.Added_service_id); return(View(tblInvoice)); }
public void GetCustomerBalanceTest() { tblInvoice invoice = dc.tblInvoices.Where(i => i.Status == "Issued").FirstOrDefault(); tblCustomer customer = dc.tblCustomers.Where(c => c.Id == invoice.CustomerId).FirstOrDefault(); decimal expected = invoice.ServiceRate * customer.PropertySqFt; decimal actual = 0; var customerId = new SqlParameter { ParameterName = "customerId", SqlDbType = System.Data.SqlDbType.UniqueIdentifier, Value = customer.Id }; var results = dc.Set <spGetCustomerBalanceResult>().FromSqlRaw("exec spGetCustomerBalance @customerId", customerId).ToList(); foreach (var r in results) { actual = r.Balance; } Assert.AreEqual(expected, actual); }
public ActionResult Update(int?id) { tblInvoice tblInvoice = db.tblInvoices.Find(id); ViewBag.Added_service_id = new SelectList(db.tblAdded_service, "ID", "ID", tblInvoice.Added_service_id); return(View(tblInvoice)); }
public ActionResult DeleteConfirmed(int id) { tblInvoice tblInvoice = db.tblInvoices.Find(id); db.tblInvoices.Remove(tblInvoice); db.SaveChanges(); return RedirectToAction("Index"); }
public void InsertTest() { int expected = 1; int actual = 0; Guid customerId = dc.tblCustomers.First().Id; string serviceName = dc.tblServiceTypes.First().Description; decimal serviceRate = dc.tblServiceTypes.First().CostPerSqFt; string employeeName = dc.tblEmployees.First().FirstName + " " + dc.tblEmployees.First().LastName; tblInvoice newInvoice = new tblInvoice { Id = Guid.NewGuid(), CustomerId = customerId, EmployeeName = employeeName, ServiceName = serviceName, ServiceRate = serviceRate, ServiceDate = DateTime.Now, Status = "Completed" }; dc.tblInvoices.Add(newInvoice); actual = dc.SaveChanges(); invoiceId = newInvoice.Id; Assert.AreEqual(expected, actual); }
public newInvoiceForm(tblInvoice MyInvoice) { InitializeComponent(); this.myLines.ListChanged += new ListChangedEventHandler(updateSummaries); this.myReceipts.ListChanged += new ListChangedEventHandler(updateSummaries); this.myReceiptAmounts.ListChanged += new ListChangedEventHandler(updateSummaries); retrieveInvoiceDetails(MyInvoice); }
public ActionResult Edit([Bind(Include = "Bill_Id,Bill_Date,Appointment_Code,Bill_Code,Patient_Code")] tblInvoice tblInvoice) { if (ModelState.IsValid) { db.Entry(tblInvoice).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Appointment_Code = new SelectList(db.tblAppointments, "Appointment_Code", "Appointment_Type", tblInvoice.Appointment_Code); ViewBag.Patient_Code = new SelectList(db.tblPatients, "Patient_Code", "Patient_Name", tblInvoice.Patient_Code); return(View(tblInvoice)); }
public ActionResult Create([Bind(Include = "ID,Invoice_no,Added_service_id,Payment_status,Payment_type,Due,Date")] tblInvoice tblInvoice) { if (ModelState.IsValid) { db.tblInvoices.Add(tblInvoice); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Added_service_id = new SelectList(db.tblAdded_service, "ID", "ID", tblInvoice.Added_service_id); return View(tblInvoice); }
// GET: tblInvoices/Details/5 public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } tblInvoice tblInvoice = db.tblInvoices.Find(id); if (tblInvoice == null) { return HttpNotFound(); } return View(tblInvoice); }
public ActionResult Edit([Bind(Include = "InvoiceID,InvoiceNo,BillingAddress,ShippingAddress,InvoiceType,GSTIN,CustomerName,ContactNumber,Email,Website,PaymentModeID,IsPaid,IsOnCredit,InvoiceDate,PaymentExpectedBy,Remarks,IsActive,CreatedOn,UpdatedOn,CreatedBy,UpdatedBy")] tblInvoice tblInvoice) { if (ModelState.IsValid) { db.Entry(tblInvoice).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PaymentModeID = new SelectList(db.tblPaymentModes, "PaymentModeID", "PaymentMode", tblInvoice.PaymentModeID); ViewBag.CreatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblInvoice.CreatedBy); ViewBag.UpdatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblInvoice.UpdatedBy); return(View(tblInvoice)); }
// GET: Invoices/Create public ActionResult Create() { Guid hg = Guid.NewGuid(); string uni = hg.ToString().Substring(0, 8); ViewBag.PaymentModeID = new SelectList(db.tblPaymentModes, "PaymentModeID", "PaymentMode"); tblInvoice tblInvoice = new tblInvoice(); tblInvoice.InvoiceNo = ConfigurationManager.AppSettings["InvoicePrefix"] + "00" + uni.ToUpper(); ViewBag.ProductID = new SelectList(db.tblProducts, "ProductID", "ProductName"); ViewBag.SizeID = new SelectList(db.tblSizes.Where(a => a.UnitID == null), "SizeID", "SizeName"); ViewBag.UnitID = new SelectList(db.tblUnits, "UnitID", "Name", tblInvoice.UnitID); return(View(tblInvoice)); }
// GET: Invoices/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblInvoice tblInvoice = db.tblInvoices.Find(id); if (tblInvoice == null) { return(HttpNotFound()); } return(View(tblInvoice)); }
// GET: tblInvoices/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } tblInvoice tblInvoice = db.tblInvoices.Find(id); if (tblInvoice == null) { return HttpNotFound(); } ViewBag.Added_service_id = new SelectList(db.tblAdded_service, "ID", "ID", tblInvoice.Added_service_id); return View(tblInvoice); }
public async static Task <int> Update(Invoice invoice, bool rollback = false) { try { int results = 0; await Task.Run(() => { using (LawnProEntities dc = new LawnProEntities()) { IDbContextTransaction transaction = null; if (rollback) { transaction = dc.Database.BeginTransaction(); } tblInvoice updateRow = dc.tblInvoices.FirstOrDefault(s => s.Id == invoice.Id); if (updateRow != null) { updateRow.EmployeeName = invoice.EmployeeFullName; updateRow.ServiceDate = invoice.ServiceDate; updateRow.ServiceName = invoice.ServiceType; updateRow.ServiceRate = invoice.ServiceRate; updateRow.Status = invoice.Status; dc.tblInvoices.Update(updateRow); results = dc.SaveChanges(); if (rollback) { transaction.Rollback(); } } else { throw new Exception("Invoice not found"); } } }); return(results); } catch (Exception) { throw; } }
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 static void WritePaymentLog(string title, tblInvoice invoice, tblInvoice savedOne = null, LogCategory cat = LogCategory.General, int logPriority = 3) { string message = getInvoiceMessageTemplate(invoice, savedOne); LogWriter writer = EnterpriseLibraryContainer.Current.GetInstance <LogWriter>(); LogEntry log = new LogEntry(); log.Title = title; log.Message = message; log.Categories.Add(cat.ToString()); log.Priority = logPriority; log.Severity = System.Diagnostics.TraceEventType.Information; writer.Write(log); }
// GET: Invoices/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblInvoice tblInvoice = db.tblInvoices.Find(id); if (tblInvoice == null) { return(HttpNotFound()); } ViewBag.Appointment_Code = new SelectList(db.tblAppointments, "Appointment_Code", "Appointment_Type", tblInvoice.Appointment_Code); ViewBag.Patient_Code = new SelectList(db.tblPatients, "Patient_Code", "Patient_Name", tblInvoice.Patient_Code); return(View(tblInvoice)); }
public void DeleteTest() { InsertTest(); int expected = 1; int actual = 0; tblInvoice deleteRow = dc.tblInvoices.Where(a => a.Id == invoiceId).FirstOrDefault(); if (deleteRow != null) { dc.tblInvoices.Remove(deleteRow); actual = dc.SaveChanges(); } Assert.AreEqual(expected, actual); }
public void UpdateTest() { InsertTest(); int expected = 1; int actual = 0; tblInvoice updateRow = dc.tblInvoices.Where(a => a.Id == invoiceId).FirstOrDefault(); if (updateRow != null) { updateRow.Status = "Paid"; actual = dc.SaveChanges(); } Assert.AreEqual(expected, actual); }
public async static Task <int> Delete(Guid id, bool rollback = false) { try { int results = 0; await Task.Run(() => { using (LawnProEntities dc = new LawnProEntities()) { bool inuse = dc.tblInvoices.Any(e => e.Id == id && e.Status != "Paid"); if (inuse && rollback == false) { throw new Exception("This Invoice has not been paid and cannot be deleted"); } else { IDbContextTransaction transaction = null; if (rollback) { transaction = dc.Database.BeginTransaction(); } tblInvoice deleteRow = dc.tblInvoices.FirstOrDefault(s => s.Id == id); if (deleteRow != null) { dc.tblInvoices.Remove(deleteRow); results = dc.SaveChanges(); } else { throw new Exception("Invoice not found"); } } } }); return(results); } catch (Exception) { throw; } }
private void FillAlertMessage(tblInvoice invoice = null) { if (invoice != null) { lblTransaction.Text = invoice.Invoice.ToString(); lblPaymentDate.Text = invoice.FormattedCreatedDate; lblFormattedAmountPaid.Text = invoice.FormattedMCGross; lblStatus.Text = invoice.PaymentStatus; } else { lblTransaction.Text = string.Empty; lblPaymentDate.Text = string.Empty; lblFormattedAmountPaid.Text = string.Empty; lblStatus.Text = string.Empty; } }
public async static Task <bool> Insert(Invoice invoice, bool rollback = false) { try { int result = 0; await Task.Run(() => { using (LawnProEntities dc = new LawnProEntities()) { IDbContextTransaction transaction = null; if (rollback) { transaction = dc.Database.BeginTransaction(); } tblInvoice newrow = new tblInvoice(); newrow.Id = Guid.NewGuid(); newrow.CustomerId = invoice.CustomerId; newrow.EmployeeName = invoice.EmployeeFullName; newrow.ServiceDate = invoice.ServiceDate; newrow.ServiceName = invoice.ServiceType; newrow.ServiceRate = invoice.ServiceRate; newrow.Status = invoice.Status; invoice.Id = newrow.Id; dc.tblInvoices.Add(newrow); result = dc.SaveChanges(); if (rollback) { transaction.Rollback(); } } }); return(result == 1); } catch (Exception) { throw; } }
// GET: Invoices/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblInvoice tblInvoice = db.tblInvoices.Find(id); if (tblInvoice == null) { return(HttpNotFound()); } ViewBag.PaymentModeID = new SelectList(db.tblPaymentModes, "PaymentModeID", "PaymentMode", tblInvoice.PaymentModeID); ViewBag.CreatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblInvoice.CreatedBy); ViewBag.UpdatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblInvoice.UpdatedBy); return(View(tblInvoice)); }
public JsonResult InsertInvoice(tblInvoice tb) { tblInvoice tbl = _db.tblInvoices.OrderByDescending(ti => ti.InvoiceId).Take(1).FirstOrDefault(); tblSetting tbs = _db.tblSettings.OrderByDescending(s => s.SettingId).Take(1).FirstOrDefault(); tblInvoice t = new tblInvoice(); if (tbl != null) { t.InvoiceId = tbl.InvoiceId; } else { t.InvoiceId = 1; } t.OrderId = tb.OrderId; decimal taxamount = Convert.ToDecimal(tb.GrossAmount * 15 / 100); decimal grossamount = Convert.ToDecimal(tb.GrossAmount + taxamount); decimal discountamount = Convert.ToDecimal(tbs.DiscountRate / 100 * grossamount); t.DiscountAmount = discountamount; t.TaxAmount = taxamount; t.GrossAmount = tb.GrossAmount; t.NetAmount = tb.GrossAmount + taxamount - discountamount; t.InvoiceDate = DateTime.Today; t.UserId = Convert.ToInt32(Session["userid"]); t.BranchId = Convert.ToInt32(Session["branchid"]); _db.tblInvoices.Add(t); _db.SaveChanges(); return(Json(1, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "ID,Invoice_no,Added_service_id,Payment_status,Payment_type,Due,Date")] tblInvoice tblInvoice, int PaidAmount) { if (ModelState.IsValid) { int status = Convert.ToInt32(tblInvoice.Due - PaidAmount); if (status == 0) { tblInvoice.Payment_status = 1; tblInvoice.Due = 0; } else { tblInvoice.Payment_status = 0; tblInvoice.Due = status; } db.Entry(tblInvoice).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Added_service_id = new SelectList(db.tblAdded_service, "ID", "ID", tblInvoice.Added_service_id); return View(tblInvoice); }
private void CreateInvoice() { if (!IsPostBack) { _Invoice = new tblInvoice(); UpdateInvoiceData(); _Data.NWODC.tblInvoices.InsertOnSubmit(_Invoice); } else { _Invoice = _Data.NWODC.tblInvoices.SingleOrDefault <tblInvoice>(a => a.ID == InvoiceID); if (_Invoice == null) { ThrowError(this, new ControlErrorArgs() { Message = "Invoice is not found. Please contact webmaster.", Severity = 1 }); } UpdateInvoiceData(); } _Data.NWODC.SubmitChanges(); }
public ActionResult Create(tblInvoice tblInvoice, List <tblInvoiceItem> invItem, string submit) { List <tblInvoiceItem> tblItem = new List <tblInvoiceItem>(); tblInvoiceItem objtblInvoiceItem = new tblInvoiceItem(); tblUser objSource = (tblUser)Session["UserDetails"]; if (submit == "Add Row") { tblProduct objpro = db.tblProducts.Where(p => p.ProductID == tblInvoice.ProductID).FirstOrDefault(); tblUnit objUnit = db.tblUnits.Where(t => t.UnitID == tblInvoice.UnitID).FirstOrDefault(); tblSize objSize = db.tblSizes.Where(t => t.SizeID == tblInvoice.SizeID).FirstOrDefault(); objtblInvoiceItem.ProductID = tblInvoice.ProductID; objtblInvoiceItem.ProductName = objpro.ProductName; objtblInvoiceItem.SizeID = tblInvoice.SizeID; objtblInvoiceItem.UnitID = tblInvoice.UnitID; objtblInvoiceItem.TaxID = tblInvoice.TaxID; objtblInvoiceItem.Tax = tblInvoice.Tax; objtblInvoiceItem.TaxAmount = tblInvoice.TaxAmount; objtblInvoiceItem.Quantity = tblInvoice.Quantity; objtblInvoiceItem.RatePerUnit = tblInvoice.RatePerUnit; objtblInvoiceItem.IsDeleted = false; objtblInvoiceItem.UnitName = objUnit.Name; objtblInvoiceItem.SizeName = objSize.SizeName; objtblInvoiceItem.HSN_SAC = tblInvoice.HSN_SAC; objtblInvoiceItem.Discount = tblInvoice.Discount; objtblInvoiceItem.DiscountAmount = tblInvoice.DiscountAmount; objtblInvoiceItem.SGST = tblInvoice.SGST; objtblInvoiceItem.Make = tblInvoice.Make; if (invItem == null) { tblItem.Add(objtblInvoiceItem); tblInvoice.tblInvoiceItems = tblItem; } else { invItem.Add(objtblInvoiceItem); tblInvoice.tblInvoiceItems = invItem; } } if (submit == "Delete Row") { ModelState.Clear(); invItem.RemoveAll(a => a.IsDeleted == true); tblInvoice.tblInvoiceItems = invItem; } if (submit == "Save Invoice") { GetInvoiceDetails(tblInvoice, invItem, objSource.Id); } if (submit == "Print Preview") { } if (submit == "Print") { } //if (ModelState.IsValid) //{ // db.tblInvoices.Add(tblInvoice); // db.SaveChanges(); // return RedirectToAction("Index"); //} ViewBag.PaymentModeID = new SelectList(db.tblPaymentModes, "PaymentModeID", "PaymentMode", tblInvoice.PaymentModeID); ViewBag.ProductID = new SelectList(db.tblProducts, "ProductID", "ProductName"); ViewBag.SizeID = new SelectList(db.tblSizes.Where(a => a.UnitID == tblInvoice.UnitID), "SizeID", "SizeName", tblInvoice.SizeID); ViewBag.UnitID = new SelectList(db.tblUnits, "UnitID", "Name", tblInvoice.UnitID); // ViewBag.CreatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblInvoice.CreatedBy); // ViewBag.UpdatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblInvoice.UpdatedBy); return(View(tblInvoice)); }
//Invoice public static InvoiceModel ToModel(this tblInvoice entity) { return(Mapper.Map <tblInvoice, InvoiceModel>(entity)); }
public bool GetInvoiceDetails(tblInvoice objtblInvoice, IList <tblInvoiceItem> tblInvoiceItemList, int userID) { bool isValid = false; try { DataTable dtInvoice = new DataTable(); dtInvoice.TableName = "Invoice"; dtInvoice.Columns.Add("CustomerName", typeof(String)); dtInvoice.Columns.Add("ContactNumber", typeof(String)); dtInvoice.Columns.Add("Email", typeof(String)); dtInvoice.Columns.Add("Website", typeof(String)); dtInvoice.Columns.Add("PaymentModeID", typeof(Int32)); dtInvoice.Columns.Add("IsPaid", typeof(Int32)); dtInvoice.Columns.Add("IsOnCredit", typeof(Int32)); dtInvoice.Columns.Add("InvoiceDate", typeof(String)); dtInvoice.Columns.Add("PaymentExpectedBy", typeof(String)); dtInvoice.Columns.Add("Remarks", typeof(String)); dtInvoice.Columns.Add("InvoiceNo", typeof(String)); dtInvoice.Columns.Add("BillingAddress", typeof(String)); dtInvoice.Columns.Add("ShippingAddress", typeof(String)); dtInvoice.Columns.Add("InvoiceType", typeof(Int32)); dtInvoice.Columns.Add("GSTIN", typeof(String)); DataRow rowInvoice = dtInvoice.NewRow(); rowInvoice["CustomerName"] = objtblInvoice.CustomerName.Trim(); rowInvoice["ContactNumber"] = objtblInvoice.ContactNumber.Trim(); rowInvoice["Email"] = objtblInvoice.Email.Trim(); rowInvoice["Website"] = objtblInvoice.Website.Trim(); rowInvoice["PaymentModeID"] = Convert.ToInt32(objtblInvoice.PaymentModeID); rowInvoice["IsPaid"] = objtblInvoice.IsPaid; rowInvoice["IsOnCredit"] = objtblInvoice.IsOnCredit; rowInvoice["InvoiceDate"] = objtblInvoice.InvoiceDate; rowInvoice["PaymentExpectedBy"] = objtblInvoice.PaymentExpectedBy; rowInvoice["Remarks"] = objtblInvoice.Remarks; rowInvoice["InvoiceNo"] = objtblInvoice.InvoiceNo; rowInvoice["BillingAddress"] = objtblInvoice.BillingAddress.Trim(); rowInvoice["ShippingAddress"] = objtblInvoice.ShippingAddress.Trim(); rowInvoice["InvoiceType"] = objtblInvoice.InvoiceType; rowInvoice["GSTIN"] = objtblInvoice.GSTIN.Trim(); dtInvoice.Rows.Add(rowInvoice); DataTable dt1 = new DataTable(); dt1.TableName = "InvoiceDetails"; dt1.Columns.Add("InvoiceItemID", typeof(Int32)); dt1.Columns.Add("InvoiceID", typeof(Int32)); dt1.Columns.Add("ProductID", typeof(Int32)); dt1.Columns.Add("Product", typeof(String)); dt1.Columns.Add("Make", typeof(String)); dt1.Columns.Add("Quantity", typeof(Decimal)); dt1.Columns.Add("UnitID", typeof(String)); dt1.Columns.Add("SizeId", typeof(Int32)); dt1.Columns.Add("Size", typeof(String)); dt1.Columns.Add("RatePerUnit", typeof(Decimal)); dt1.Columns.Add("TaxID", typeof(Int32)); dt1.Columns.Add("HSN_SAC", typeof(Int32)); dt1.Columns.Add("TaxPercentage", typeof(Int32)); dt1.Columns.Add("TaxAmount", typeof(Decimal)); dt1.Columns.Add("Discount", typeof(Decimal)); dt1.Columns.Add("DiscountAmount", typeof(Decimal)); dt1.Columns.Add("TotalAmount", typeof(Decimal)); dt1.Columns.Add("Remark", typeof(String)); dt1.Columns.Add("Delete", typeof(Boolean)); DataRow row; foreach (var item in tblInvoiceItemList) { row = dt1.NewRow(); row["InvoiceItemID"] = item.InvoiceItemID; row["InvoiceID"] = objtblInvoice.InvoiceID; row["ProductID"] = item.ProductID; row["Product"] = item.ProductName; row["Make"] = item.Make; row["Quantity"] = item.Quantity; row["UnitID"] = item.UnitID; row["TaxID"] = item.TaxID; row["SizeId"] = item.SizeID; row["RatePerUnit"] = item.RatePerUnit; row["HSN_SAC"] = item.HSN_SAC; row["TaxPercentage"] = item.Tax; row["Discount"] = item.Discount; row["TaxAmount"] = item.TaxAmount; row["DiscountAmount"] = item.DiscountAmount; row["TotalAmount"] = item.TotalAmount; row["Remark"] = item.Remark; row["Delete"] = item.IsDeleted; dt1.Rows.Add(row); } System.IO.StringWriter swSQL; DataTable dtInvoiceItems = dt1; StringBuilder sbSQL1 = new StringBuilder(); swSQL = new System.IO.StringWriter(sbSQL1); dtInvoiceItems.WriteXml(swSQL); swSQL.Dispose(); System.IO.StringWriter swSQL2; StringBuilder sbSQL2 = new StringBuilder(); swSQL2 = new System.IO.StringWriter(sbSQL2); dtInvoice.WriteXml(swSQL2); swSQL2.Dispose(); db.spInvoice_InvoiceEntrySave(sbSQL2.ToString(), sbSQL1.ToString(), userID, objtblInvoice.InvoiceID); isValid = true; } catch (Exception) { isValid = false; } return(isValid); }
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; } }
public void AddRecord(tblInvoice entity) { _context.Invoices.Add(entity); }
private static string getInvoiceMessageTemplate(tblInvoice tempInvoice, tblInvoice savedOne = null) { if (savedOne != null) { tempInvoice.ID = savedOne.ID; tempInvoice.ProfileID = savedOne.ProfileID; tempInvoice.PlanID = savedOne.PlanID; tempInvoice.ProfileID = savedOne.ProfileID; tempInvoice.CampaignID = savedOne.CampaignID; tempInvoice.CreatedDate = savedOne.CreatedDate; tempInvoice.CustomerIP = savedOne.CustomerIP; } string messageTemp = @" ID: #ID#; Campaign: #CampaignID#; PlanID: #PlanID#; ProfileID: #ProfileID#; PaymentStatus: #PaymentStatus#; PaymentType: #PaymentType#; AddressStatus: #AddressStatus#; PayerStatus: #PayerStatus#; FirstName: #FirstName#; LastName: #LastName#; PayerEmail: #PayerEmail#; PayerID: #PayerID#; AddressName: #AddressName#; AddressCountry: #AddressCountry#; AddressCountryCode: #AddressCountryCode#; AddressZip: #AddressZip#; AddressState: #AddressState#; AddressCity: #AddressCity#; AddressStreet: #AddressStreet#; Business: #Business#; ReceiverEmail: #ReceiverEmail#; ResidenceCountry: #ResidenceCountry#; ItemName: #ItemName#; ItemNumber: #ItemNumber#; Quantity: #Quantity#; Shipping: #Shipping#; Tax: #Tax#; MCCurrency: #MCCurrency#; MCFee: #MCFee#; MCGross: #MCGross#; MCGross1: #MCGross1#; TxnType: #TxnType#; TxnID: #TxnID#; NotifyVersion: #NotifyVersion#; FraudManagementPendingFilter: #FraudManagementPendingFilter#; PendingReason: #PendingReason#; ProtectionEligibility: #ProtectionEligibility#; ReasonCode: #ReasonCode#; CreatedDate: #CreatedDate#; ParentTxnId: #ParentTxnId#; PaymentDate: #PaymentDate#; Invoice: #Invoice#; PaypalIP: #PaypalIP#; CustomerIP: #CustomerIP#; PromotionCode: #PromotionCode#; ReceiverID: #ReceiverID#;"; messageTemp = messageTemp.Replace("#ID#", tempInvoice.ID.ToString()); messageTemp = messageTemp.Replace("#CampaignID#", tempInvoice.CampaignID.ToString()); messageTemp = messageTemp.Replace("#PlanID#", tempInvoice.PlanID.ToString()); messageTemp = messageTemp.Replace("#ProfileID#", tempInvoice.ProfileID.ToString()); messageTemp = messageTemp.Replace("#PaymentStatus#", tempInvoice.PaymentStatus); messageTemp = messageTemp.Replace("#PaymentType#", tempInvoice.PaymentType); messageTemp = messageTemp.Replace("#AddressStatus#", tempInvoice.AddressStatus); messageTemp = messageTemp.Replace("#PayerStatus#", tempInvoice.PayerStatus); messageTemp = messageTemp.Replace("#FirstName#", tempInvoice.FirstName); messageTemp = messageTemp.Replace("#LastName#", tempInvoice.LastName); messageTemp = messageTemp.Replace("#PayerEmail#", tempInvoice.PayerEmail); messageTemp = messageTemp.Replace("#PayerID#", tempInvoice.PayerID); messageTemp = messageTemp.Replace("#AddressName#", tempInvoice.AddressName); messageTemp = messageTemp.Replace("#AddressCountry#", tempInvoice.AddressCountry); messageTemp = messageTemp.Replace("#AddressCountryCode#", tempInvoice.AddressCountryCode); messageTemp = messageTemp.Replace("#AddressZip#", tempInvoice.AddressZip); messageTemp = messageTemp.Replace("#AddressState#", tempInvoice.AddressState); messageTemp = messageTemp.Replace("#AddressCity#", tempInvoice.AddressCity); messageTemp = messageTemp.Replace("#AddressStreet#", tempInvoice.AddressStreet); messageTemp = messageTemp.Replace("#Business#", tempInvoice.Business); messageTemp = messageTemp.Replace("#ReceiverEmail#", tempInvoice.ReceiverEmail); messageTemp = messageTemp.Replace("#ResidenceCountry#", tempInvoice.ResidenceCountry); messageTemp = messageTemp.Replace("#ItemName#", tempInvoice.ItemName); messageTemp = messageTemp.Replace("#Quantity#", tempInvoice.Quantity); messageTemp = messageTemp.Replace("#Shipping#", tempInvoice.Shipping); messageTemp = messageTemp.Replace("#Tax#", tempInvoice.Tax); messageTemp = messageTemp.Replace("#MCCurrency#", tempInvoice.MCCurrency); messageTemp = messageTemp.Replace("#MCFee#", tempInvoice.MCFee); messageTemp = messageTemp.Replace("#MCGross#", tempInvoice.MCGross); messageTemp = messageTemp.Replace("#TxnType#", tempInvoice.TxnType); messageTemp = messageTemp.Replace("#TxnID#", tempInvoice.TxnID); messageTemp = messageTemp.Replace("#NotifyVersion#", tempInvoice.NotifyVersion); messageTemp = messageTemp.Replace("#FraudManagementPendingFilter#", tempInvoice.FraudManagementPendingFilter); messageTemp = messageTemp.Replace("#PendingReason#", tempInvoice.PendingReason); messageTemp = messageTemp.Replace("#ProtectionEligibility#", tempInvoice.ProtectionEligibility); messageTemp = messageTemp.Replace("#ReasonCode#", tempInvoice.ReasonCode); messageTemp = messageTemp.Replace("#ParentTxnId#", tempInvoice.ParentTxnId); messageTemp = messageTemp.Replace("#PaypalIP#", tempInvoice.PaypalIP); if (tempInvoice.PaymentDate != null) { messageTemp = messageTemp.Replace("#PaymentDate#", tempInvoice.PaymentDate.ToString()); } messageTemp = messageTemp.Replace("#CreatedDate#", tempInvoice.CreatedDate.ToString()); if (tempInvoice.Invoice != null) { messageTemp = messageTemp.Replace("#Invoice#", tempInvoice.Invoice.ToString()); } messageTemp = messageTemp.Replace("#CustomerIP#", tempInvoice.CustomerIP); messageTemp = messageTemp.Replace("#PromotionCode#", tempInvoice.PromotionCode); messageTemp = messageTemp.Replace("#ReceiverID#", tempInvoice.ReceiverID); return(messageTemp); }
public void RemoveRecord(tblInvoice entity) { _context.Invoices.Remove(entity); }
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(); }