protected void Page_Load(object sender, EventArgs e) { // First control the type of parent page if (Request.QueryString["InvoiceId"] != null) { invoiceId = Int32.Parse(Request.QueryString["InvoiceId"]); inv = CntAriCli.GetProfessionalInvoice(invoiceId, ctx); caller = "invoice"; // Called by Insurance } }
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 == "profInvoice" select p).FirstOrDefault<Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } // if (Request.QueryString["InvoiceId"] != null) { invoiceId = Int32.Parse(Request.QueryString["InvoiceId"]); inv = CntAriCli.GetProfessionalInvoice(invoiceId, ctx); LoadInvoiceData(); } else { //TODO: What to do if there is not an invoice } if (Session["Clinic"] != null) cl = (Clinic)Session["Clinic"]; // if (Request.QueryString["InvoiceLineId"] != null) { invoiceLineId = Int32.Parse(Request.QueryString["InvoiceLineId"]); invl = CntAriCli.GetProfessionalInvoiceLine(invoiceLineId, ctx); LoadData(invl); } else { LoadTaxTypeCombo(null); } }
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 == "profInvoice" select p).FirstOrDefault<Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } hc = CntAriCli.GetHealthCompany(ctx); // if (Request.QueryString["InvoiceId"] != null) { invoiceId = Int32.Parse(Request.QueryString["InvoiceId"]); inv = CntAriCli.GetProfessionalInvoice(invoiceId, ctx); LoadData(inv); } else { // deafault values rddpInvoiceDate.SelectedDate = DateTime.Now; txtYear.Text = DateTime.Now.Year.ToString(); } // if (Request.QueryString["Caller"] != null) caller = Request.QueryString["Caller"]; if (Session["Clinic"] != null) cl = (Clinic)Session["Clinic"]; // always read Healt care company }
protected void LoadData(ProfessionalInvoiceLine invl) { txtInvoiceLineId.Text = invl.InvoiceLineId.ToString(); inv = invl.ProfessionalInvoice; taxt = invl.TaxType; LoadInvoiceData(); //tck = invl.Ticket; //if (tck != null) //{ // txtTicketId.Text = tck.TicketId.ToString(); // txtTicketData.Text = String.Format("{0} ({1}: {2:###,##0.00})" // , tck.Policy.Customer.FullName // , tck.Description // , tck.Amount); //} LoadTaxTypeCombo(taxt); txtDescription.Text = invl.Description; txtTaxPercentage.Text = String.Format("{0:##0.00}", invl.TaxPercentage); txtAmount.Text = String.Format("{0:###,##0.00}", invl.Amount); }
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { // weonly 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": inv = (from i in ctx.ProfessionalInvoices where i.InvoiceId == id select i).FirstOrDefault<ProfessionalInvoice>(); if (!CntAriCli.DeleteProfessionalInvoice(inv, ctx)) { lblMessage.Text = Resources.GeneralResource.DeleteInvoiceFailed; return; } lblMessage.Text = ""; ctx.SaveChanges(); RefreshGrid(true); break; } } }
protected void UnloadData(ProfessionalInvoice inv) { //inv.Serial = txtInvoiceSerial.Text; inv.Year = Int32.Parse(txtYear.Text); inv.Serial = txtInvoiceSerial.Text; ProfessionalId = Int32.Parse(txtProfessionalId.Text); inv.Professional = CntAriCli.GetProfessional(ProfessionalId, ctx); inv.InvoiceDate = (DateTime)rddpInvoiceDate.SelectedDate; inv.Amount = CntAriCli.GetProfessionalInvoiceTotal(inv); if (inv.Professional.TaxWithholdingType == null) { inv.TaxWithHoldingPercentage = 0; } else { inv.TaxWithHoldingPercentage = inv.Professional.TaxWithholdingType.Percentage / 100; } if (txtInvoiceNumber.Text == "") { try { inv.InvoiceNumber = CntAriCli.GetNextProfessionalInvoiceNumber(inv.Professional, inv.Year, ctx); } catch (NullReferenceException nre) { inv.InvoiceNumber = 1; } } inv.InvoiceKey = String.Format("{0}-{1:000000}-{2}", inv.Year, inv.InvoiceNumber, inv.Serial); }
protected void LoadData(ProfessionalInvoice inv) { txtInvoiceId.Text = inv.InvoiceId.ToString(); txtInvoiceSerial.Text = inv.Serial;//.Serial; txtYear.Text = inv.Year.ToString(); txtInvoiceNumber.Text = String.Format("{0:000000}", inv.InvoiceNumber); rddpInvoiceDate.SelectedDate = inv.InvoiceDate; txtProfessionalId.Text = inv.Professional.PersonId.ToString(); txtProfessionalName.Text = inv.Professional.ComercialName; txtInvoiceTotal.Text = String.Format("{0:####,#0.00}", inv.Amount); }
protected bool CreateChange() { if (!DataOk()) return false; if (inv == null) { inv = new ProfessionalInvoice(); UnloadData(inv); ctx.Add(inv); } else { inv = CntAriCli.GetProfessionalInvoice(invoiceId, ctx); UnloadData(inv); } ctx.SaveChanges(); return true; }
public static bool DeleteProfessionalInvoice(ProfessionalInvoice inv, AriClinicContext ctx) { // Last invoice number? int n = GetNextProfessionalInvoiceNumber(inv.Professional, inv.Year, ctx) - 1; // only the last invoice can be deleted if (inv.InvoiceNumber != n) return false; // delete lines ctx.Delete(inv.ProfessionalInvoiceLines); // delete invoice ctx.Delete(inv); return true; }
public static Decimal GetProfessionalInvoiceTotal(ProfessionalInvoice inv) { Decimal total = 0; foreach (ProfessionalInvoiceLine invl in inv.ProfessionalInvoiceLines) { total += invl.Amount; } return total; }