protected void Page_Load(object sender, EventArgs e)
        {
            SetName = "Invoice";

            if (!IsPostBack)
            {
                // set the correct filters
                Common.AddInvoiceStatusList(DropDownListBookingType.Items, false);
                CalendarControlStartDate.SelectedDate = new DateTime(Common.CurrentClientDateTime(Session).Year, 1, 1);
                CalendarControlEndDate.SelectedDate   = Common.CurrentClientDateTime(Session).Date;

                ButtonSearch_Click(sender, e);

                if (Request.Params["InvoiceNumber"] != null)
                {
                    TextBoxInvoiceNo.Text = Request.Params["InvoiceNumber"];
                    EntityDataSourcePurchaseInvoices.CommandParameters["InvoiceNumber"].DefaultValue = TextBoxInvoiceNo.Text;
                    EntityDataSourcePurchaseInvoices.DataBind();

                    if (GridViewSelectedInvoices.Rows.Count == 1)
                    {
                        GridViewSelectedInvoices.SelectedIndex = 0;
                        GridViewSelectedInvoices_SelectedIndexChanged(null, null);
                    }
                }
            }
        }
        protected void ButtonSearch_Click(object sender, EventArgs e)
        {
            EntityDataSourcePurchaseInvoices.DefaultContainerName = EntityDataSourcePurchaseInvoices.DefaultContainerName;

            EntityDataSourcePurchaseInvoices.CommandParameters["Description"].DefaultValue = TextBoxFilterName.Text == "" ? "%" : "%" + TextBoxFilterName.Text + "%";
            EntityDataSourcePurchaseInvoices.CommandParameters["StartDate"].DefaultValue   = CalendarControlStartDate.SelectedDate.ToString();
            EntityDataSourcePurchaseInvoices.CommandParameters["EndDate"].DefaultValue     = CalendarControlEndDate.SelectedDate.AddDays(1).ToString();

            EntityDataSourcePurchaseInvoices.CommandParameters["InvoiceNumber"].DefaultValue       = TextBoxInvoiceNo.Text == "" ? "%" : "%" + TextBoxInvoiceNo.Text + "%";
            EntityDataSourcePurchaseInvoices.CommandParameters["InvoiceStatus"].DefaultValue       = DropDownListBookingType.SelectedValue == "" ? "%" : DropDownListBookingType.SelectedValue;
            EntityDataSourcePurchaseInvoices.CommandParameters["MaterialDescription"].DefaultValue = DropDownListMaterial.SelectedValue == "" ? "%" : DropDownListMaterial.SelectedValue;
            EntityDataSourcePurchaseInvoices.CommandParameters["CorrectedStatus"].DefaultValue     = DropDownListCorrected.SelectedValue == "" ? "%" : DropDownListCorrected.SelectedValue;
            EntityDataSourcePurchaseInvoices.CommandParameters["RelationDescription"].DefaultValue = TextBoxCustomer.Text == "" ? "%" : "%" + TextBoxCustomer.Text + "%";
            EntityDataSourcePurchaseInvoices.CommandParameters["LocationDescription"].DefaultValue = TextBoxLocation.Text == "" ? "%" : "%" + TextBoxLocation.Text + "%";

            EntityDataSourcePurchaseInvoices.DataBind();

            WebUserControlInvoiceBase1.Visible = false;
        }