예제 #1
0
        private void LoadGrid()
        {
            int    clientId            = 0;
            int    subContractId       = 0;
            int    jobId               = 0;
            int    invoiceId           = 0;
            string clientInvoiceNumber = string.Empty;

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

            // Client
            if (cboClient.Text != "")
            {
                clientId = Convert.ToInt32(cboClient.SelectedValue);
            }

            // Sub Contractor
            if (cboSubContractor.Text != "")
            {
                subContractId = Convert.ToInt32(cboSubContractor.SelectedValue);
            }

            // Invoice Id
            if (txtInvoiceId.Text != "")
            {
                invoiceId = Convert.ToInt32(txtInvoiceId.Text);
            }

            // Client Invoice Number
            if (txtClientInvoiceNumber.Text != "")
            {
                clientInvoiceNumber = txtClientInvoiceNumber.Text;
            }

//			// Job State
//			if (cboJobState.SelectedValue != string.Empty)
//				jobState = (eJobState) Enum.Parse(typeof(eJobState), cboJobState.SelectedValue);


            // Job Id
            if (txtJobId.Text != "")
            {
                jobId = Convert.ToInt32(txtJobId.Text);
            }

            // Date Range
            if (dteStartDate.SelectedDate != DateTime.MinValue)
            {
                startDate = dteStartDate.SelectedDate.Value;
            }

            if (dteEndDate.SelectedDate != DateTime.MinValue)
            {
                endDate = dteEndDate.SelectedDate.Value;
            }

            // Get Invoiced Jobs
            Facade.IInvoice facInvoice  = new Facade.Invoice();
            DataSet         dsInvoicing = null;

            if (rdoInvoiceType.SelectedIndex != 1)
            {
                if (startDate != DateTime.MinValue || endDate != DateTime.MinValue)
                {
                    dsInvoicing = facInvoice.GetInvoicedJobsWithParamsAndDate(clientId, subContractId, invoiceId, jobId, clientInvoiceNumber, startDate, endDate, 0);
                }
                else
                {
                    dsInvoicing = facInvoice.GetInvoicedJobsWithParams(clientId, subContractId, invoiceId, jobId, clientInvoiceNumber, 0);
                }
            }
            else
            {
                if (startDate != DateTime.MinValue || endDate != DateTime.MinValue)
                {
                    dsInvoicing = facInvoice.GetInvoicedJobsWithParamsAndDate(clientId, subContractId, invoiceId, jobId, clientInvoiceNumber, startDate, endDate, 1);
                }
                else
                {
                    dsInvoicing = facInvoice.GetInvoicedJobsWithParams(clientId, subContractId, invoiceId, jobId, clientInvoiceNumber, 1);
                }
            }

            // Check whether account is on hold
            if (rdoInvoiceType.SelectedIndex != 1)
            {
                if (dsInvoicing.Tables[0].Rows.Count > 0)
                {
//					if (Convert.ToInt32(dsInvoicing.Tables[0].Rows[0]["OnHold"])  == 1)
//					{
//						dlJob.Enabled = false;
//						lblOnHold.Visible = true;
//						lblOnHold.Text = cboClient.Text + "'s account has been put on hold, please go to <A HREF=../Organisation/addupdateorganisation.aspx?IdentityId=" + Convert.ToInt32(cboClient.SelectedValue) + ">" + cboClient.Text + "'s details to change.</A>";
//					}
//					else
                    lblOnHold.Visible = false;

                    pnlNormalJob.Visible = true;
                    pnlSubJob.Visible    = false;
                    dlJob.Visible        = true;
                    dlJob.DataSource     = dsInvoicing;
                    dlJob.DataBind();

                    lblJobCount.Text = "There are " + dlJob.Items.Count.ToString() + " jobs invoiced.";
                }
                else
                {
                    lblOnHold.Visible    = true;
                    lblOnHold.Text       = "With the given parameters no jobs have been found.";
                    dlJob.Visible        = false;
                    pnlNormalJob.Visible = false;
                    pnlSubJob.Visible    = false;
                }
            }
            else
            {
                if (dsInvoicing.Tables[0].Rows.Count > 0)
                {
                    //					if (Convert.ToInt32(dsInvoicing.Tables[0].Rows[0]["OnHold"])  == 1)
                    //					{
                    //						dlJob.Enabled = false;
                    //						lblOnHold.Visible = true;
                    //						lblOnHold.Text = cboClient.Text + "'s account has been put on hold, please go to <A HREF=../Organisation/addupdateorganisation.aspx?IdentityId=" + Convert.ToInt32(cboClient.SelectedValue) + ">" + cboClient.Text + "'s details to change.</A>";
                    //					}
                    //					else
                    lblOnHold.Visible = false;

                    pnlSubJob.Visible    = true;
                    pnlNormalJob.Visible = false;
                    dlJobSub.Visible     = true;
                    dlJobSub.DataSource  = dsInvoicing;
                    dlJobSub.DataBind();

                    lblJobCount.Text = "There are " + dlJobSub.Items.Count.ToString() + " jobs invoiced.";
                }
                else
                {
                    lblOnHoldSub.Visible = true;
                    lblOnHoldSub.Text    = "With the given parameters no jobs have been found.";
                    dlJobSub.Visible     = false;
                    pnlNormalJob.Visible = false;
                    pnlSubJob.Visible    = false;
                }
            }

//				// Sort By
//				DataView dvInvoice = new DataView(dsInvoicing.Tables[0]);
//
//				foreach ( ListItem sortField in rdoSortType.Items )
//				{
//					if (sortField.Selected)
//						dvInvoice.Sort = sortField.Text;
//				}

            // Load List
//
//				pnlSort.Visible = false;
//				btnFilter.Visible = true;
//
//				btnClear.Visible = true;
        }