예제 #1
0
        private void performSubContractorSearch()
        {
            Facade.IInvoiceSubContrator facInvoice = new Facade.Invoice();

            int posted = 0;

            switch ((eWithOrWithout)Enum.Parse(typeof(eWithOrWithout), rdoPosted.SelectedValue))
            {
            case eWithOrWithout.All:
                posted = 2;
                break;

            case eWithOrWithout.With:
                posted = 1;
                break;

            case eWithOrWithout.Without:
                posted = 0;
                break;
            }

            int clientId = cboSubContractor.SelectedValue == "" ? 0 : Convert.ToInt32(cboSubContractor.SelectedValue);

            string clientInvoiceNumber = String.Empty;

            if (txtClientInvoiceNumber.Text != string.Empty)
            {
                clientInvoiceNumber = txtClientInvoiceNumber.Text;
            }

            DateTime startDate = DateTime.MinValue;
            DateTime endDate   = DateTime.MinValue;

            if (dteStartDate.SelectedDate.HasValue)
            {
                startDate = dteStartDate.SelectedDate.Value;
                startDate = startDate.Subtract(startDate.TimeOfDay);
            }

            if (dteEndDate.SelectedDate.HasValue)
            {
                endDate = dteEndDate.SelectedDate.Value;
                endDate = endDate.Subtract(endDate.TimeOfDay);
                endDate = endDate.Add(new TimeSpan(23, 59, 59));
            }

            // Job State
            eJobState jobState = new eJobState();

            if (cboJobState.SelectedValue != string.Empty)
            {
                jobState = (eJobState)Enum.Parse(typeof(eJobState), cboJobState.SelectedValue);
            }

            if (startDate != DateTime.MinValue && endDate != DateTime.MinValue)
            {
                dsInvoice = facInvoice.GetSubContractorswithParamsAndDate(clientId, clientInvoiceNumber, jobState, posted, startDate, endDate, eInvoiceType.SubContract);
            }
            else
            {
                if (clientId == 0)
                {
                    dsInvoice = facInvoice.GetSubContractors(posted, eInvoiceType.SubContract);
                }
                else
                {
                    dsInvoice = facInvoice.GetSubContractorswithParams(clientId, clientInvoiceNumber, jobState, posted, eInvoiceType.SubContract);
                }
            }

            gvSubContratorInvoice.DataSource = dsInvoice;

            ViewState[C_InvoiceDATA_VS] = dsInvoice;

            gvSubContratorInvoice.DataBind();


            if (gvSubContratorInvoice.Rows.Count == 0)
            {
                pnlSubContractorInvoice.Visible = false;
                lblNote.Text      = "There are no invoices for the given criteria.";
                lblNote.ForeColor = Color.Red;
                lblNote.Visible   = true;
            }
            else
            {
                pnlSubContractorInvoice.Visible = true;
            }

            lblClientInvoiceNumber.Visible = txtClientInvoiceNumber.Visible = true;
        }