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 = (User)Session["User"];
            user = CntAriCli.GetUser(user.UserId, ctx);
            Process proc = (from p in ctx.Processes
                            where p.Code == "examinationassigned"
                            select p).FirstOrDefault <Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }

        //
        if (Request.QueryString["OpticalObjectiveExaminationId"] != null)
        {
            id = Int32.Parse(Request.QueryString["OpticalObjectiveExaminationId"]);
            OpticalObjectiveExamination = CntAriCli.GetOpticalObjectiveExamination(id, ctx);
            refractometry = OpticalObjectiveExamination.Refractometry;
            LoadData(OpticalObjectiveExamination);
        }
        if (Request.QueryString["RefractometryId"] != null)
        {
            id            = int.Parse(Request.QueryString["RefractometryId"]);
            refractometry = (Refractometry)CntAriCli.GetExaminationAssigned(id, ctx);
        }
    }
 protected bool CreateChange()
 {
     if (!DataOk())
     {
         return(false);
     }
     if (OpticalObjectiveExamination == null)
     {
         OpticalObjectiveExamination = new OpticalObjectiveExamination();
         OpticalObjectiveExamination.Refractometry = refractometry;
         UnloadData(OpticalObjectiveExamination);
         ctx.Add(OpticalObjectiveExamination);
     }
     else
     {
         OpticalObjectiveExamination = CntAriCli.GetOpticalObjectiveExamination(OpticalObjectiveExamination.Id, ctx);
         UnloadData(OpticalObjectiveExamination);
     }
     ctx.SaveChanges();
     RadAjaxManager1.ResponseScripts.Add(String.Format("showDialog('{0}','{1}','success',null,0,0)"
                                                       , Resources.GeneralResource.Success
                                                       , Resources.GeneralResource.CorrectlyStored));
     Response.Redirect(String.Format("OpticalObjectiveExaminationForm.aspx?OpticalObjectiveExaminationId={0}", OpticalObjectiveExamination.Id));
     return(true);
 }
    protected void LoadData(OpticalObjectiveExamination ooex)
    {
        txtFarAcuity.Text               = ooex.FarAcuity;
        txtFarAxisLeftEye.Text          = ooex.FarAxisLeftEye;
        txtFarAxisRightEye.Text         = ooex.FarAxisRightEye;
        txtFarCenter.Text               = ooex.FarCenters;
        txtFarCylinderLeftEye.Text      = ooex.FarCylinderLeftEye;
        txtFarCylinderRightEye.Text     = ooex.FarCylinderRightEye;
        txtFarPrismLeftEye.Text         = ooex.FarPrismLeftEye;
        txtFarPrismRightEye.Text        = ooex.FarPrimsRightEye;
        txtFarSphericityLefttEye.Text   = ooex.FarSphericityLeftEye;
        txtFarSphericityRightEye.Text   = ooex.FarSphericityRightEye;
        txtFarVisualAcuityLeftEye.Text  = ooex.FarVisualAcuityLeftEye;
        txtFarVisualAcuityRightEye.Text = ooex.FarVisualAcuityRightEye;

        txtCloseAcuity.Text               = ooex.CloseAcuity;
        txtCloseAxisLeftEye.Text          = ooex.CloseAxisLeftEye;
        txtCloseAxisRightEye.Text         = ooex.CloseAxisRightEye;
        txtCloseCenter.Text               = ooex.CloseCenters;
        txtCloseCylinderLeftEye.Text      = ooex.CloseCylinderLeftEye;
        txtCloseCylinderRightEye.Text     = ooex.CloseCylinderRightEye;
        txtClosePrismLeftEye.Text         = ooex.ClosePrismLeftEye;
        txtClosePrismRightEye.Text        = ooex.ClosePrismRightEye;
        txtCloseSphericityLefttEye.Text   = ooex.CloseSphericityLeftEye;
        txtCloseSphericityRightEye.Text   = ooex.CloseSphericityRightEye;
        txtCloseVisualAcuityLeftEye.Text  = ooex.CloseAcuityLeftEye;
        txtCloseVisualAcuityRightEye.Text = ooex.CloseAcuityRightEye;

        txtBothAcuity.Text               = ooex.BothAcuity;
        txtBothAxisLeftEye.Text          = ooex.BothAxisLeftEye;
        txtBothAxisRightEye.Text         = ooex.BothAxisRightEye;
        txtBothCenter.Text               = ooex.BothCenters;
        txtBothCylinderLeftEye.Text      = ooex.BothCylinderLeftEye;
        txtBothCylinderRightEye.Text     = ooex.BothCylinderRightEye;
        txtBothPrismLeftEye.Text         = ooex.BothPrismLeftEye;
        txtBothPrismRightEye.Text        = ooex.BothPrismRightEye;
        txtBothSphericityLefttEye.Text   = ooex.BothSphericityLeftEye;
        txtBothSphericityRightEye.Text   = ooex.BothSphericityRightEye;
        txtBothVisualAcuityLeftEye.Text  = ooex.BothAcuityLeftEye;
        txtBothVisualAcuityRightEye.Text = ooex.BothAcuityRightEye;

        txtK1RightEye.Text = ooex.K1RightEye;
        txtK1LeftEye.Text  = ooex.K1LeftEye;
        txtK2RightEye.Text = ooex.K2RightEye;
        txtK2LeftEye.Text  = ooex.K2LeftEye;


        txtComments.Text = ooex.Comments;
    }