/// <summary>
        /// Function to bind the data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DataBind()
        {
            ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject();
            string          name   = string.Empty;

            if (!((ddlCategory.SelectedIndex != 0) && (txtItemName.Text != "")))
            {
                if (!(ddlCategory.SelectedIndex == 0))
                {
                    gvShowItemList.DataSource = objBLL.GetItemList(Convert.ToInt32(ddlCategory.SelectedItem.Value));
                    gvShowItemList.DataBind();
                }
                else if (!(txtItemName.Text == ""))
                {
                    name = txtItemName.Text;
                    gvShowItemList.DataSource = objBLL.SearchItembyName(name);
                    gvShowItemList.DataBind();
                }

                else
                {
                    gvShowItemList.Visible = false;
                }
            }
            else
            {
                name = txtItemName.Text;
                int categoryId = Convert.ToInt32(ddlCategory.SelectedItem.Value);
                gvShowItemList.DataSource = objBLL.GetItemList(categoryId, name);
                gvShowItemList.DataBind();
            }
        }
        /// <summary>
        /// On click of Search Button Item name with Matching results will be displayed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            ISalesPersonBLL objBLL = TCS.ISMS.BLLFactory.SalesPersonBLLFactory.CreateSalesPersonBLLObject();

            string name = txtName.Text;

            gvItemSearch.DataSource = objBLL.SearchItembyName(name);
            gvItemSearch.DataBind();
        }
        /// <summary>
        /// Function to search items from inventory according to values inserted or category selected or both
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnSearch_Click(object sender, EventArgs e)
        {
            lblMessage1.Text         = "";
            btnAddItemToBill.Visible = false;
            ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject();


            string name = string.Empty;

            if (!((ddlCategory.SelectedIndex != 0) && (txtItemName.Text != "")))
            {
                if (!(ddlCategory.SelectedIndex == 0))
                {
                    List <IItem> lstItems = objBLL.GetItemList(Convert.ToInt32(ddlCategory.SelectedItem.Value));
                    foreach (IItem item in lstItems)
                    {
                        if (item.ItemQuantity == 0)
                        {
                            lstItems.Remove(item);
                        }
                    }

                    if (lstItems.Count == 0)
                    {
                        lblMessage1.Text         = "No Items In this Category";
                        btnAddItemToBill.Visible = false;
                    }
                    gvshowItemList.DataSource = lstItems;
                    gvshowItemList.DataBind();
                    btnAddItemToBill.Visible = true;
                }
                else if (!(txtItemName.Text == ""))
                {
                    name = txtItemName.Text;
                    gvshowItemList.DataSource = objBLL.SearchItembyName(name);
                    gvshowItemList.DataBind();
                    btnAddItemToBill.Visible = true;
                }
                else
                {
                    lblErrorMsg.Text = "Please Select Category/Enter Name ";
                }
            }
            else
            {
                btnAddItemToBill.Visible = true;
                name = txtItemName.Text;
                int categoryId = Convert.ToInt32(ddlCategory.SelectedItem.Value);
                gvshowItemList.DataSource = objBLL.GetItemList(categoryId, name);
                gvshowItemList.DataBind();
            }
        }
        /// <summary>
        /// This method displays the item details based on category in the database
        /// </summary>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            gvShowItemList.Visible = true;

            ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject();
            string          name   = string.Empty;

            if (!((ddlCategory.SelectedIndex != 0) && (txtItemName.Text != "")))
            {
                lblMessage.Text = "Please enter item name or select item category";

                if (!(ddlCategory.SelectedIndex == 0))
                {
                    lblMessage.Text           = "";
                    gvShowItemList.DataSource = objBLL.GetItemList(Convert.ToInt32(ddlCategory.SelectedItem.Value));
                    gvShowItemList.DataBind();
                }
                else if (!(txtItemName.Text == ""))
                {
                    lblMessage.Text           = "";
                    name                      = txtItemName.Text;
                    gvShowItemList.DataSource = objBLL.SearchItembyName(name);
                    gvShowItemList.DataBind();
                }

                else if ((ddlCategory.SelectedIndex != 0) && (gvShowItemList.Rows.Count == 0))
                {
                    lblMessage.Text = "No items found in this category";
                }

                else
                {
                    gvShowItemList.Visible = false;
                }
            }

            else
            {
                name = txtItemName.Text;
                int categoryId = Convert.ToInt32(ddlCategory.SelectedItem.Value);
                gvShowItemList.DataSource = objBLL.GetItemList(categoryId, name);
                gvShowItemList.DataBind();
            }
        }