Example #1
0
 protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
 {
     RefreshGrid(true);
     if (e.Argument == "new")
     {
         //RadGrid1.CurrentPageIndex = RadGrid1.PageCount - 1;
         RadGrid1.Rebind();
     }
     if (e.Argument == "yes")
     {
         if (Session["DeleteId"] != null)
         {
             try
             {
                 labTestAssignedId = (int)Session["DeleteId"];
                 labTestAssigned   = (from da in ctx.LabTestAssigneds
                                      where da.LabTestAssignedId == labTestAssignedId
                                      select da).FirstOrDefault <LabTestAssigned>();
                 ctx.Delete(labTestAssigned);
                 ctx.SaveChanges();
                 RefreshGrid(true);
                 Session["DeleteId"] = null;
             }
             catch (Exception ex)
             {
                 Session["Exception"] = ex;
                 string command = String.Format("showDialog('Error','{0}','error',null, 0, 0)"
                                                , Resources.GeneralResource.DeleteRecordFail);
                 RadAjaxManager1.ResponseScripts.Add(command);
             }
         }
     }
 }
    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 == "labtestassigned"
                            select p).FirstOrDefault <Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }

        //
        if (Request.QueryString["LabTestAssignedId"] != null)
        {
            labTestcAssignedId = Int32.Parse(Request.QueryString["LabTestAssignedId"]);
            labTestAssigned    = CntAriCli.GetLabTestAssigned(labTestcAssignedId, ctx);
            LoadData(labTestAssigned);
        }
        else
        {
            rdpLabTestDate.SelectedDate = DateTime.Now;
        }
        //
        if (Request.QueryString["PatientId"] != null)
        {
            patientId = int.Parse(Request.QueryString["PatientId"]);
            patient   = CntAriCli.GetPatient(patientId, ctx);
            // fix rdc with patient
            rdcPatient.Items.Clear();
            rdcPatient.Items.Add(new RadComboBoxItem(patient.FullName, patient.PersonId.ToString()));
            rdcPatient.SelectedValue = patient.PersonId.ToString();
            rdcPatient.Enabled       = false;
        }
        //
        if (Request.QueryString["VisitId"] != null)
        {
            visitId   = int.Parse(Request.QueryString["VisitId"]);
            visit     = CntAriCli.GetVisit(visitId, ctx);
            patientId = visit.Patient.PersonId;
            patient   = CntAriCli.GetPatient(patientId, ctx);
            // fix rdc with patient
            rdcPatient.Items.Clear();
            rdcPatient.Items.Add(new RadComboBoxItem(patient.FullName, patient.PersonId.ToString()));
            rdcPatient.SelectedValue = patient.PersonId.ToString();
            rdcPatient.Enabled       = false;
        }
    }
 protected void UnloadData(LabTestAssigned lta)
 {
     lta.Patient     = CntAriCli.GetPatient(int.Parse(rdcPatient.SelectedValue), ctx);
     lta.LabTestDate = (DateTime)rdpLabTestDate.SelectedDate;
     lta.LabTest     = CntAriCli.GetLabTest(int.Parse(rdcLabTest.SelectedValue), ctx);
     if (lta.LabTest.GeneralType == "LBTN")
     {
         lta.NumValue = decimal.Parse(txtValue.Text);
     }
     else
     {
         lta.StringValue = txtValue.Text;
     }
     if (visit != null)
     {
         lta.BaseVisit = visit;
     }
     lta.Comments = txtComments.Text;
 }
 protected bool CreateChange()
 {
     if (!DataOk())
     {
         return(false);
     }
     if (labTestAssigned == null)
     {
         labTestAssigned = new LabTestAssigned();
         UnloadData(labTestAssigned);
         ctx.Add(labTestAssigned);
     }
     else
     {
         labTest = CntAriCli.GetLabTest(labTestId, ctx);
         UnloadData(labTestAssigned);
     }
     ctx.SaveChanges();
     return(true);
 }
    protected void LoadData(LabTestAssigned lta)
    {
        // Load patient data
        rdcPatient.Items.Clear();
        rdcPatient.Items.Add(new RadComboBoxItem(lta.Patient.FullName, lta.Patient.PersonId.ToString()));
        rdcPatient.SelectedValue = lta.Patient.PersonId.ToString();

        // Load diagnostic data
        rdcLabTest.Items.Clear();
        rdcLabTest.Items.Add(new RadComboBoxItem(lta.LabTest.Name, lta.LabTest.LabTestId.ToString()));
        rdcLabTest.SelectedValue = lta.LabTest.LabTestId.ToString();

        rdpLabTestDate.SelectedDate = lta.LabTestDate;
        if (lta.LabTest.GeneralType == "LBTN")
        {
            //txtValue.Text = lta.NumValue.ToString();
            txtValue.Text = String.Format("{0:#.#}", lta.NumValue);
        }
        else
        {
            txtValue.Text = lta.StringValue;
        }
        txtComments.Text = lta.Comments;
    }
Example #6
0
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem)
        {
            ImageButton imgb = (ImageButton)e.Item.FindControl("New");
            imgb.Visible = per.Create;
            if (patient != null)
            {
                imgb.OnClientClick = "NewLabTestAssignedRecordInTab();";
            }
            if (visit != null)
            {
                imgb.OnClientClick = "NewLabTestAssignedRecordInVisit()";
            }
        }
        if (e.Item is GridDataItem)
        {
            ImageButton  imgb    = null;
            string       name    = "";
            string       command = "";
            GridDataItem gdi;
            int          id = 0;

            id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]];

            // assign javascript function to select button
            imgb    = (ImageButton)e.Item.FindControl("Select");
            gdi     = (GridDataItem)e.Item;
            name    = gdi["Patient.FullName"].Text + ": " + gdi["LabTest.Name"].Text;
            command = String.Format("return Selection('{0}','{1}','{2}','{3}','{4}');"
                                    , id.ToString()
                                    , null
                                    , name
                                    , null
                                    , "LabTest");
            imgb.OnClientClick = command;
            if (type != "S")
            {
                imgb.Visible = false;              // not called from another form
            }
            // assign javascript function to edit button
            imgb    = (ImageButton)e.Item.FindControl("Edit");
            command = String.Format("return EditLabTestAssignedRecord({0});", id);
            if (patient != null)
            {
                command = String.Format("return EditLabTestAssignedRecordInTab({0});", id);
            }
            if (visit != null)
            {
                command = String.Format("return EditLabTestAssignedRecordInVisit({0});", id);
            }
            imgb.OnClientClick = command;

            // assigning javascript functions to delete button
            imgb = (ImageButton)e.Item.FindControl("Delete");
            string message = Resources.GeneralResource.DeleteRecordQuestion;
            message      = String.Format("{0}<br/>{1}", message, name);
            command      = String.Format("ariDialog('LabTestos asignados','{0}','prompt',null,0,0)", message);
            imgb.Visible = per.Create;

            // showing the value
            LabTestAssigned lt = CntAriCli.GetLabTestAssigned(id, ctx);
            Label           lb = (Label)e.Item.FindControl("lblValue");
            if (lt.LabTest.GeneralType == "LBTN")
            {
                //lb.Text = lt.NumValue.ToString();
                lb.Text = String.Format("{0:#.#}", lt.NumValue);
            }
            else
            {
                lb.Text = lt.StringValue;
            }
        }
    }