protected void gvPlan_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int rowIndex = e.RowIndex;

            int      ConserveApprovalID = DataUtils.GetInt(((Label)gvPlan.Rows[rowIndex].FindControl("lblConservePlanID")).Text);
            DateTime DispDate           = Convert.ToDateTime(((TextBox)gvPlan.Rows[rowIndex].FindControl("txtPlanDate")).Text);
            bool     RowIsActive        = Convert.ToBoolean(((CheckBox)gvPlan.Rows[rowIndex].FindControl("chkActive")).Checked);;

            ConservationStewardshipData.UpdateConservePlans(ConserveApprovalID, DispDate, RowIsActive);
            gvPlan.EditIndex = -1;

            BindPlansGrid();

            LogMessage("Plan updated successfully");
        }
        protected void gvApproval_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int rowIndex = e.RowIndex;

            int      ConserveApprovalID = DataUtils.GetInt(((Label)gvApproval.Rows[rowIndex].FindControl("lblConserveApprovalID")).Text);
            DateTime ReqDate            = Convert.ToDateTime(((TextBox)gvApproval.Rows[rowIndex].FindControl("txtApprovalsReqDate")).Text);
            int      LkDisp             = DataUtils.GetInt(((DropDownList)gvApproval.Rows[rowIndex].FindControl("ddlApprovalsDispositionE")).SelectedValue.ToString());
            DateTime DispDate           = Convert.ToDateTime(((TextBox)gvApproval.Rows[rowIndex].FindControl("txtApprovalsDispDate")).Text);
            bool     RowIsActive        = Convert.ToBoolean(((CheckBox)gvApproval.Rows[rowIndex].FindControl("chkActive")).Checked);;

            ConservationStewardshipData.UpdateConserveApprovals(ConserveApprovalID, ReqDate, LkDisp, DispDate, RowIsActive);
            gvApproval.EditIndex = -1;

            BindApprovalsGrid();

            LogMessage("Approval updated successfully");
        }
        protected void btnAddPlan_Click(object sender, EventArgs e)
        {
            if (ddlPlan.SelectedIndex == 0)
            {
                LogMessage("Select Plan");
                ddlPlan.Focus();
                return;
            }

            if (txtPlanDate.Text.Trim() == "")
            {
                LogMessage("Enter Date");
                txtPlanDate.Focus();
                return;
            }
            else
            {
                if (!DataUtils.IsDateTime(txtPlanDate.Text.Trim()))
                {
                    LogMessage("Enter Valid Date");
                    txtPlanDate.Focus();
                    return;
                }
            }

            ConservationStewardshipData.AddConsAmend objAddConsAmend = ConservationStewardshipData.AddConservePlans(DataUtils.GetInt(hfProjectId.Value),
                                                                                                                    DataUtils.GetInt(ddlPlan.SelectedValue.ToString()), DataUtils.GetDate(txtPlanDate.Text));

            ClearPlansForm();

            BindPlansGrid();

            if (objAddConsAmend.IsDuplicate && !objAddConsAmend.IsActive)
            {
                LogMessage("New Plan already exist as in-active");
            }
            else if (objAddConsAmend.IsDuplicate)
            {
                LogMessage("New Plan already exist");
            }
            else
            {
                LogMessage("New Plan added successfully");
            }
        }
        private void BindPlansGrid()
        {
            try
            {
                DataTable dtPlan = ConservationStewardshipData.GetConservePlansList(DataUtils.GetInt(hfProjectId.Value), cbActiveOnly.Checked);

                if (dtPlan.Rows.Count > 0)
                {
                    dvPlanGrid.Visible = true;
                    gvPlan.DataSource  = dtPlan;
                    gvPlan.DataBind();
                }
                else
                {
                    dvPlanGrid.Visible = false;
                    gvPlan.DataSource  = null;
                    gvPlan.DataBind();
                }
            }
            catch (Exception ex)
            {
                LogError(Pagename, "BindPlansGrid", "", ex.Message);
            }
        }
        private void BindMinorGrid()
        {
            try
            {
                DataTable dtMinor = ConservationStewardshipData.GetMinorAmendmentsList(DataUtils.GetInt(hfProjectId.Value), cbActiveOnly.Checked);

                if (dtMinor.Rows.Count > 0)
                {
                    dvMinorGrid.Visible = true;
                    gvMinor.DataSource  = dtMinor;
                    gvMinor.DataBind();
                }
                else
                {
                    dvMinorGrid.Visible = false;
                    gvMinor.DataSource  = null;
                    gvMinor.DataBind();
                }
            }
            catch (Exception ex)
            {
                LogError(Pagename, "BindMajorGrid", "", ex.Message);
            }
        }
        protected void btnAddApproval_Click(object sender, EventArgs e)
        {
            if (ddlApproval.SelectedIndex == 0)
            {
                LogMessage("Select Approval");
                ddlApproval.Focus();
                return;
            }

            if (txtApprovalReqdate.Text.Trim() == "")
            {
                LogMessage("Enter Request Date");
                txtApprovalReqdate.Focus();
                return;
            }
            else
            {
                if (!DataUtils.IsDateTime(txtApprovalReqdate.Text.Trim()))
                {
                    LogMessage("Enter Valid Request Date");
                    txtApprovalReqdate.Focus();
                    return;
                }
            }

            if (ddlApprovalDisposition.SelectedIndex == 0)
            {
                LogMessage("Select Disposition");
                ddlApprovalDisposition.Focus();
                return;
            }

            if (txtApprovalDispositionDate.Text.Trim() == "")
            {
                LogMessage("Enter Disposition Date");
                txtApprovalDispositionDate.Focus();
                return;
            }
            else
            {
                if (!DataUtils.IsDateTime(txtApprovalDispositionDate.Text.Trim()))
                {
                    LogMessage("Enter Disposition Date");
                    txtApprovalDispositionDate.Focus();
                    return;
                }
            }

            ConservationStewardshipData.AddConsAmend objAddConsAmend = ConservationStewardshipData.AddConserveApprovals(DataUtils.GetInt(hfProjectId.Value),
                                                                                                                        DataUtils.GetInt(ddlApproval.SelectedValue.ToString()), DataUtils.GetDate(txtApprovalReqdate.Text),
                                                                                                                        DataUtils.GetInt(ddlApprovalDisposition.SelectedValue.ToString()), DataUtils.GetDate(txtApprovalDispositionDate.Text));

            ClearApprovalForm();

            BindApprovalsGrid();

            if (objAddConsAmend.IsDuplicate && !objAddConsAmend.IsActive)
            {
                LogMessage("New Approval already exist as in-active");
            }
            else if (objAddConsAmend.IsDuplicate)
            {
                LogMessage("New Approval already exist");
            }
            else
            {
                LogMessage("New Approval added successfully");
            }
        }