private void WebForm1_BubbleClick(object sender, EventArgs e)
    {
        //Response.Write("WebForm1 :: WebForm1_BubbleClick from " +
        //               sender.GetType().ToString() + "<BR>");

        int caseID = int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);


        //Session["CaseID"] = caseID;
        GetAllAttorney(caseID);
        
        GetTarikh();
     

        GetAllLitigants(caseID);
        LoadLitigants();
        this.pnlMain.Visible = true;
        this.addBtnDiv.Visible = true;
        
        Session["TarikhList1"] = Session["Tarikh"];

        
        


    }
    protected void GetTarikhLocation()
    {
        int caseID = int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);

        tarikhLocationGrid.DataSource = BLLTarikhLocation.GetTarikhLocation(caseID);
        tarikhLocationGrid.DataBind();
    }
    //protected void tarikhDetailsGrid_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    GridViewRow row = ((GridView)sender).SelectedRow;

    //    if (row == null) return;

    //    ModalPopupExtender Extender = row.FindControl("extPerson") as ModalPopupExtender;


    //    if (Extender != null)
    //    {
    //        Extender.Show();
    //    }
    //}

  
    //protected void tarikhDetailsGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    //{
    //    e.Row.Cells[0].Visible = false;
    //}
    //protected void tarikhListGrid_RowEditing(object sender, GridViewEditEventArgs e)
    //{
    //    this.tarikhListGrid.EditIndex = e.NewEditIndex;
    //    this.tarikhListGrid.DataSource = (List<ATTTarikh>)Session["TarikhList"];
    //    this.tarikhListGrid.DataBind();
    //}
    //protected void tarikhListGrid_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    //{
    //    this.tarikhListGrid.EditIndex = -1;
    //    this.tarikhListGrid.DataSource = (List<ATTTarikh>)Session["TarikhList"];
    //    this.tarikhListGrid.DataBind();
    //}
    //protected void tarikhListGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
    //{
    //    List<ATTTarikh> tarikhLst=(List<ATTTarikh>)Session["TarikhList"];
    //    int personId = Convert.ToInt32(this.tarikhListGrid.DataKeys[(e.RowIndex)].Values["PersonID"]);

    //    int index = tarikhLst.FindIndex
    //    (
    //        delegate(ATTTarikh obj)
    //        {
    //            return obj.PersonID == personId;

    //        }
    //    );

        
    //    tarikhLst[index].TakenTime = ((TextBox)tarikhListGrid.Rows[e.RowIndex].Cells[1].FindControl("takenDateTxtEdit")).Text;
    //    tarikhLst[index].PresentDate = ((TextBox)tarikhListGrid.Rows[e.RowIndex].Cells[2].FindControl("presentDateTxtEdit")).Text;
    //    tarikhLst[index].Action = "E";
    //    Session["TarikhList"] = tarikhLst;
    //    this.tarikhListGrid.EditIndex = -1;
    //    this.tarikhListGrid.DataSource = (List<ATTTarikh>)Session["TarikhList"];
    //    this.tarikhListGrid.DataBind();





    //}
    protected void saveTarikhListBtn_Click(object sender, EventArgs e)
    {
        if (this.tarikhGrid.SelectedIndex > -1)
        {
            
            ATTTarikh tarikh=new ATTTarikh();
            List<ATTTarikh> listTarikh = new List<ATTTarikh>();
           
            tarikh.CaseID=int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);
            tarikh.TarikhDate = tarikhGrid.SelectedRow.Cells[0].Text;
            tarikh.TarikhTime =((TextBox)tarikhGrid.SelectedRow.FindControl("tarikhTimeTxt")).Text;
            tarikh.Action="E";

        
        List<ATTTarikh> tarikhLst = (List<ATTTarikh>)Session["TarikhList"];
        try
        {
            BLLTarikh.AddTarikhDetails(tarikhLst);
            BLLTarikh.AddTarikh(listTarikh);
            lblStatusMessage.Text = "Tarikh List Updated Successfully";
            this.programmaticModalPopup.Show();
            return;
        }
        catch (Exception ex)
        {
            this.lblStatusMessage.Text = "Tarikh List Could not be updated " + ex.Message;
            this.programmaticModalPopup.Show();
            return;
        }
    }

    }
    private void WebForm1_BubbleClick(object sender, EventArgs e)
    {
        int caseID = int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);

        GetAllAttorney(caseID);
        GetAllWitnesses(caseID);
        GetAllLitigants(caseID);
        LoadLitigants();
        this.CollapsiblePanelExtender1.ClientState = "false";
        this.CollapsiblePanelExtender1.Collapsed   = false;

        //if (LitigantsAppelant.Count > 0 || LitigantsRespondant.Count > 0)
        //{
        this.collCasesearch.Collapsed   = true;
        this.collCasesearch.ClientState = "true";
        //}
        //else
        //{
        //    this.collCasesearch.ClientState = "false";
        //    this.collCasesearch.Collapsed = false;
        //}

        //ScriptManager.RegisterStartupScript(this, this.GetType(), "hideTr", "javascript:alert('hello');", true);

        if (ddlMyaadType.SelectedIndex < 1)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "hideTra", "javascript:disableAllCheckBoxes();", true);
        }
    }
 protected void GetTarikh()
 {
     int caseId=int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);
     List<ATTTarikh> lst = BLLTarikh.GetTarikh(caseId);
     Session["Tarikh"] = lst;
     tarikhGrid.DataSource = lst;
     tarikhGrid.DataBind();
 }
 void ClearCaseSearch()
 {
     ((GridView)CaseSearch1.FindControl("grdCase")).SelectedIndex = -1;
     ((GridView)CaseSearch1.FindControl("grdCase")).DataSource    = "";
     ((GridView)CaseSearch1.FindControl("grdCase")).DataBind();
     ((DropDownList)CaseSearch1.FindControl("ddlCaseType")).SelectedIndex = -1;
     ((TextBox)CaseSearch1.FindControl("txtRegNo")).Text          = "";
     ((TextBox)CaseSearch1.FindControl("txtCaseNo")).Text         = "";
     ((TextBox)CaseSearch1.FindControl("txtRegDate")).Text        = "";
     ((TextBox)CaseSearch1.FindControl("txtAppelantName")).Text   = "";
     ((TextBox)CaseSearch1.FindControl("txtRespondantName")).Text = "";
 }
    private void WebForm1_BubbleClickBtn(object sender, EventArgs e)
    {
        if (((GridView)CaseSearch1.FindControl("grdCase")).Rows.Count < 1)
        {
            grdLitigantsApp.DataSource = null;
            grdLitigantRes.DataSource  = null;
            grdLitigantsApp.DataBind();
            grdLitigantRes.DataBind();
        }



        this.CollapsiblePanelExtender1.Collapsed   = true;
        this.CollapsiblePanelExtender1.ClientState = "true";
    }
    private void WebForm1_BubbleClickBtn(object sender, EventArgs e)
    {
        if (((GridView)CaseSearch1.FindControl("grdCase")).Rows.Count < 1)
        {
            grdLitigantsApp.DataSource = null;
            grdLitigantRes.DataSource = null;
            grdLitigantsApp.DataBind();
            grdLitigantRes.DataBind();
        }



        this.pnlMain.Visible = false;
        this.addBtnDiv.Visible = false;

    }
    protected void tarikhGrid_SelectedIndexChanged(object sender, EventArgs e)
    {
        tarikhDateTxt.Enabled = true;
        int caseId = int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);
        string tarikhDate = tarikhGrid.SelectedRow.Cells[0].Text;
        GetTarkihList(caseId, tarikhDate);
        tarikhDateTxt.Text = tarikhDate;
        tarikhTimeTxt.Text = tarikhGrid.SelectedRow.Cells[1].Text;

        List<ATTTarikh> lst = (List<ATTTarikh>)Session["Tarikh"];
        if (lst[this.tarikhGrid.SelectedIndex].Action != "A")
        {
            tarikhDateTxt.Enabled = false;
        }
        
        
    }
    private void WebForm1_BubbleClick(object sender, EventArgs e)
    {
        //Response.Write("WebForm1 :: WebForm1_BubbleClick from " +
        //               sender.GetType().ToString() + "<BR>");

        int caseID = int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);


        //Session["CaseID"] = caseID;
        GetAllAttorney(caseID);

        GetAllLitigants(caseID);
        LoadLitigants();
        GetTarikhLocation();
        displayAllControlDiv.Visible = true;
        this.CollapsiblePanelExtender1.ClientState = "false";
        this.CollapsiblePanelExtender1.Collapsed   = false;
    }
    protected void tarikhLocationGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int caseID   = int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);
        int courtID  = Convert.ToInt32((this.tarikhLocationGrid.DataKeys[(e.RowIndex)].Values["CourtID"]));
        int personID = Convert.ToInt32((this.tarikhLocationGrid.DataKeys[(e.RowIndex)].Values["PersonID"]));

        try
        {
            BLLTarikhLocation.DeleteTarikhLocation(caseID, personID, courtID);
            GetTarikhLocation();
            lblStatusMessage.Text = "Deleted Successfully";
            programmaticModalPopup.Show();
        }
        catch (Exception ex)
        {
            throw ex;
            programmaticModalPopup.Show();
        }
    }
    private void ClearControls()
    {
        ///// UserControl Controls
        GridView grd = (GridView)CaseSearch1.FindControl("grdCase");

        grd.DataSource = null;
        grd.DataBind();
        ((DropDownList)CaseSearch1.FindControl("ddlCaseType")).SelectedIndex = -1;
        ((TextBox)CaseSearch1.FindControl("txtCaseNo")).Text       = "";
        ((TextBox)CaseSearch1.FindControl("txtRegNo")).Text        = "";
        ((TextBox)CaseSearch1.FindControl("txtRegDate")).Text      = "";
        ((TextBox)CaseSearch1.FindControl("txtAppelantName")).Text = "";
        ////
        grdLitigantsApp.DataSource = null;
        grdLitigantRes.DataSource  = null;
        grdLitigantsApp.DataBind();
        grdLitigantRes.DataBind();


        txtIssuedDate.Text = "";
        //txtPost.Text = "";
        txtPublicationDate.Text = "";
        txtTameliMedia.Text     = "";
        //txtTameliWitnessPerson.Text = "";
        ddlCourt.SelectedIndex      = -1;
        ddlMyaadType.SelectedIndex  = -1;
        ddlTameliType.SelectedIndex = -1;
        grdTamilDaar.SelectedIndex  = -1;

        TameliWitPersonLST  = null;
        ALLAttorneyLIST     = null;
        LitigantsLIST       = null;
        LitigantsAppelant   = null;
        LitigantsRespondant = null;

        this.collCasesearch.Collapsed              = false;
        this.collCasesearch.ClientState            = "false";
        this.CollapsiblePanelExtender1.ClientState = "true";
        this.CollapsiblePanelExtender1.Collapsed   = true;

        this.CollapsiblePanelExtender2.ClientState = "true";
        this.CollapsiblePanelExtender2.Collapsed   = true;
    }
    private void WebForm1_BubbleClick(object sender, EventArgs e)
    {
        //uctl grd selected index changed
        Session["CaseID"]     = int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);
        Session["CaseTypeID"] = int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[0].Text);

        try
        {
            List <ATTSectionCaseType> OrgUnitList = BLLSectionCaseType.GetSecCaseType(orgID, (int)Session["CaseTypeID"]);

            Session["UnitList"]        = OrgUnitList;
            lstOrgUnits.DataSource     = OrgUnitList;
            lstOrgUnits.DataTextField  = "UnitName";
            lstOrgUnits.DataValueField = "UnitID";
            lstOrgUnits.DataBind();
        }
        catch (Exception ex)
        {
            lblStatusMessage.Text = ex.Message;
            programmaticModalPopup.Show();
        }
    }
    protected void TarikhFunction()
    {
        if (tarikhGrid.SelectedIndex < 0)
        {
            if (tarikhDateTxt.Text == "")
            {
                this.lblStatusMessage.Text = "कृपया तारिख मिति राख्नुहोस्";
                this.programmaticModalPopup.Show();
                return;
            }

            List<ATTTarikh> lst = (List<ATTTarikh>)Session["Tarikh"];
            ATTTarikh obj = new ATTTarikh();
            obj.TarikhDate = tarikhDateTxt.Text;
            obj.TarikhTime = tarikhTimeTxt.Text;
            obj.CaseID = int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);
            obj.Action = "A";
            obj.EntryBy = entryBy;
            lst.Add(obj);
            tarikhGrid.DataSource = lst;
            tarikhGrid.DataBind();
            tarikhGrid.SelectedIndex = tarikhGrid.Rows.Count - 1;
            Session["TarikhList1"] = lst;
        }
        else if (tarikhGrid.SelectedIndex > -1)
        {
            List<ATTTarikh> lst = (List<ATTTarikh>)Session["Tarikh"];
            lst[this.tarikhGrid.SelectedIndex].TarikhTime = tarikhTimeTxt.Text;
            lst[this.tarikhGrid.SelectedIndex].CaseID= int.Parse(((GridView)CaseSearch1.FindControl("grdCase")).SelectedRow.Cells[2].Text);
            lst[this.tarikhGrid.SelectedIndex].Action = "E";
            tarikhGrid.DataSource = lst;
            tarikhGrid.DataBind();
            
            Session["TarikhList1"] = lst;
        }
    }