protected void fvAg_WFP3_Encumbrance_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        int?     i     = null;
        int      iCode = 0;
        FormView fv    = fvAg_WFP3_Encumbrance;

        DropDownList ddlEncumbrance        = fv.FindControl("ddlEncumbrance") as DropDownList;
        CustomControls_AjaxCalendar ecDate = fvAg_WFP3_Encumbrance.FindControl("tbCalEncumbranceDate") as CustomControls_AjaxCalendar;
        TextBox tbAmount = fv.FindControl("tbAmount") as TextBox;
        TextBox tbNote   = fv.FindControl("tbNote") as TextBox;

        StringBuilder sb = new StringBuilder();

        using (WACDataClassesDataContext wDataContext = new WACDataClassesDataContext())
        {
            try
            {
                if (wDataContext.form_wfp3_get_okToEncumber(FK_Wfp3) != "N")
                {
                    string sEncumbrance = null;
                    if (!string.IsNullOrEmpty(ddlEncumbrance.SelectedValue))
                    {
                        sEncumbrance = ddlEncumbrance.SelectedValue;
                    }
                    else
                    {
                        sb.Append("Encumbrance is required. ");
                    }

                    DateTime?dtDate = ecDate.CalDateNotNullable;
                    if (dtDate == null)
                    {
                        sb.Append("Date is required. ");
                    }

                    decimal?dAmount = null;
                    if (!string.IsNullOrEmpty(tbAmount.Text))
                    {
                        try
                        {
                            dAmount = Convert.ToDecimal(tbAmount.Text);
                            if (dAmount < (decimal)0.01)
                            {
                                sb.Append("Encumbrance ammount must be greater than zero");
                            }
                        }
                        catch { sb.Append("Amount is incorrect. Must be a number (Decimal). "); }
                    }
                    else
                    {
                        sb.Append("Amount is required. ");
                    }

                    string sNote = null;
                    if (!string.IsNullOrEmpty(tbNote.Text))
                    {
                        sNote = WACGlobal_Methods.Format_Global_StringLengthRestriction(tbNote.Text, 255);
                    }

                    if (string.IsNullOrEmpty(sb.ToString()))
                    {
                        iCode = wDataContext.form_wfp3_encumbrance_add(FK_Wfp3, sEncumbrance, dtDate, dAmount, sNote, Session["userName"].ToString(), ref i);
                        if (iCode != 0)
                        {
                            WACAlert.Show("Error Returned from Database.", iCode);
                        }
                        else
                        {
                            PK_Wfp3Encumbrance = Convert.ToInt32(i);
                        }
                    }
                    else
                    {
                        WACAlert.Show(sb.ToString(), iCode);
                    }
                }
                else
                {
                    WACAlert.Show("It is not okay to encumber this package. ", 0);
                }
            }
            catch (Exception ex) { WACAlert.Show(ex.Message, 0); }
        }
    }