private void FillControls(SqlInt32 IncomeID, SqlInt32 UserID)
    {
        IncomeBAL balIncome = new IncomeBAL();
        IncomeENT entIncome = new IncomeENT();

        entIncome = balIncome.SelectByPK(IncomeID, UserID);

        if (!entIncome.IncomeName.IsNull)
        {
            txtIncomeName.Text = entIncome.IncomeName.Value;
        }

        if (!entIncome.CatagoryID.IsNull)
        {
            ddlCatagoryList.SelectedValue = entIncome.CatagoryID.Value.ToString();
        }

        if (!entIncome.Date.IsNull)
        {
            txtdate.Text = entIncome.Date.Value.ToString();
        }

        if (!entIncome.Descripation.IsNull)
        {
            txtDescripation.Text = entIncome.Descripation.Value.ToString();
        }

        if (!entIncome.IncomeAmount.IsNull)
        {
            txtIncomeAmount.Text = entIncome.IncomeAmount.Value.ToString().Trim();
        }
    }
    protected void lbtnDeleteIncome_Click(object sender, EventArgs e)
    {
        IncomeBAL balIncome = new IncomeBAL();

        foreach (GridViewRow gvRow in gvIncome.Rows)
        {
            CheckBox chkDeleteIncome = (CheckBox)gvRow.FindControl("chkIncome");
            if (chkDeleteIncome.Checked)
            {
                int IncomeID = Convert.ToInt32(gvIncome.DataKeys[gvRow.RowIndex].Value.ToString());
                balIncome.Delete(IncomeID, Convert.ToInt32(Session["UserID"].ToString()));
            }
        }
        fillGridViewIncome(Convert.ToInt32(Session["UserID"].ToString()));
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region Server Side Validation
        string strError = "";

        if (txtIncomeName.Text.Trim() == "")
        {
            strError += "Enter Income Name";
        }

        if (ddlCatagoryList.SelectedIndex == 0)
        {
            strError += "Enter Catagory";
        }

        if (txtdate.Text.Trim() == "")
        {
            strError += "Enter Date";
        }

        if (txtIncomeAmount.Text.Trim() == "")
        {
            strError += "Enter Income Amount";
        }

        if (strError.Trim() != "")
        {
            lblErrorMessage.Text = strError;
            return;
        }
        #endregion Server Side Validation

        #region Collect Data
        IncomeENT entIncome = new IncomeENT();

        if (txtIncomeName.Text.Trim() != "")
        {
            entIncome.IncomeName = txtIncomeName.Text;
        }

        if (ddlCatagoryList.SelectedIndex > 0)
        {
            entIncome.CatagoryID = Convert.ToInt32(ddlCatagoryList.SelectedValue.ToString().Trim());
        }

        if (txtdate.Text.Trim() != "")
        {
            entIncome.Date = Convert.ToDateTime(txtdate.Text.ToString());
        }

        if (txtIncomeAmount.Text.Trim() != "")
        {
            entIncome.IncomeAmount = Convert.ToDecimal(txtIncomeAmount.Text.ToString().Trim());
        }

        if (Session["UserID"] != null)
        {
            entIncome.UserID = Convert.ToInt32(Session["UserID"].ToString());
        }

        entIncome.Descripation = txtDescripation.Text;

        #endregion Collect Data

        IncomeBAL balIncome = new IncomeBAL();
        if (hfIncomeID.Value == "")
        {
            if (balIncome.Insert(entIncome))
            {
                lblErrorMessage.Text = "Data Insert Successfully...";
                divMessage.Visible   = true;
                ClearControls();
            }
            else
            {
                lblErrorMessage.Text = balIncome.Message;
            }
            //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "#add-contact", "$('body').removeClass('modal-open');$('.modal-backdrop').remove();", true);
        }
        else
        {
            entIncome.IncomeID = Convert.ToInt32(hfIncomeID.Value.ToString().Trim());

            if (balIncome.Update(entIncome))
            {
                //Response.Redirect("~/AdminPanel/Income/Income.aspx");
                lblErrorMessage.Text = "Data Updated Successfully...";
                divMessage.Visible   = true;
                ClearControls();
            }
            else
            {
                lblErrorMessage.Text = balIncome.Message;
            }
        }
        fillGridViewIncome(Convert.ToInt32(Session["UserID"].ToString()));
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "#add-contact", "$('body').removeClass('modal-open');$('.modal-backdrop').remove();", true);
    }