protected void Page_Load(object sender, EventArgs e)
    {
        Whitfield_Project _wc = new Whitfield_Project();
        whitfield_reports _wr = new whitfield_reports();
        // 1
        // Get collection
        NameValueCollection n = Request.QueryString;
        if (!Page.IsPostBack)
        {

            // See if any query string exists
            if (n.HasKeys())
            {
                // 3
                // Get first key and value
                string k = n.GetKey(0);
                string v = n.Get(0);
                string k1 = n.GetKey(1);
                string v1 = n.Get(1);

                if (Request.QueryString["hFlag"] == "D")
                {
                    _wc.DeleteProjDocument(Convert.ToInt32(Request.QueryString["EstNum"]), Convert.ToInt32(Request.QueryString["seqno"]), Convert.ToInt32(Request.QueryString["twcProjNumber"]));
                    ViewState["EstNum"] = Request.QueryString["EstNum"].ToString();
                    ViewState["twc_project_number"] = Request.QueryString["twcProjNumber"].ToString();
                    twc_project_number = Convert.ToInt32(Request.QueryString["twcProjNumber"].ToString());
                    DataSet dsGridResults = this.GetDocs();
                    this.PopulateDataGrid(dsGridResults, grddocs);
                }

                //Check for QueryString Date
                if (k == "ReportDate")
                {
                    txtReportDate.Text = v;
                    twc_project_number = Convert.ToInt32(v1);
                    EstNum = Convert.ToInt32(Request.QueryString["EstNum"].ToString());
                    ViewState["EstNum"] = Request.QueryString["EstNum"].ToString();
                    ViewState["twc_project_number"] = twc_project_number;
                    txtwhitPrjNumber.Text = twc_project_number.ToString() ;
                    txtrealPrjNumber.Text = _wc.GetReal_proj_Number(twc_project_number).ToString();
                    this.FetchAndBind(EstNum, twc_project_number);
                    ActiveIndexNumber = 4;
                }
                else
                {
                    txtReportDate.Text = _wr.GetCurrentDate().Trim();
                    twc_project_number = Convert.ToInt32(v1);
                    ViewState["EstNum"] = EstNum;
                    ViewState["twc_project_number"] = twc_project_number;
                    txtwhitPrjNumber.Text = ViewState["twc_project_number"].ToString();
                    txtrealPrjNumber.Text = _wc.GetReal_proj_Number(Convert.ToInt32(ViewState["twc_project_number"].ToString())).ToString();
                    this.FetchAndBind(EstNum, twc_project_number);
                }

                if (k == "EstNum")
                {
                    EstNum = Convert.ToInt32(v);  // Here goes the code for the creation of new EstNum
                    twc_project_number = Convert.ToInt32(v1);
                    ViewState["EstNum"] = EstNum;
                    ViewState["twc_project_number"] = twc_project_number;
                    //txtReportDate.Text = _wr.GetCurrentDate().Trim();
                    txtwhitPrjNumber.Text = ViewState["twc_project_number"].ToString();
                    txtrealPrjNumber.Text = _wc.GetReal_proj_Number(Convert.ToInt32(ViewState["twc_project_number"].ToString())).ToString();
                    this.FetchAndBind(EstNum, twc_project_number);
                }

            }
            else
            {
                if (n.HasKeys())
                {
                    string k = n.GetKey(0);
                    string v = n.Get(0);

                    string k1 = n.GetKey(1);
                    string v1 = n.Get(1);

                    if (k == "EstNum")
                    {
                        EstNum = Convert.ToInt32(v);  // Here goes the code for the creation of new EstNum

                        twc_project_number = Convert.ToInt32(v1);
                        ViewState["EstNum"] = EstNum;
                        ViewState["twc_project_number"] = twc_project_number;
                        //txtReportDate.Text = _wr.GetCurrentDate().Trim();
                        txtwhitPrjNumber.Text = ViewState["twc_project_number"].ToString();
                        txtrealPrjNumber.Text = _wc.GetReal_proj_Number(Convert.ToInt32(ViewState["twc_project_number"].ToString())).ToString();
                        this.FetchAndBind(EstNum, twc_project_number);
                    }
                }
                else
                {
                    EstNum = Convert.ToInt32(ViewState["EstNum"].ToString());
                    twc_project_number = Convert.ToInt32(ViewState["twc_project_number"].ToString());
                    //txtReportDate.Text = _wr.GetCurrentDate().Trim();
                    txtwhitPrjNumber.Text = ViewState["twc_project_number"].ToString();
                    txtrealPrjNumber.Text = _wc.GetReal_proj_Number(Convert.ToInt32(ViewState["twc_project_number"].ToString())).ToString();
                    this.FetchAndBind(EstNum, twc_project_number);
                }
            }

            Response.Cookies["EstNum"].Value = EstNum.ToString();
            Response.Cookies["twc_project_number"].Value = twc_project_number.ToString();
            hdnEstNum.Value = EstNum.ToString();
            hdntwcProjNumber.Value = twc_project_number.ToString();

            //Bind the clients and competition and Conversation Log
            try
            {
                grdclients.PageSize = _DEFAULTPAGESIZE;
                DataSet dsGridResults;
                dsGridResults = this.Project_clients();
                this.PopulateDataGrid(dsGridResults, grdclients);
            }

            catch (Exception exp)
            {
                Response.Write(exp.Message.ToString());
            }

            //GetDocumentsforProject
            try
            {
                grddocs.PageSize = _DEFAULTPAGESIZE;
                DataSet dsGridResults;
                dsGridResults = this.GetDocs();
                this.PopulateDataGrid(dsGridResults, grddocs);
            }
            catch (Exception exp)
            {
                Response.Write(exp.Message.ToString());
            }

           //Logic Here for the Project Daily Field Report

           // if (_wr.IsReportExists(Convert.ToInt32(ViewState["twc_project_number"].ToString()), txtReportDate.Text))

            if (_wr.IsReportExists(twc_project_number, txtReportDate.Text))
                {
                    DataSet _dsDailyRpt = _wr.GetReportForProject(Convert.ToInt32(ViewState["twc_project_number"].ToString()), txtReportDate.Text.Trim());
                    //txtReportDate.Text = _wr.GetCurrentDate();
                    DataTable dtUsr = _dsDailyRpt.Tables[0];
                    String _chkStatus = "";
                    foreach (DataRow dRow in dtUsr.Rows)
                    {
                        txtRptNotes.Text = dRow["Daily_notes"] == DBNull.Value ? "" : dRow["Daily_notes"].ToString();
                        txtRptIssues.Text = dRow["Daily_comments"] == DBNull.Value ? "" : dRow["Daily_comments"].ToString();
                        txtRptChangeOrderNotes.Text = dRow["Change_order_notes"] == DBNull.Value ? "" : dRow["Change_order_notes"].ToString();
                        _chkStatus = dRow["is_locked"] == DBNull.Value ? "" : dRow["is_locked"].ToString();
                        if (_chkStatus.Trim() == "Y")
                        {
                            chkActive.SelectedIndex = chkActive.Items.IndexOf(chkActive.Items.FindByValue(_chkStatus));
                        }
                    }
                }
            //Logic for Project Daily Field Report Ends.
             Whitfieldcore _wc1 = new Whitfieldcore();
             lblTotAnnFabHours.Text = _wc1.GetTotalFabricationHours(twc_project_number.ToString());
             lblTotScheduledHours.Text = _wc1.GetTotalscheduledHours(twc_project_number);
            //GetTotalFabricationHours
        }
        else
        {
            //pHprojClient.Visible = true;
            //pHprojcompe.Visible = true;
        }

        tabgeneral.ActiveTabIndex = ActiveIndexNumber;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Whitfield_Project _wc = new Whitfield_Project();
        whitfield_reports _wr = new whitfield_reports();
        // 1
        // Get collection
        NameValueCollection n = Request.QueryString;
        if (!Page.IsPostBack)
        {
            // See if any query string exists
            if (n.HasKeys())
            {
                // 3
                // Get first key and value
                string k = n.GetKey(0);
                string v = n.Get(0);
                string k1 = n.GetKey(1);
                string v1 = n.Get(1);

                //Check for QueryString Date

                if (k == "ReportDate")
                {
                    txtReportDate.Text = v;
                    twc_project_number = Convert.ToInt32(v1);
                    EstNum = Convert.ToInt32(Request.QueryString["EstNum"].ToString());
                    ViewState["EstNum"] = Request.QueryString["EstNum"].ToString();
                    ViewState["twc_project_number"] = twc_project_number;
                    txtwhitPrjNumber.Text = twc_project_number.ToString();
                    //this.FetchAndBind(EstNum, twc_project_number);
                    bindcontrols(EstNum, twc_project_number);
                }
                else
                {
                    txtReportDate.Text = _wr.GetCurrentDate().Trim();
                    twc_project_number = Convert.ToInt32(v1);
                    ViewState["EstNum"] = EstNum;
                    ViewState["twc_project_number"] = twc_project_number;
                    txtwhitPrjNumber.Text = ViewState["twc_project_number"].ToString();
                    //this.FetchAndBind(EstNum, twc_project_number);
                    bindcontrols(EstNum, twc_project_number);
                }

                if (k == "EstNum")
                {
                    EstNum = Convert.ToInt32(v);  // Here goes the code for the creation of new EstNum
                    twc_project_number = Convert.ToInt32(v1);
                    ViewState["EstNum"] = EstNum;
                    ViewState["twc_project_number"] = twc_project_number;
                    //txtReportDate.Text = _wr.GetCurrentDate().Trim();
                    txtwhitPrjNumber.Text = ViewState["twc_project_number"].ToString();
                    //this.FetchAndBind(EstNum, twc_project_number);
                    bindcontrols(EstNum, twc_project_number);
                }

            }
            else
            {
                if (n.HasKeys())
                {
                    string k = n.GetKey(0);
                    string v = n.Get(0);

                    string k1 = n.GetKey(1);
                    string v1 = n.Get(1);

                    if (k == "EstNum")
                    {
                        EstNum = Convert.ToInt32(v);  // Here goes the code for the creation of new EstNum

                        twc_project_number = Convert.ToInt32(v1);
                        ViewState["EstNum"] = EstNum;
                        ViewState["twc_project_number"] = twc_project_number;
                        txtwhitPrjNumber.Text = ViewState["twc_project_number"].ToString();
                        //this.FetchAndBind(EstNum, twc_project_number);
                        bindcontrols(EstNum, twc_project_number);
                    }
                }
                else
                {
                    EstNum = Convert.ToInt32(ViewState["EstNum"].ToString());
                    twc_project_number = Convert.ToInt32(ViewState["twc_project_number"].ToString());
                    //txtReportDate.Text = _wr.GetCurrentDate().Trim();
                    txtwhitPrjNumber.Text = ViewState["twc_project_number"].ToString();
                    //this.FetchAndBind(EstNum, twc_project_number);
                    bindcontrols(EstNum, twc_project_number);
                }
            }

            Response.Cookies["EstNum"].Value = EstNum.ToString();
            Response.Cookies["twc_project_number"].Value = twc_project_number.ToString();
            hdnEstNum.Value = EstNum.ToString();
            hdntwcProjNumber.Value = twc_project_number.ToString();

            //Logic Here for the Project Daily Field Report

            if (_wr.IsReportExists(twc_project_number, txtReportDate.Text))
            {
                DataSet _dsDailyRpt = _wr.GetReportForProject(Convert.ToInt32(ViewState["twc_project_number"].ToString()), txtReportDate.Text.Trim());
                //txtReportDate.Text = _wr.GetCurrentDate();
                DataTable dtUsr = _dsDailyRpt.Tables[0];
                String _chkStatus = "";
                foreach (DataRow dRow in dtUsr.Rows)
                {
                    txtRptNotes.Text = dRow["Daily_notes"] == DBNull.Value ? "" : dRow["Daily_notes"].ToString();
                    txtRptIssues.Text = dRow["Daily_comments"] == DBNull.Value ? "" : dRow["Daily_comments"].ToString();
                    txtRptChangeOrderNotes.Text = dRow["Change_order_notes"] == DBNull.Value ? "" : dRow["Change_order_notes"].ToString();
                    _chkStatus = dRow["is_locked"] == DBNull.Value ? "" : dRow["is_locked"].ToString();
                    if (_chkStatus.Trim() == "Y")
                    {
                        chkActive.SelectedIndex = chkActive.Items.IndexOf(chkActive.Items.FindByValue(_chkStatus));
                    }
                }
            }
            //Logic for Project Daily Field Report Ends.
        }
        else
        {
            //pHprojClient.Visible = true;
            //pHprojcompe.Visible = true;
        }
    }