예제 #1
0
    protected void btnSubmit_Click_1(object sender, EventArgs e)
    {
        lblOutput.Text = colorPicker.Value;



        Patient patient = PatientDB.GetByID(54950);

        if (patient == null)
        {
            throw new Exception("Invalid url id");
        }

        Hashtable selectedConditions = PatientConditionDB.GetHashtable_ByPatientID(patient.PatientID, false);

        foreach (ListItem li in chkBoxListConditions.Items)
        {
            if (li.Selected && selectedConditions[Convert.ToInt32(li.Value)] == null)
            {
                PatientConditionDB.Insert(patient.PatientID, Convert.ToInt32(li.Value), DateTime.MinValue, 0, "", false);
            }

            if (!li.Selected && selectedConditions[Convert.ToInt32(li.Value)] != null)
            {
                PatientConditionDB.Delete(patient.PatientID, Convert.ToInt32(li.Value));
            }
        }

        //SetErrorMessage("Updated");
        Response.Redirect(Request.RawUrl);
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Patient patient = PatientDB.GetByID(GetFormPatientID());

        if (patient == null)
        {
            throw new Exception("Invalid url id");
        }

        Hashtable selectedConditions = PatientConditionDB.GetHashtable_ByPatientID(patient.PatientID, false);

        foreach (GridViewRow row in GrdCondition.Rows)
        {
            Label        lblId          = row.FindControl("lblId") as Label;
            CheckBox     chkSelect      = row.FindControl("chkSelect") as CheckBox;
            DropDownList ddlDate_Day    = (DropDownList)row.FindControl("ddlDate_Day");
            DropDownList ddlDate_Month  = (DropDownList)row.FindControl("ddlDate_Month");
            DropDownList ddlDate_Year   = (DropDownList)row.FindControl("ddlDate_Year");
            DropDownList ddlNbrWeeksDue = (DropDownList)row.FindControl("ddlNbrWeeksDue");
            TextBox      txtText        = (TextBox)row.FindControl("txtText");


            if (lblId == null || chkSelect == null)
            {
                continue;
            }


            DateTime date = DateTime.MinValue;
            if (ddlDate_Day.Visible && ddlDate_Month.Visible && ddlDate_Year.Visible)
            {
                if (!IsValidDate(Convert.ToInt32(ddlDate_Day.Text), Convert.ToInt32(ddlDate_Month.Text), Convert.ToInt32(ddlDate_Year.Text)))
                {
                    SetErrorMessage("Please enter a valid date or unset all");
                    return;
                }
                else
                {
                    date = GetDateFromForm(Convert.ToInt32(ddlDate_Day.Text), Convert.ToInt32(ddlDate_Month.Text), Convert.ToInt32(ddlDate_Year.Text));
                }
            }

            int    nweeksdue = ddlNbrWeeksDue.Visible ? Convert.ToInt32(ddlNbrWeeksDue.Text) : 0;
            string text      = txtText.Visible ? txtText.Text.Trim() : string.Empty;

            if (chkSelect.Checked && selectedConditions[Convert.ToInt32(lblId.Text)] == null)
            {
                PatientConditionDB.Insert(patient.PatientID, Convert.ToInt32(lblId.Text), date, nweeksdue, text, false);
            }

            if (!chkSelect.Checked && selectedConditions[Convert.ToInt32(lblId.Text)] != null)
            {
                PatientConditionDB.Delete(patient.PatientID, Convert.ToInt32(lblId.Text));
            }

            if (chkSelect.Checked && selectedConditions[Convert.ToInt32(lblId.Text)] != null)
            {
                PatientConditionDB.Update(patient.PatientID, Convert.ToInt32(lblId.Text), date, nweeksdue, text, false);
            }
        }

        FillGrdCondition(patient);
        FillGrdConditionView(patient);

        SetErrorMessage("Updated");
    }