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; } }