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 == "Estimate"
                         select p).FirstOrDefault<Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
         btnAccept.Visible = per.Modify;
     }
     //
     LoadComboInsurance();
     // 
     if (Request.QueryString["EstimateId"] != null)
     {
         estId = Int32.Parse(Request.QueryString["EstimateId"]);
         est = CntAriCli.GetEstimate(estId, ctx);
         
     }
     // 
     if (Request.QueryString["EstimateLineId"] != null)
     {
         estlId = Int32.Parse(Request.QueryString["EstimateLineId"]);
         estl = CntAriCli.GetEstimateLine(estlId, ctx);
         LoadData(estl);
     }
 }
示例#2
0
 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 == "estimate"
                         select p).FirstOrDefault<Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
         btnAccept.Visible = per.Modify;
     }
     //
     if (Request.QueryString["RequestId"] != null)
     {
         reqId = Int32.Parse(Request.QueryString["RequestId"]);
         req = CntAriCli.GetRequest(reqId, ctx);
         txtRequestRequestId.Text = req.RequestId.ToString();
         if (req.Patient != null)
         {
             txtFullName.Text = req.Patient.FullName;
         }
         else
         {
             txtFullName.Text = req.FullName;
         }
     }
     // 
     if (Request.QueryString["EstimateId"] != null)
     {
         estimateId = Int32.Parse(Request.QueryString["EstimateId"]);
         estimate = CntAriCli.GetEstimate(estimateId, ctx);
         req = estimate.Request;
         LoadData(estimate);
     }
     else
     {
         // default values for a new Estimate
         rdtEstimateDate.SelectedDate = DateTime.Now;
     }
     if (Request.QueryString["Caller"] != null)
     {
         caller = Request.QueryString["Caller"];
     }
 }
示例#3
0
    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 == "rtickets"
                            select p).FirstOrDefault<Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
        }
        // cheks if is call from another form
        if (Request.QueryString["Report"] != null)
            report = Request.QueryString["Report"];
        if (Request.QueryString["FDate"] != null)
            fDate = CntWeb.ParseUrlDate(Request.QueryString["FDate"]);
        if (Request.QueryString["TDate"] != null)
            tDate = CntWeb.ParseUrlDate(Request.QueryString["TDate"]);
        if (Request.QueryString["Diary"] != null)
            diary = CntAriCli.GetDiary(int.Parse(Request.QueryString["Diary"]),ctx);
        if (Request.QueryString["Visit"] != null)
            visit = CntAriCli.GetVisit(int.Parse(Request.QueryString["Visit"]), ctx);
        if (Request.QueryString["Treatment"] != null)
            treatment = CntAriCli.GetTreatment(int.Parse(Request.QueryString["Treatment"]), ctx);
        if (Request.QueryString["Invoice"] != null)
            invoice = CntAriCli.GetInvoice(int.Parse(Request.QueryString["Invoice"]), ctx);
        if (Request.QueryString["AmendmentInvoice"] != null)
            aInvoice = CntAriCli.GetAmendementInvoice(int.Parse(Request.QueryString["AmendmentInvoice"]), ctx);

        if (Request.QueryString["PrescriptionGlasses"] != null)
            prescriptionGlasses = CntAriCli.GetPrescriptionGlasses(int.Parse(Request.QueryString["PrescriptionGlasses"]), ctx);
        if (Request.QueryString["Estimate"] != null)
            estimate = CntAriCli.GetEstimate(int.Parse(Request.QueryString["Estimate"]), ctx);
    }
示例#4
0
 protected void btnEstimate_Click(object sender, ImageClickEventArgs e)
 {
     if (!CreateChange())
         return;
     // check if 
     string command = "";
     if (req.Estimates.Count > 0)
     {
         // There's a replay already
         Estimate est = req.Estimates[0];
         command = String.Format("EditEstimateRecord('{0}','{1}');", est.EstimateId, req.RequestId);
     }
     else
     {
         Estimate est = new Estimate();
         est.User = user;
         est.FullName = req.FullName;
         est.Request = req;
         est.EstimateDate = DateTime.Now;
         if (req.Patient != null)
             est.FullName = req.Patient.FullName;
         else
             est.FullName = req.FullName;
         ctx.Add(est);
         ctx.SaveChanges(); 
         if (req.Service != null)
         {
             if (req.Patient != null && req.Patient.Customer != null && req.Patient.Customer.Policies.Count > 0)
             {
                 Policy pol = req.Patient.Customer.Policies[0];
                 InsuranceService inss = (from i in ctx.InsuranceServices
                                          where i.Insurance == pol.Insurance
                                          && i.Service.ServiceId == req.Service.ServiceId
                                          select i).FirstOrDefault<InsuranceService>();
                 if (inss != null)
                 {
                     // estimate line
                     EstimateLine estl = new EstimateLine();
                     est.Comments = "";
                     estl.Estimate = est;
                     estl.InsuranceService = inss;
                     estl.Amount = inss.Price;
                     estl.Discount = 0;
                     estl.Description = inss.Service.Name;
                     ctx.Add(estl);
                     est.Total = estl.Amount;
                     ctx.SaveChanges();
                 }
             }
         }
         command = String.Format("EditEstimateRecord('{0}','{1}');", est.EstimateId, req.RequestId);
     }
     // string command = "CloseAndRebind('')";
     RadAjaxManager1.ResponseScripts.Add(command);
 }
示例#5
0
 protected void RefreshTotal(Estimate est)
 {
     decimal total = 0;
     if (estimate == null)
     {
         lblTotal.Text = String.Format("TOTAL: {0:###,###,#0.00}", total);
         return;
     }
     foreach (EstimateLine estl in est.EstimateLines)
     {
         total += (estl.Amount - estl.Discount);
     }
     est.Total = total;
     lblTotal.Text = String.Format("TOTAL: {0:###,###,#0.00}", est.Total);
 }
示例#6
0
 protected void UnloadData(Estimate estimate)
 {
     estimate.EstimateDate = (DateTime)rdtEstimateDate.SelectedDate;
     estimate.FullName = txtFullName.Text;
     estimate.Comments = txtComments.Text;
     estimate.Request = req;
     estimate.User = user;
     RefreshTotal(estimate);
 }
示例#7
0
 protected void LoadData(Estimate estimate)
 {
     txtEstimateId.Text = estimate.EstimateId.ToString();
     rdtEstimateDate.SelectedDate = estimate.EstimateDate;
     txtFullName.Text = estimate.FullName;
     txtComments.Text = estimate.Comments;
     lblTotal.Text = String.Format("TOTAL: {0:###,###,#0.00}", estimate.Total);
 }
示例#8
0
 protected bool CreateChange()
 {
     if (!DataOk())
         return false;
     if (estimate == null)
     {
         estimate = new Estimate();
         UnloadData(estimate);
         ctx.Add(estimate);
     }
     else
     {
         estimate = CntAriCli.GetEstimate(estimateId, ctx);
         UnloadData(estimate);
     }
     ctx.SaveChanges();
     return true;
 }
示例#9
0
 public static void DeleteEstimate(Estimate e, AriClinicContext ctx)
 {
     // there's nothing to delete if it's null
     if (e == null) return;
     // delete associate estimate lines
     foreach (EstimateLine el in e.EstimateLines)
     {
         ctx.Delete(el);
     }
     ctx.Delete(e);
     ctx.SaveChanges();
 }