protected void btnAdd_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnAdd_Click";

            try {

                //----------------------------------------------------------------------
                // Use the constructor to clean up state values, especially from grid.
                //----------------------------------------------------------------------
                ListEquityDeductionItem state = new ListEquityDeductionItem(
                    "",
                    txtEDedNumber.Text,
                    txtEDedDescription.Text,
                    (chkEDedIsActive.Checked ? "Y" : "N"),
                    "");

                string tmpNum = state.DeductionNumber;
                int deductionNumber = 0;
                try {
                    deductionNumber = Convert.ToInt32(tmpNum);
                }
                catch {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a positive number for Deduction Number.");
                    throw (warn);
                }
                if (deductionNumber == 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Deduction Number to a number greater than zero.");
                    throw (warn);
                }

                if (state.DeductionDescription.Length == 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Deduction Description.");
                    throw (warn);
                }

                string userName = Common.AppHelper.GetIdentityName();

                BeetEquityDeduction.EquityDeductionSave(Convert.ToInt32(state.EquityDeductionID), Convert.ToInt32(state.DeductionNumber),
                    state.DeductionDescription, state.IsActiveAsBool(), state.RowVersion, userName);

                ResetEquityDeductionEdit();
                FillEqDeductionGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnDelete_Click";

            try {

                //------------------------------------
                // Pull info from grid selection.
                //------------------------------------
                GridViewRow row = grdEqDeduction.SelectedRow;
                if (row == null) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Before pressing Delete, please select an Equity Deduction from the Equity Deductions grid.");
                    throw (warn);
                }

                //----------------------------------------------------------------------
                // Use the constructor to clean up state values, especially from grid.
                //----------------------------------------------------------------------
                ListEquityDeductionItem state = new ListEquityDeductionItem(
                    row.Cells[(int)EqDedGridCols.colEquityDeductionID].Text,
                    txtEDedNumber.Text,
                    txtEDedDescription.Text,
                    (chkEDedIsActive.Checked ? "Y" : "N"),
                    row.Cells[(int)EqDedGridCols.colRowVersion].Text);

                int equityDeductionID = Convert.ToInt32(state.EquityDeductionID);
                if (equityDeductionID <= 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Unable to identify your Equity Deductions grid selection.  Try making your selection again.");
                    throw (warn);
                }

                string rowVersion = state.RowVersion;
                if (rowVersion.Length == 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Unable to identify your Equity Deductions grid selection.  Try making your selection again.");
                    throw (warn);
                }

                BeetEquityDeduction.EquityDeductionDelete(equityDeductionID, rowVersion);

                ResetEquityDeductionEdit();
                FillEqDeductionGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
        protected void grdEqDeduction_SelectedIndexChanged(object sender, EventArgs e)
        {
            const string METHOD_NAME = "grdEqDeduction_SelectedIndexChanged";
            try {

                ResetEquityDeductionEdit();

                //-----------------------------------
                //	Fill Equity Deduction Edit
                //-----------------------------------
                //      Note: here we don't care about the ID or rowVersion stamp
                // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

                GridViewRow row = grdEqDeduction.SelectedRow;

                ListEquityDeductionItem state = new ListEquityDeductionItem("",
                    row.Cells[(int)EqDedGridCols.colDeductionNumber].Text,
                    row.Cells[(int)EqDedGridCols.colDeductionDescription].Text,
                    row.Cells[(int)EqDedGridCols.colIsActive].Text,
                    "");

                txtEDedNumber.Text = state.DeductionNumber;
                txtEDedDescription.Text = state.DeductionDescription;
                chkEDedIsActive.Checked = state.IsActiveAsBool();

            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnUpdate_Click";

            try {

                //------------------------------------
                // Pull info from grid selection.
                //------------------------------------
                GridViewRow row = grdEqDeduction.SelectedRow;
                if (row == null) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Before pressing Update, please select an Equity Deduction from the Equity Deductions grid.");
                    throw (warn);
                }

                //----------------------------------------------------------------------
                // Use the constructor to clean up state values, especially from grid.
                //----------------------------------------------------------------------
                ListEquityDeductionItem state = new ListEquityDeductionItem(
                    row.Cells[(int)EqDedGridCols.colEquityDeductionID].Text,
                    txtEDedNumber.Text,
                    txtEDedDescription.Text,
                    (chkEDedIsActive.Checked? "Y": "N"),
                    row.Cells[(int)EqDedGridCols.colRowVersion].Text);

                int equityDeductionID = Convert.ToInt32(state.EquityDeductionID);
                if (equityDeductionID <= 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Unable to identify your Equity Deductions grid selection.  Try making your selection again.");
                    throw (warn);
                }

                string rowVersion = state.RowVersion;
                if (rowVersion.Length == 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Unable to identify your Equity Deductions grid selection.  Try making your selection again.");
                    throw (warn);
                }

                bool isActive = state.IsActiveAsBool();
                string deductionDescription = state.DeductionDescription;

                if (deductionDescription.Length == 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Deduction Description.");
                    throw (warn);
                }

                string tmpNum = state.DeductionNumber;
                int deductionNumber = 0;
                try {
                    deductionNumber = Convert.ToInt32(tmpNum);
                }
                catch {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a positive number for Deduction Number.");
                    throw (warn);
                }
                if (deductionNumber == 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Deduction Number to a number greater than zero.");
                    throw (warn);
                }
                if (deductionNumber != Convert.ToInt32(row.Cells[(int)EqDedGridCols.colDeductionNumber].Text)) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("You cannot update the Deduction Number of a Deduction.  If the deduction has never been used, you can delete the deduction.");
                    throw (warn);
                }

                string userName = Common.AppHelper.GetIdentityName();

                BeetEquityDeduction.EquityDeductionSave(equityDeductionID, deductionNumber, deductionDescription, isActive, rowVersion, userName);

                ResetEquityDeductionEdit();
                FillEqDeductionGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }