protected void UnloadData(AmendmentInvoiceLine aInvl) { aInvl.AmendmentInvoice = aInv; taxTypeId = Int32.Parse(rdcbTaxType.SelectedValue); aInvl.TaxType = CntAriCli.GetTaxType(taxTypeId, ctx); aInvl.User = CntAriCli.GetUser(user.UserId, ctx); aInvl.Description = txtDescription.Text; aInvl.TaxPercentage = Decimal.Parse(txtTaxPercentage.Text); aInvl.Amount = Decimal.Parse(txtAmount.Text); }
protected void LoadData(AmendmentInvoiceLine aInvl) { txtInvoiceLineId.Text = aInvl.AmendmentInvoiceLineId.ToString(); aInv = aInvl.AmendmentInvoice; LoadInvoiceData(); LoadTaxTypeCombo(aInvl.TaxType); txtDescription.Text = aInvl.Description; txtTaxPercentage.Text = String.Format("{0:##0.00}", aInvl.TaxPercentage); txtAmount.Text = String.Format("{0:###,##0.00}", aInvl.Amount); }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) { Response.Redirect("Default.aspx"); } else { user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "invoice" select p).FirstOrDefault <Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } // if (Request.QueryString["AmendmentInvoiceId"] != null) { aInvoiceId = Int32.Parse(Request.QueryString["AmendmentInvoiceId"]); aInv = CntAriCli.GetAmendementInvoice(aInvoiceId, ctx); LoadInvoiceData(); } else { //TODO: What to do if there is not an invoice } if (Session["Clinic"] != null) { cl = (Clinic)Session["Clinic"]; } // if (Request.QueryString["AmendmentInvoiceLineId"] != null) { aInvoiceLineId = Int32.Parse(Request.QueryString["AmendmentInvoiceLineId"]); aInvl = CntAriCli.GetAmendementInvoiceLine(aInvoiceLineId, ctx); LoadData(aInvl); } else { LoadTaxTypeCombo(null); } }
protected bool CreateChange() { if (!DataOk()) { return(false); } if (aInvl == null) { aInvl = new AmendmentInvoiceLine(); UnloadData(aInvl); ctx.Add(aInvl); } else { aInvl = CntAriCli.GetAmendementInvoiceLine(aInvoiceLineId, ctx); UnloadData(aInvl); } ctx.SaveChanges(); return(true); }
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { try { // we only process commands with a datasource (our image buttons) if (e.CommandSource == null) { return; } string typeOfControl = e.CommandSource.GetType().ToString(); if (typeOfControl.Equals("System.Web.UI.WebControls.ImageButton")) { int id = 0; ImageButton imgb = (ImageButton)e.CommandSource; if (imgb.ID != "New" && imgb.ID != "Exit") { id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]]; } switch (imgb.ID) { case "Select": break; case "Edit": break; case "Delete": aInvl = CntAriCli.GetAmendementInvoiceLine(id, ctx); ctx.Delete(aInvl); ctx.SaveChanges(); RefreshGrid(true); break; } } } catch (Exception ex) { Label lbl = (Label)this.Parent.FindControl("lblMessage"); lbl.Text = ex.Message; } }
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { try { // we only process commands with a datasource (our image buttons) if (e.CommandSource == null) return; string typeOfControl = e.CommandSource.GetType().ToString(); if (typeOfControl.Equals("System.Web.UI.WebControls.ImageButton")) { int id = 0; ImageButton imgb = (ImageButton)e.CommandSource; if (imgb.ID != "New" && imgb.ID != "Exit") id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]]; switch (imgb.ID) { case "Select": break; case "Edit": break; case "Delete": aInvl = CntAriCli.GetAmendementInvoiceLine(id, ctx); ctx.Delete(aInvl); ctx.SaveChanges(); RefreshGrid(true); break; } } } catch (Exception ex) { Label lbl = (Label)this.Parent.FindControl("lblMessage"); lbl.Text = ex.Message; } }
public static AmendmentInvoice CreateAmendmentInvoice(Invoice invoice, DateTime vdate, string reason, AriClinicContext ctx) { // first of all check if there's another amendment invoice // linked to this invoice. AmendmentInvoice aInv = (from a in ctx.AmendmentInvoices where a.OriginalInvoice.InvoiceId == invoice.InvoiceId select a).FirstOrDefault<AmendmentInvoice>(); if (aInv != null) { return null; } // collecting some stuff we'll need. HealthcareCompany hc = CntAriCli.GetHealthCompany(ctx); // now let's go to create it aInv = new AmendmentInvoice(); aInv.Customer = invoice.Customer; aInv.InvoiceDate = vdate; aInv.Serial = hc.AmendmentInvoiceSerial; aInv.Year = aInv.InvoiceDate.Year; aInv.InvoiceNumber = CntAriCli.GetNextAmendmentInvoiceNumber(aInv.Serial, aInv.Year, ctx); aInv.OriginalInvoice = invoice; aInv.Reason = reason; ctx.Add(aInv); ctx.SaveChanges(); // related lines decimal total = 0; foreach (InvoiceLine il in invoice.InvoiceLines) { AmendmentInvoiceLine ail = new AmendmentInvoiceLine(); ail.AmendmentInvoice = aInv; ail.TaxType = il.TaxType; ail.TaxPercentage = il.TaxPercentage; ail.Description = il.Description; ail.Amount = -il.Amount; total += ail.Amount; ctx.Add(ail); ctx.SaveChanges(); } aInv.Total = total; ctx.SaveChanges(); return aInv; }