protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Common_EncryptDecryptBL objCommon_EncryptDecryptBL = new Common_EncryptDecryptBL();
            ipdObservationId = objCommon_EncryptDecryptBL.Decrypt(Request.QueryString["ipdObservationId"].ToString());

            Doctor_GetPatientDetailsByIPDObservationIDBL objDoctor_GetPatientDetailsByIPDObservationIDBL = new Doctor_GetPatientDetailsByIPDObservationIDBL();
            Label1.Text = objDoctor_GetPatientDetailsByIPDObservationIDBL.Doctor_GetPatientDetailsByIPDObservationID(ipdObservationId);

            Doctor_GetIPDObservationDetailsByIdBL objDoctor_GetIPDObservationDetailsByIdBL = new Doctor_GetIPDObservationDetailsByIdBL();
            ds1         = objDoctor_GetIPDObservationDetailsByIdBL.Doctor_GetIPDObservationDetailsById(ipdObservationId);
            Label2.Text = ds1.Tables[0].Rows[0]["OBSERVATION_DATE"].ToString();
            Label3.Text = ds1.Tables[0].Rows[0]["OBSERVATION_TIME"].ToString();
            Label4.Text = ds1.Tables[0].Rows[0]["PATIENT_GENERAL_HEALTH"].ToString();

            Doctor_GetIPDObservationReportBL objDoctor_GetIPDObservationReportBL = new Doctor_GetIPDObservationReportBL();
            ds2 = objDoctor_GetIPDObservationReportBL.Doctor_GetIPDObservationReport(ipdObservationId);
            GridView1.DataSource = ds2;
            GridView1.DataBind();

            Doctor_GetIPDObservationMedicineBL objDoctor_GetIPDObservationMedicineBL = new Doctor_GetIPDObservationMedicineBL();
            ds3 = objDoctor_GetIPDObservationMedicineBL.Doctor_GetIPDObservationMedicine(ipdObservationId);
            if (ds3.Tables[0].Rows.Count != 0)
            {
                GridView2.DataSource = ds3;
                GridView2.DataBind();
            }
            else
            {
                Label5.Visible = true;
            }

            Doctor_GetIPDObservationMedicalTestBL objDoctor_GetIPDObservationMedicalTestBL = new Doctor_GetIPDObservationMedicalTestBL();
            ds4 = objDoctor_GetIPDObservationMedicalTestBL.Doctor_GetIPDObservationMedicalTest(ipdObservationId);
            if (ds4.Tables[0].Rows.Count != 0)
            {
                GridView3.DataSource = ds4;
                GridView3.DataBind();
            }
            else
            {
                Label6.Visible = true;
            }
        }
    }
    private void GetMedicines()
    {
        Doctor_GetIPDObservationMedicineBL objGetIPDObservationMedicineBL = new Doctor_GetIPDObservationMedicineBL();

        medicineDataSet = objGetIPDObservationMedicineBL.Doctor_GetIPDObservationMedicine(ipdObservationId);
        if (medicineDataSet.Tables[0].Rows.Count != 0)
        {
            GridView3.DataSource = medicineDataSet;
            GridView3.DataBind();
            GridView3.Visible = true;
            Panel2.Visible    = true;
        }
        else
        {
            GridView3.Visible = false;
            Panel2.Visible    = false;
        }
    }
    protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        SetRowData();
        if (ViewState["CurrentTable"] != null)
        {
            DataTable dt           = (DataTable)ViewState["CurrentTable"];
            DataRow   drCurrentRow = null;
            int       rowIndex     = Convert.ToInt32(e.RowIndex);
            Doctor_DeleteIPDObservationReportBL objDoctor_DeleteIPDObservationReportBL = new Doctor_DeleteIPDObservationReportBL();
            objDoctor_DeleteIPDObservationReportBL.Doctor_DeleteIPDObservationReport(Convert.ToInt32(e.Values["RowNumber"].ToString()));
            Doctor_GetIPDObservationMedicineBL objGetIPDObservationMedicineBL = new Doctor_GetIPDObservationMedicineBL();
            GridView3.DataSource = objGetIPDObservationMedicineBL.Doctor_GetIPDObservationMedicine(ipdObservationId);
            GridView3.DataBind();
            GridView3.Visible = true;
            if (dt.Rows.Count > 1)
            {
                dt.Rows.Remove(dt.Rows[rowIndex]);
                drCurrentRow = dt.NewRow();
                ViewState["CurrentTable"] = dt;
                GridView2.DataSource      = dt;
                GridView2.DataBind();

                for (int i = 0; i < GridView2.Rows.Count - 1; i++)
                {
                    GridView2.Rows[i].Cells[0].Text = Convert.ToString(i + 1);
                }
                SetPreviousData();
            }
        }
        DropDownList6.Items.Clear();
        DropDownList2.Items.Clear();
        for (int i = 0; i < observationCount + 1; i++)
        {
            DropDownList6.Items.Add(new ListItem((i + 1).ToString(), (i + 1).ToString()));
            DropDownList2.Items.Add(new ListItem((i + 1).ToString(), (i + 1).ToString()));
        }
        DropDownList6.Items.Add(new ListItem("General", "0"));
        DropDownList2.Items.Add(new ListItem("General", "0"));
    }
 private void GetMedicines()
 {
     Doctor_GetIPDObservationMedicineBL objGetIPDObservationMedicineBL = new Doctor_GetIPDObservationMedicineBL();
     medicineDataSet = objGetIPDObservationMedicineBL.Doctor_GetIPDObservationMedicine(ipdObservationId);
     if(medicineDataSet.Tables[0].Rows.Count != 0)
     {
         GridView3.DataSource = medicineDataSet;
         GridView3.DataBind();
         GridView3.Visible = true;
         Panel2.Visible = true;
     }
     else
     {
         GridView3.Visible = false;
         Panel2.Visible = false;
     }
 }
    protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        SetRowData();
        if(ViewState["CurrentTable"] != null)
        {
            DataTable dt = (DataTable)ViewState["CurrentTable"];
            DataRow drCurrentRow = null;
            int rowIndex = Convert.ToInt32(e.RowIndex);
            Doctor_DeleteIPDObservationReportBL objDoctor_DeleteIPDObservationReportBL = new Doctor_DeleteIPDObservationReportBL();
            objDoctor_DeleteIPDObservationReportBL.Doctor_DeleteIPDObservationReport(Convert.ToInt32(e.Values["RowNumber"].ToString()));
            Doctor_GetIPDObservationMedicineBL objGetIPDObservationMedicineBL = new Doctor_GetIPDObservationMedicineBL();
            GridView3.DataSource = objGetIPDObservationMedicineBL.Doctor_GetIPDObservationMedicine(ipdObservationId);
            GridView3.DataBind();
            GridView3.Visible = true;
            if(dt.Rows.Count > 1)
            {
                dt.Rows.Remove(dt.Rows[rowIndex]);
                drCurrentRow = dt.NewRow();
                ViewState["CurrentTable"] = dt;
                GridView2.DataSource = dt;
                GridView2.DataBind();

                for(int i = 0; i < GridView2.Rows.Count - 1; i++)
                {
                    GridView2.Rows[i].Cells[0].Text = Convert.ToString(i + 1);
                }
                SetPreviousData();
            }
        }
        DropDownList6.Items.Clear();
        DropDownList2.Items.Clear();
        for(int i = 0; i < observationCount + 1; i++)
        {
            DropDownList6.Items.Add(new ListItem((i + 1).ToString(), (i + 1).ToString()));
            DropDownList2.Items.Add(new ListItem((i + 1).ToString(), (i + 1).ToString()));
        }
        DropDownList6.Items.Add(new ListItem("General", "0"));
        DropDownList2.Items.Add(new ListItem("General", "0"));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            Common_EncryptDecryptBL objCommon_EncryptDecryptBL = new Common_EncryptDecryptBL();
            ipdObservationId = objCommon_EncryptDecryptBL.Decrypt(Request.QueryString["ipdObservationId"].ToString());

            Doctor_GetPatientDetailsByIPDObservationIDBL objDoctor_GetPatientDetailsByIPDObservationIDBL = new Doctor_GetPatientDetailsByIPDObservationIDBL();
            Label1.Text = objDoctor_GetPatientDetailsByIPDObservationIDBL.Doctor_GetPatientDetailsByIPDObservationID(ipdObservationId);

            Doctor_GetIPDObservationDetailsByIdBL objDoctor_GetIPDObservationDetailsByIdBL = new Doctor_GetIPDObservationDetailsByIdBL();
            ds1 = objDoctor_GetIPDObservationDetailsByIdBL.Doctor_GetIPDObservationDetailsById(ipdObservationId);
            Label2.Text = ds1.Tables[0].Rows[0]["OBSERVATION_DATE"].ToString();
            Label3.Text = ds1.Tables[0].Rows[0]["OBSERVATION_TIME"].ToString();
            Label4.Text = ds1.Tables[0].Rows[0]["PATIENT_GENERAL_HEALTH"].ToString();

            Doctor_GetIPDObservationReportBL objDoctor_GetIPDObservationReportBL = new Doctor_GetIPDObservationReportBL();
            ds2 = objDoctor_GetIPDObservationReportBL.Doctor_GetIPDObservationReport(ipdObservationId);
            GridView1.DataSource = ds2;
            GridView1.DataBind();

            Doctor_GetIPDObservationMedicineBL objDoctor_GetIPDObservationMedicineBL = new Doctor_GetIPDObservationMedicineBL();
            ds3 = objDoctor_GetIPDObservationMedicineBL.Doctor_GetIPDObservationMedicine(ipdObservationId);
            if(ds3.Tables[0].Rows.Count != 0)
            {
                GridView2.DataSource = ds3;
                GridView2.DataBind();
            }
            else
                Label5.Visible = true;

            Doctor_GetIPDObservationMedicalTestBL objDoctor_GetIPDObservationMedicalTestBL = new Doctor_GetIPDObservationMedicalTestBL();
            ds4 = objDoctor_GetIPDObservationMedicalTestBL.Doctor_GetIPDObservationMedicalTest(ipdObservationId);
            if(ds4.Tables[0].Rows.Count != 0)
            {
                GridView3.DataSource = ds4;
                GridView3.DataBind();
            }
            else
                Label6.Visible = true;
        }
    }