Пример #1
0
        private void LoadOrganisation()
        {
            // Retrieve the organisation and place it in viewstate
            Facade.IOrganisation facOrganisation = new Facade.Organisation();
            m_organisation               = facOrganisation.GetForIdentityId(m_identityId);
            m_organisationName           = m_organisation.OrganisationName;
            ViewState[C_ORGANISATION_VS] = m_organisation;

            txtOrganisationName.Text = m_organisation.OrganisationName;

            ddStatuses.SelectedValue          = ((int)m_organisation.IdentityStatus).ToString();
            m_originalStatus                  = m_organisation.IdentityStatus;
            ViewState[C_ORIGINALSTATUS_ID_VS] = m_originalStatus;

            // Set the update buttons and labels
            btnAddLocation.Enabled = true;
            btnAdd.Text            = "Update";

            PopulateLocations();

            Repositories.DTOs.GeofenceNotificationSettings settings = facOrganisation.GetSettings(m_identityId);
            if (settings != null)
            {
                cbNotifyWhen_ItemsRequested(cbNotifyWhen, null);

                chkBoxEnableNotification.Checked = settings.Enabled;
                cbNotificationType.SelectedValue = settings.NotificationType.ToString();
                cbNotifyWhen.SelectedValue       = settings.NotifyWhen.ToString();
                txtContactDetail.Text            = settings.Recipient;
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int organisationID = Convert.ToInt32(Request.QueryString["OrganisationID"].ToString());

                // Set the page title.
                this.Master.WizardTitle = string.Format("Approve Organisation");

                lblUnnaprovedOrganisation.Text      = string.Format("Please approve the Organisation");
                lblUnnaprovedOrganisation.Font.Bold = true;

                Facade.Organisation facOrganisation = new Orchestrator.Facade.Organisation();
                this.Organisation = facOrganisation.GetForIdentityId(organisationID);
                string organisationName = string.IsNullOrWhiteSpace(this.Organisation.OrganisationName) ? "Unnamed" : this.Organisation.OrganisationName;

                lblNameAndStatus.Text = "<b>Name:</b> " + organisationName;
                lblNameAndStatus.Text = lblNameAndStatus.Text + "<br /><br /><b>Status:</b> " + this.Organisation.IdentityStatus.ToString();

                string jsInjection = @"
                try { resizeTo(630, 730); }
                catch (err) { }
                window.focus();
                moveTo(30, 20);";

                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "ApproveOnly", jsInjection, true);
            }
        }
Пример #3
0
        private void PopulateStaticControls()
        {
            // Bind the control areas
            using (Facade.IControlArea facControlArea = new Facade.Traffic())
                cboControlArea.DataSource = facControlArea.GetAll();
            cboControlArea.DataBind();
            cboControlArea.Items.Insert(0, new ListItem("All", "0"));

            // Pre-populate fields if qs elements present
            if (Request.QueryString["prepop"] == "true")
            {
                m_popupJobId = Request.QueryString["jid"];

                cboControlArea.SelectedIndex = Convert.ToInt32(Request.QueryString["ca"]);
                if (Request.QueryString["oi"] != string.Empty)
                {
                    using (Facade.IOrganisation facOrganisation = new Facade.Organisation())
                    {
                        Entities.Organisation client = facOrganisation.GetForIdentityId(Convert.ToInt32(Request.QueryString["oi"]));
                        cboClient.Text          = client.OrganisationName;
                        cboClient.SelectedValue = client.IdentityId.ToString();
                    }
                }
            }
        }
Пример #4
0
        private void PopulateOrganisation()
        {
            if (m_isUpdate)
            {
                // Recover from viewstate
                m_organisation = (Entities.Organisation)ViewState[C_ORGANISATION_VS];
            }
            else
            {
                // Create a new organisation
                m_organisation = new Entities.Organisation();
            }

            //--------------------------------------------------------------------------
            // 1. Populate the Organisation
            //--------------------------------------------------------------------------
            m_organisation.OrganisationName        = txtOrganisationName.Text;
            m_organisation.OrganisationDisplayName = m_organisation.OrganisationName;
            m_organisation.OrganisationType        = m_organisationType;

            m_organisation.IdentityStatus = (eIdentityStatus)Int32.Parse(ddStatuses.SelectedValue);

            //if (chkSuspended.Checked)
            //	m_organisation.IdentityStatus = eIdentityStatus.Deleted;
            //else
            //	m_organisation.IdentityStatus = eIdentityStatus.Active;
        }
Пример #5
0
        private void PopulateType(bool useClientDefaults)
        {
            eJobType       jobType       = eJobType.Normal;
            eJobChargeType jobChargeType = eJobChargeType.Job;
            decimal        chargeAmount  = 0;

            if (useClientDefaults)
            {
                Facade.IOrganisation  facOrganisation = new Facade.Organisation();
                Entities.Organisation client          = facOrganisation.GetForIdentityId(m_job.IdentityId);

                if (client.Defaults != null && client.Defaults.Count > 0)
                {
                    jobType = (eJobType)client.Defaults[0].JobTypeId;
                }
            }
            else
            {
                // Get the values from the Job object
                jobType       = m_job.JobType;
                jobChargeType = m_job.Charge.JobChargeType;
                chargeAmount  = m_job.Charge.JobChargeAmount;
            }

            cboChargeType.ClearSelection();
            cboChargeType.Items.FindByValue(Utilities.UnCamelCase(Enum.GetName(typeof(eJobChargeType), jobChargeType))).Selected = true;

            ConfigureChargeAmount(jobChargeType);

            txtChargeAmount.Text = chargeAmount.ToString("F2");

            chkIsStockMovement.Checked = m_job.IsStockMovement;
        }
Пример #6
0
        private void PrepareOrders()
        {
            if (!IsPostBack)
            {
                OrdersCSV = PreviousPage.Orders;
            }

            Facade.IOrder facOrder = new Facade.Order();
            DataSet       dsOrders = facOrder.GetOrdersForList(OrdersCSV, true, false);

            Facade.IOrganisation  facOrg   = new Facade.Organisation();
            Entities.Organisation org      = facOrg.GetForIdentityId(Globals.Configuration.IdentityId);
            Facade.IPoint         facPoint = new Facade.Point();
            Entities.Point        deliveryRunCollectionPoint = null;
            if (org.Defaults[0].GroupageDeliveryRunCollectionPoint > 0)
            {
                deliveryRunCollectionPoint = facPoint.GetPointForPointId(org.Defaults[0].GroupageDeliveryRunCollectionPoint);
            }

            dsOrders.Tables[0].Columns.Add("CollectFromPointID", typeof(int));
            dsOrders.Tables[0].Columns.Add("CollectFromPoint", typeof(string));
            dsOrders.Tables[0].Columns.Add("CollectAtDateTime", typeof(DateTime));
            dsOrders.Tables[0].Columns.Add("CollectAtAnyTime", typeof(bool));
            dsOrders.Tables[0].Columns.Add("LoadOrder", typeof(string));
            dsOrders.Tables[0].Columns.Add("DeliveryOrder", typeof(int));

            int loadOrder = 1;

            foreach (DataRow row in dsOrders.Tables[0].Rows)
            {
                row["CollectFromPointID"] = (int)row["DeliveryRunCollectionPointID"];
                row["CollectFromPoint"]   = row["DeliveryRunCollectionPointDescription"].ToString();
                row["CollectAtDateTime"]  = (DateTime)row["DeliveryRunCollectionDateTime"];
                row["CollectAtAnyTime"]   = (bool)row["DeliveryRunCollectionIsAnyTime"];
                if (loadOrder == dsOrders.Tables[0].Rows.Count)
                {
                    row["LoadOrder"] = "L";
                }
                else
                {
                    row["LoadOrder"] = loadOrder.ToString();
                }
                loadOrder++;

                // Set the default collection point to that specified by the organisation settings
                if (row["LastPlannedOrderActionID"] == DBNull.Value)
                {
                    if (deliveryRunCollectionPoint != null)
                    {
                        row["CollectFromPointID"] = deliveryRunCollectionPoint.PointId;
                        row["CollectFromPoint"]   = deliveryRunCollectionPoint.Description;
                    }
                }
            }

            dsOrders.AcceptChanges();
            OrderData = dsOrders;
            grdOrders.Rebind();
        }
        private void PopulateJobInformation()
        {
            // Populate the Job fieldset.
            lblJobId.Text = m_jobId.ToString();
            ucJobStateIndicator.JobState = m_job.JobState;
            lblJobType.Text = Utilities.UnCamelCase(m_job.JobType.ToString());
            if (m_job.CurrentTrafficArea == null)
            {
                lblCurrentTrafficArea.Text = "Unknown";
            }
            else
            {
                lblCurrentTrafficArea.Text = m_job.CurrentTrafficArea.TrafficAreaName;
            }

            // Populate the Job Details fieldset.
            Facade.IOrganisation  facOrganisation = new Facade.Organisation();
            Entities.Organisation client          = facOrganisation.GetForIdentityId(m_job.IdentityId);
            lblLoadNumber.Text     = m_job.LoadNumber;
            lblLoadNumberText.Text = client.LoadNumberText;
            if (m_job.JobType == eJobType.Return)
            {
                lblReturnReferenceNumber.Text = m_job.ReturnReceiptNumber;
            }
            else
            {
                lblReturnReferenceNumber.Text = "N/A";
            }
            int numberOfPallets = 0;

            foreach (Entities.Instruction instruction in m_job.Instructions)
            {
                if (instruction.InstructionTypeId == (int)eInstructionType.Load)
                {
                    numberOfPallets = numberOfPallets + instruction.TotalPallets;
                }
            }

            lblNumberOfPallets.Text = numberOfPallets.ToString();
            if (m_job.ForCancellation)
            {
                lblMarkedForCancellation.Text = "Yes - " + m_job.ForCancellationReason;
            }
            else
            {
                lblMarkedForCancellation.Text = "No";
            }

            if (m_job.PCVs.Count > 0)
            {
                lblTakingPCVs.Text = "YES - INFORM DRIVER";
            }
            else
            {
                lblTakingPCVs.Text = "No";
            }
        }
Пример #8
0
 void cfvOwner_ServerValidate(object source, ServerValidateEventArgs args)
 {
     args.IsValid = true;
     if (cboOwner.SelectedValue == string.Empty)
     {
         // A new organisation is being created.
         Facade.IOrganisation  facOrganisation      = new Facade.Organisation();
         Entities.Organisation existingOrganisation = facOrganisation.GetForName(cboOwner.Text);
         args.IsValid = existingOrganisation == null;
     }
 }
Пример #9
0
        private void ConfigureDisplay()
        {
            if (!string.IsNullOrEmpty(Request.QueryString[c_customerID_QS]))
            {
                int id = int.Parse(Request.QueryString[c_customerID_QS]);
                Facade.IOrganisation facOrganisation = new Facade.Organisation();

                organisation = facOrganisation.GetForIdentityId(id);

                RadComboBoxItem listItem = new RadComboBoxItem(organisation.OrganisationDisplayName, organisation.IdentityId.ToString());
                cboClient.Items.Add(listItem);
                cboClient.SelectedValue = organisation.IdentityId.ToString();

                hidSelectedClientsValues.Value = organisation.IdentityId.ToString() + ",";
                hidSelectedClientsText.Value   = organisation.OrganisationDisplayName + ",";
            }

            DateTime startDate = DateTime.Today.AddMonths(-1);

            System.Globalization.GregorianCalendar cal = new System.Globalization.GregorianCalendar();


            if (!string.IsNullOrEmpty(Request.QueryString[c_startDate_QS]))
            {
                this.rdiStartDate.SelectedDate = DateTime.Parse(Request.QueryString[c_startDate_QS], null, System.Globalization.DateTimeStyles.RoundtripKind);
            }
            else
            {
                this.rdiStartDate.SelectedDate = new DateTime(startDate.Year, startDate.Month, 01);
            }

            if (!string.IsNullOrEmpty(Request.QueryString[c_endDate_QS]))
            {
                this.rdiEndDate.SelectedDate = DateTime.Parse(Request.QueryString[c_endDate_QS], null, System.Globalization.DateTimeStyles.RoundtripKind);
            }
            else
            {
                this.rdiEndDate.SelectedDate = new DateTime(startDate.Year, startDate.Month, cal.GetDaysInMonth(startDate.Year, startDate.Month));
            }


            lblMode.Text = IsClient ? "Client" : "Sub-Contractor";

            if (!string.IsNullOrEmpty(cboClient.SelectedValue) &&
                !string.IsNullOrEmpty(Request.QueryString[c_startDate_QS]) &&
                !string.IsNullOrEmpty(Request.QueryString[c_endDate_QS]))
            {
                Refresh();
            }

            this.rfvCboClient.Enabled = !IsClient;

            seSelectedClients.Visible = lblSelectedClients.Visible = btnRemoveSelectedClients.Visible = btnAddCboClient.Visible = IsClient;
        }
        void cboClient_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            // Get the Account Codes(s) for the Customer
            Facade.IOrganisation  facOrg = new Facade.Organisation();
            Entities.Organisation org    = facOrg.GetForIdentityId(int.Parse(cboClient.SelectedValue));

            lblAccountCode.Text = org.AccountCode;

            CultureInfo culture = new CultureInfo(org.LCID);

            this.txtNETAmount.Culture = culture;
        }
Пример #11
0
        public OrganisationSummaryViewModel(Entities.Organisation organisation) : base(SessionHelper.Session)
        {
            OrganisationID = organisation.ID;
            var entity = organisation.Entity;

            Avatar = new ImageViewModel(entity.ImgUrl);
            Name   = entity.Name;


            AdminMoney   = new MoneyViewModel(entity.Wallet.GetMoney(CurrencyTypeEnum.Gold, Persistent.Currencies.GetAll()));
            CountryMoney = new MoneyViewModel(entity.Wallet.GetMoney(organisation.Country.CurrencyID, Persistent.Currencies.GetAll()));
        }
Пример #12
0
        private void LoadClientAuditTrail()
        {
            pnlClient.Visible = true;

            Facade.IOrganisation  facOrganisation = new Facade.Organisation();
            Entities.Organisation currentOrg      = facOrganisation.GetForIdentityId(currentID);

            lblPalletBalanceType.Text = "Client Pallet Audit Trail : " + currentOrg.OrganisationName;

            Facade.IPalletBalance facPalletBalance = new Facade.Pallet();
            lvClientAudit.DataSource = facPalletBalance.GetClientAuditTrail(currentID, int.Parse(rcbPalletType.SelectedValue), rdiStartDate.SelectedDate.Value, rdiEndDate.SelectedDate.Value);
            lvClientAudit.DataBind();
        }
Пример #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int identityId = Convert.ToInt32(Request.QueryString["IdentityId"]);

            // Telephone Number
            // Fax Number
            // Primary Contact Email
            // Head Office Address

            Entities.Organisation organisation = null;

            if (identityId > 0)
            {
                string cacheName = "_organisation" + identityId.ToString();

                if (Cache[cacheName] == null)
                {
                    Facade.IOrganisation facOrganisation = new Facade.Organisation();
                    organisation = facOrganisation.GetForIdentityId(identityId);
                    Cache.Add(cacheName, organisation, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null);
                }
                else
                {
                    organisation = (Entities.Organisation)Cache[cacheName];
                }
            }

            if (organisation != null)
            {
                // An organisation has been selected for viewing so display it.
                XslCompiledTransform transformer = new XslCompiledTransform();
                transformer.Load(Server.MapPath(@"..\xsl\organisationContactDetails.xsl"));

                XmlUrlResolver resolver  = new XmlUrlResolver();
                XPathNavigator navigator = organisation.ToXml().CreateNavigator();

                // Populate the Organisation Contact Details.
                StringWriter sw = new StringWriter();
                transformer.Transform(navigator, null, sw);
                Response.Write(sw.GetStringBuilder().ToString());

                if (Response.IsClientConnected)
                {
                    Response.Flush();
                    Response.End();
                }
                return;
            }
        }
Пример #14
0
        public Entities.Organisation AddOrganisation(Models.Organisation organisation)
        {
            var dbNewOrganization = new Entities.Organisation()
            {
                Name        = organisation.Name,
                Avatar      = organisation.Avatar,
                Email       = organisation.Email,
                SocialIssue = organisation.SocialIssue,
                Description = organisation.Description,
                Website     = organisation.Website,
                Location    = organisation.Location
            };

            _copDbContext.Add(dbNewOrganization);
            _copDbContext.SaveChanges();

            return(dbNewOrganization);
        }
Пример #15
0
        private void BindRepeater()
        {
            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            Facade.IOrganisation facOrganisation = new Facade.Organisation();
            DataSet dsBusinessType;

            int identityID;

            int.TryParse(cboClient.SelectedValue, out identityID);

            organisation = facOrganisation.GetForIdentityId(identityID);

            dsBusinessType = facBusinessType.GetAll();

            repBusinessType.DataSource = dsBusinessType;
            repBusinessType.DataBind();
            grdNormal.Rebind();
            grdSummary.Rebind();
        }
Пример #16
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!this.IsPostBack)
            {
                Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.GeneralUsage, eSystemPortion.SearchForPODs);

                //Get the user's Identity row
                Facade.IUser  facUser = new Facade.User();
                SqlDataReader reader  = facUser.GetRelatedIdentity(((Entities.CustomPrincipal)Page.User).UserName);
                reader.Read();
                //Is the User a Client User
                if ((eRelationshipType)reader["RelationshipTypeId"] == eRelationshipType.IsClient)
                {
                    //Set the Client combo yo the Client of the User and diable it
                    int clientID = (int)reader["RelatedIdentityId"];
                    UserClientID            = clientID;
                    cboClient.SelectedValue = Convert.ToString(clientID);
                    Facade.IOrganisation  facOrganisation = new Facade.Organisation();
                    Entities.Organisation organisation    = facOrganisation.GetForIdentityId(clientID);
                    cboClient.Text    = organisation.OrganisationName;
                    cboClient.Enabled = false;
                }
                reader.Close();
            }

            if (UserClientID.HasValue)
            {
                ConfigureClientUI(); //Tweak the grid headings etc. so that the are relevant for a Client user
            }
            if (!dteDateOfDeliveryFrom.SelectedDate.HasValue)
            {
                dteDateOfDeliveryFrom.SelectedDate = DateTime.Today.AddMonths(-5);
            }

            if (!dteDateOfDeliveryTo.SelectedDate.HasValue)
            {
                dteDateOfDeliveryTo.SelectedDate = DateTime.Today.AddMonths(1);
            }

            // retrive the dataset from viewstate
            dsPODList = (DataSet)ViewState[C_PODDATA_VS];
        }
Пример #17
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.GeneralUsage);

            Facade.IUser  facUser = new Facade.User();
            SqlDataReader reader  = facUser.GetRelatedIdentity(((Entities.CustomPrincipal)Page.User).UserName);

            reader.Read();

            if ((eRelationshipType)reader["RelationshipTypeId"] == eRelationshipType.IsClient)
            {
                cboClient.SelectedValue = Convert.ToString((int)reader["RelatedIdentityId"]);
                Facade.IOrganisation  facOrganisation = new Facade.Organisation();
                Entities.Organisation organisation    = facOrganisation.GetForIdentityId((int)reader["RelatedIdentityId"]);
                cboClient.Text    = organisation.OrganisationName;
                cboClient.Enabled = false;
            }

            // Put user code to initialize the page here
        }
Пример #18
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.AddEditOrganisations, eSystemPortion.GeneralUsage);
            btnAdd.Enabled     = Orchestrator.WebUI.Security.Authorise.CanAccess(eSystemPortion.AddEditOrganisations);
            btnPromote.Enabled = Orchestrator.WebUI.Security.Authorise.CanAccess(eSystemPortion.AddEditOrganisations);
            pnlDeliveryNotification.Visible = Globals.Configuration.ClientCustomerDeliveryNotificationEnabled;

            // Setup
            ResetPageDisplay();
            RetrieveQueryStringParameters();
            SetWhereIAm();

            if (!IsPostBack)
            {
                if (m_isUpdate)
                {
                    LoadOrganisation();
                }
            }
            else
            {
                if (m_isUpdate)
                {
                    // Retrieve the organisation details from the viewstate
                    m_organisation     = (Entities.Organisation)ViewState[C_ORGANISATION_VS];
                    m_organisationName = m_organisation.OrganisationName;
                    m_originalStatus   = (eIdentityStatus)ViewState[C_ORIGINALSTATUS_ID_VS];
                }
            }

            if (m_originalStatus == eIdentityStatus.Unapproved)
            {
                approveNote.Visible = true;
            }
            else
            {
                approveNote.Visible = false;
            }

            infringementDisplay.Visible = true;
        }
Пример #19
0
        public OrganisationInfoViewModel(Entities.Organisation organisation)
        {
            OrganisationID   = organisation.ID;
            OrganisationName = organisation.Entity.Name;
            CountryName      = organisation.Country.Entity.Name;
            CountryID        = organisation.CountryID;
            OwnerID          = organisation.OwnerID;
            OwnerName        = organisation.Owner?.Name ?? "";
            Avatar           = new ImageViewModel(organisation.Entity.ImgUrl);

            if (organisation.OwnerID == SessionHelper.CurrentEntity.EntityID)
            {
                IsUnderControl = true;
            }

            var organisationService = DependencyResolver.Current.GetService <IOrganisationService>();

            Rights = organisationService.GetOrganisationRights(SessionHelper.CurrentEntity, SessionHelper.LoggedCitizen, organisation);

            createMenu();
        }
Пример #20
0
        protected void btnApproveOrganisation_Click(object sender, EventArgs e)
        {
            Facade.IOrganisation facOrganisation = new Facade.Organisation();
            int organisationID = Convert.ToInt32(Request.QueryString["OrganisationID"].ToString());

            this.Organisation = facOrganisation.GetForIdentityId(organisationID);
            this.Organisation.IdentityStatus = eIdentityStatus.Active;

            Entities.FacadeResult result = null;
            result = facOrganisation.Update(this.Organisation, this.Page.User.Identity.Name);

            if (result.Success)
            {
                this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ApprovePoint", "window.opener.__doPostBack('','Refresh');window.close();", true);
            }
            else
            {
                idErrors.Infringements = result.Infringements;
                idErrors.DisplayInfringments();
                idErrors.Visible = true;
            }
        }
Пример #21
0
        protected void btnApprovePoint_Click(object sender, EventArgs e)
        {
            int orderId = Convert.ToInt32(Request.QueryString["OrderId"].ToString());
            int pointId = Convert.ToInt32(Request.QueryString["PointId"].ToString());

            Facade.Point   facPoint = new Orchestrator.Facade.Point();
            Entities.Point point    = facPoint.GetPointForPointId(pointId);

            Facade.IOrganisation  facOrg = new Facade.Organisation();
            Entities.Organisation org    = facOrg.GetForName(point.OrganisationName);

            Entities.FacadeResult res = null;

            using (TransactionScope ts = new TransactionScope())
            {
                if (org.IdentityStatus == eIdentityStatus.Unapproved)
                {
                    // Set the identityStatus to approved
                    org.IdentityStatus = eIdentityStatus.Active;
                    facOrg.Update(org, this.Page.User.Identity.Name);
                }

                point.PointStateId = ePointState.Approved;
                res = facPoint.Update(point, this.Page.User.Identity.Name);

                ts.Complete();
            }

            if (res.Success)
            {
                this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ApprovePoint", "window.opener.__doPostBack('','Refresh');window.close();", true);
            }
            else
            {
                idErrors.Infringements = res.Infringements;
                idErrors.DisplayInfringments();
                idErrors.Visible = true;
            }
        }
Пример #22
0
        /// <summary>
        /// Load Report Depending On Invoice Type
        /// </summary>
        private ReportBase LoadReport()
        {
            // Configure the Session variables used to pass data to the report
            NameValueCollection reportParams = new NameValueCollection();

            //-------------------------------------------------------------------------------------
            //						Job/Collect-Drops/References/Demurrages Section
            //-------------------------------------------------------------------------------------
            Facade.IInvoice facInv = new Facade.Invoice();

            DataSet dsInv = null;

            if (m_isUpdate)
            {
                dsInv = facInv.GetJobsForInvoiceId(Convert.ToInt32(lblInvoiceNo.Text));
            }
            else
            {
                dsInv = facInv.GetJobsToInvoice(m_jobIdCSV);
            }

            reportParams.Add("JobIds", m_jobIdCSV);

            reportParams.Add("ExtraIds", m_extraIdCSV);

            //-------------------------------------------------------------------------------------
            //									Param Section
            //-------------------------------------------------------------------------------------
            // Fuel Type & Rate
            eInvoiceDisplayMethod fuelType;
            decimal newRate = 0;

            if (chkIncludeFuelSurcharge.Checked)
            {
                reportParams.Add("Fuel", "Include");

                // Pass The New Rate To Report if so...
                newRate = Convert.ToDecimal(txtFuelSurchargeRate.Text);
                reportParams.Add("FuelRate", newRate.ToString());

                // Pass FuelSurchargeType
                fuelType = (eInvoiceDisplayMethod)Enum.Parse(typeof(eInvoiceDisplayMethod), rdoFuelSurchargeType.SelectedValue);
                reportParams.Add("FuelType", fuelType.ToString());
            }

            // Override
            if (chkOverride.Checked)
            {
                reportParams.Add("Override", "Include");
                reportParams.Add("OverrideVAT", txtOverrideVAT.Text);
                reportParams.Add("OverrideNET", txtOverrideNetAmount.Text);
                reportParams.Add("OverrideGross", txtOverrideGrossAmount.Text);
                reportParams.Add("OverrideReason", txtOverrideReason.Text);
            }

            // PODs
            if (chkIncludePODs.Checked)
            {
                reportParams.Add("PODs", "Include");
            }

            // References
            if (chkIncludeReferences.Checked)
            {
                reportParams.Add("References", "Include");
            }

            // Job
            if (chkJobDetails.Checked)
            {
                reportParams.Add("JobDetails", "Include");

                // Demuragge
                if (chkIncludeDemurrage.Checked)
                {
                    reportParams.Add("Demurrage", "Include");

                    // Demurrage Type
                    try
                    {
                        eInvoiceDisplayMethod demurrageType = (eInvoiceDisplayMethod)Enum.Parse(typeof(eInvoiceDisplayMethod), rdoDemurrageType.SelectedValue);
                        reportParams.Add("DemurrageType", demurrageType.ToString());
                    }
                    catch (Exception) { }
                }
            }

            if (pnlExtras.Visible)
            {
                reportParams.Add("ExtraIds", Convert.ToString(ViewState["ExtraIdCSV"]));
                reportParams.Add("Extras", "Include");
            }

            // Extra details
            if (chkExtraDetails.Visible && chkExtraDetails.Checked)
            {
                reportParams.Add("ExtraDetail", "include");
            }

            // Self Bill Invoice Number
            if ((eInvoiceType)Enum.Parse(typeof(eInvoiceType), lblInvoiceType.Text) == eInvoiceType.SelfBill)
            {
                reportParams.Add("InvoiceType", "SelfBill");
                reportParams.Add("SelfBillInvoiceNumber", txtClientSelfBillInvoiceNumber.Text);
            }
            else
            {
                reportParams.Add("InvoiceType", "Normal");
            }

            // Client Name & Id
            if (m_isUpdate)
            {
                Facade.IInvoice facClient = new Facade.Invoice();

                DataSet ds = facClient.GetClientForInvoiceId(Convert.ToInt32(lblInvoiceNo.Text));

                try
                {
                    reportParams.Add("Client", Convert.ToString(ds.Tables[0].Rows[0]["Client"]));
                    reportParams.Add("ClientId", Convert.ToString(ds.Tables[0].Rows[0]["ClientId"]));

                    m_clientId = int.Parse(ds.Tables[0].Rows[0]["ClientId"].ToString());

                    if (!chkPostToExchequer.Checked)
                    {
                        btnSendToAccounts.Visible = true;
                        pnlInvoiceDeleted.Visible = true;
                    }
                }
                catch
                {
                }
            }
            else
            {
                if (Convert.ToString(Session["ClientName"]) != "")
                {
                    reportParams.Add("Client", Convert.ToString(Session["ClientName"]));
                }

                if (Convert.ToString(Session["ClientId"]) != "")
                {
                    reportParams.Add("ClientId", Convert.ToString(Session["ClientId"]));
                }

                if (m_clientId == 0)
                {
                    m_clientId = int.Parse(Session["ClientId"].ToString());
                }
                else
                {
                    Facade.IOrganisation  facOrg = new Facade.Organisation();
                    Entities.Organisation enOrg  = new Entities.Organisation();
                    enOrg = facOrg.GetForIdentityId(m_clientId);
                    reportParams.Add("Client", enOrg.OrganisationName.ToString());
                    reportParams.Add("ClientId", m_clientId.ToString());
                }
            }

            // Date Range
            if (Convert.ToDateTime(Session["StartDate"]).Date != DateTime.MinValue)
            {
                reportParams.Add("startDate", Convert.ToDateTime(Session["StartDate"]).ToString("dd/MM/yy"));
            }

            if (Convert.ToDateTime(Session["EndDate"]).Date != DateTime.MinValue)
            {
                reportParams.Add("endDate", Convert.ToDateTime(Session["EndDate"]).ToString("dd/MM/yy"));
            }

            // Invoice Id
            if (lblInvoiceNo.Text != "To Be Issued ... (This invoice has not yet been saved, add invoice to allocate Invoice No.)")
            {
                reportParams.Add("invoiceId", lblInvoiceNo.Text);
            }
            else
            {
                reportParams.Add("invoiceId", "0");
            }

            // Posted To Accounts
            if (chkPostToExchequer.Checked)
            {
                reportParams.Add("Accounts", "true");
            }

            int     vatNo   = 0;
            decimal vatRate = 0.00M;

            // VAT Rate
            facInv.GetVatRateForVatType(eVATType.Standard, dteInvoiceDate.SelectedDate.Value, out vatNo, out vatRate);
            reportParams.Add("VATrate", vatRate.ToString());

            // Invoice Date
            reportParams.Add("InvoiceDate", dteInvoiceDate.SelectedDate.Value.ToShortDateString());

            //-------------------------------------------------------------------------------------
            //									Load Report Section
            //-------------------------------------------------------------------------------------
            Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = eReportType.Invoice;
            Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = dsInv;
            Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = rdoSortType.SelectedItem.Text.Replace(" ", "");
            Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";
            Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;

            Orchestrator.Reports.ReportBase activeReport = null;
            eReportType reportType = 0;

            reportType = (eReportType)Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable];
            try
            {
                activeReport = new Orchestrator.Reports.Invoicing.rptInvoice();
            }
            catch (NullReferenceException e)
            {
                Response.Write(e.Message);
                Response.Flush();
                return(null);
            }

            if (activeReport != null)
            {
                try
                {
                    ApplicationLog.WriteTrace("Getting Data From Session Variable");
                    DataView view = null;
                    DataSet  ds   = (DataSet)Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable];

                    string sortExpression = (string)Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable];
                    ApplicationLog.WriteTrace("sortExpression ::" + sortExpression);
                    try
                    {
                        if (sortExpression.Length > 0)
                        {
                            view      = new DataView(ds.Tables[0]);
                            view.Sort = sortExpression;
                            activeReport.DataSource = view;
                        }
                        else
                        {
                            activeReport.DataSource = ds;
                        }

                        activeReport.DataMember = (string)Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable];
                    }
                    catch (Exception eX)
                    {
                        this.Trace.Write("Err1:" + eX.Message);
                        ApplicationLog.WriteTrace("GetReport :: Err1:" + eX.Message);
                    }
                    activeReport.Document.Printer.PrinterName = string.Empty;
                    activeReport.Document.Printer.PaperKind   = System.Drawing.Printing.PaperKind.A4;
                    //activeReport.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4;
                    //activeReport.PrintWidth = activeReport.PageSettings.PaperWidth - (activeReport.PageSettings.Margins.Right + activeReport.PageSettings.Margins.Left);
                    activeReport.Run(false);
                }
                catch (Exception e)
                {
                    Response.Write(e.Message);
                    Response.Flush();
                    return(null);
                }
            }

            Session[Orchestrator.Globals.Constants.ReportSessionVariable] = activeReport;

            return(activeReport);
        }
Пример #23
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            m_jobId = Convert.ToInt32(Request.QueryString["jobId"]);

            if (m_jobId > 0)
            {
                m_isUpdate = true;
            }

            // Retrieve the job from the session variable
            m_job = (Entities.Job)Session[wizard.C_JOB];

            if (Session[wizard.C_INSTRUCTION_INDEX] != null)
            {
                m_instructionIndex = (int)Session[wizard.C_INSTRUCTION_INDEX];

                if (!m_isUpdate && m_instructionIndex != m_job.Instructions.Count)
                {
                    m_isAmendment = true;
                }
            }

            if (!IsPostBack)
            {
                Facade.IOrganisation facOrganisation = new Facade.Organisation();
                btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE);

                if (Session[wizard.C_INSTRUCTION] != null)
                {
                    m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];

                    switch ((eInstructionType)m_instruction.InstructionTypeId)
                    {
                    case eInstructionType.Load:
                        // Allow the user to collect from any location if this is a stock movement job.
                        if (m_job.IsStockMovement)
                        {
                            m_identityId = 0;
                        }
                        else
                        {
                            m_identityId = m_job.IdentityId;
                        }
                        lblCollection.Visible  = true;
                        lblCollectFrom.Visible = true;
                        lblDelivery.Visible    = false;
                        lblDeliverTo.Visible   = false;
                        lblCollectDrop.Text    = "Collection Details";
                        break;

                    case eInstructionType.Drop:
                        m_identityId           = m_instruction.ClientsCustomerIdentityID;
                        lblCollection.Visible  = false;
                        lblCollectFrom.Visible = false;
                        lblDelivery.Visible    = true;
                        lblDeliverTo.Visible   = true;
                        lblCollectDrop.Text    = "Delivery Details";

                        m_owner                = facOrganisation.GetNameForIdentityId(m_identityId);
                        cboOwner.Text          = m_owner;
                        cboOwner.SelectedValue = m_identityId.ToString();
                        cboOwner.Visible       = false;
                        lblOwner.Visible       = true;
                        lblOwner.Text          = m_owner;
                        break;
                    }
                }
                else
                {
                    m_instruction       = new Entities.Instruction();
                    m_instruction.JobId = m_jobId;

                    if (m_job.Instructions == null)
                    {
                        m_job.Instructions = new Entities.InstructionCollection();
                    }

                    switch ((ePointType)Session[wizard.C_POINT_TYPE])
                    {
                    case ePointType.Collect:
                        // Allow the user to collect from any location if this is a stock movement job.
                        if (m_job.IsStockMovement)
                        {
                            m_identityId = 0;
                        }
                        else
                        {
                            m_identityId = m_job.IdentityId;
                        }

                        m_owner                = facOrganisation.GetNameForIdentityId(m_job.IdentityId);
                        cboOwner.Text          = m_owner;
                        cboOwner.SelectedValue = m_identityId.ToString();

                        m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                        lblCollection.Visible           = true;
                        lblCollectFrom.Visible          = true;
                        lblDelivery.Visible             = false;
                        lblDeliverTo.Visible            = false;
                        lblCollectDrop.Text             = "Collection Details";

                        #region Load the Default Collection Point

                        try
                        {
                            Entities.Organisation client       = facOrganisation.GetForIdentityId(m_job.IdentityId);
                            Facade.IPoint         facPoint     = new Facade.Point();
                            Entities.Point        defaultPoint = facPoint.GetPointForPointId(client.Defaults[0].DefaultCollectionPointId);
                            cboTown.SelectedValue  = defaultPoint.PostTown.TownId.ToString();
                            cboTown.Text           = defaultPoint.PostTown.TownName;
                            cboPoint.SelectedValue = defaultPoint.PointId.ToString();
                            cboPoint.Text          = defaultPoint.Description;

                            m_identityId = defaultPoint.IdentityId;
                            m_owner      = defaultPoint.OrganisationName;
                            m_pointId    = defaultPoint.PointId;
                            m_point      = defaultPoint.Description;
                            m_townId     = defaultPoint.PostTown.TownId;
                            m_town       = defaultPoint.PostTown.TownName;

                            cboOwner.Text          = m_owner;
                            cboOwner.SelectedValue = m_identityId.ToString();
                        }
                        catch { }

                        #endregion
                        break;
                    }

                    Session[wizard.C_INSTRUCTION] = m_instruction;

                    if (!m_isUpdate)
                    {
                        Session[wizard.C_INSTRUCTION_INDEX] = m_job.Instructions.Count;
                    }
                }

                if (m_instruction != null && m_instruction.Point != null)
                {
                    cboOwner.SelectedValue = m_instruction.Point.IdentityId.ToString();
                    cboOwner.Text          = m_instruction.Point.OrganisationName;

                    cboPoint.SelectedValue = m_instruction.PointID.ToString();
                    cboPoint.Text          = m_instruction.Point.Description;

                    cboTown.SelectedValue = m_instruction.Point.PostTown.TownId.ToString();
                    cboTown.Text          = m_instruction.Point.PostTown.TownName;
                }
            }
            else
            {
                m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];
            }

            pnlCreateNewPoint.Visible = false;
        }
Пример #24
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (cboPoint.SelectedValue == String.Empty)
                {
                    int ownerID = 0;

                    if (cboOwner.SelectedValue == string.Empty)
                    {
                        // Create a new client customer for the point owner (this can be upgraded to client in the future).
                        Entities.Organisation organisation = new Entities.Organisation();
                        organisation.OrganisationName = cboOwner.Text;
                        organisation.OrganisationType = eOrganisationType.ClientCustomer;
                        Facade.IOrganisation  facOrganisation = new Facade.Organisation();
                        Entities.FacadeResult result          = facOrganisation.Create(organisation, ((Entities.CustomPrincipal)Page.User).UserName);
                        if (result.Success)
                        {
                            ownerID = result.ObjectId;
                        }
                        else
                        {
                            // Organisation has already been created by someone else between validation and this call (unlikely)
                            ownerID = facOrganisation.GetForName(cboOwner.Text).IdentityId;
                        }
                    }
                    else
                    {
                        ownerID = int.Parse(cboOwner.SelectedValue);
                    }

                    // Set the point type, organisation, town, and name for the new point
                    switch ((eInstructionType)m_instruction.InstructionTypeId)
                    {
                    case eInstructionType.Drop:
                        Session[wizard.C_POINT_TYPE] = ePointType.Deliver;
                        Session[wizard.C_POINT_FOR]  = m_instruction.ClientsCustomerIdentityID;
                        break;

                    case eInstructionType.Load:
                        Session[wizard.C_POINT_TYPE] = ePointType.Collect;
                        Session[wizard.C_POINT_FOR]  = ownerID;
                        break;
                    }

                    Session[wizard.C_INSTRUCTION_INDEX] = m_instructionIndex;
                    Session[wizard.C_POINT_NAME]        = cboPoint.Text;
                    Session[wizard.C_TOWN_ID]           = Convert.ToInt32(cboTown.SelectedValue);

                    // The point name must be unique for this client
                    bool          foundPointName = false;
                    Facade.IPoint facPoint       = new Facade.Point();
                    DataSet       pointNames     = facPoint.GetAllForOrganisation((int)Session[wizard.C_POINT_FOR], ePointType.Any, cboPoint.Text);
                    foreach (DataRow row in pointNames.Tables[0].Rows)
                    {
                        if (((string)row["Description"]) == cboPoint.Text)
                        {
                            foundPointName = true;
                        }
                    }

                    if (foundPointName)
                    {
                        pnlCreateNewPoint.Visible = true;
                    }
                    else
                    {
                        // Allow the user to create the new point
                        GoToStep("CNP");
                    }
                }
                else
                {
                    int pointId = Convert.ToInt32(cboPoint.SelectedValue);

                    if (m_isUpdate)
                    {
                        if (m_instruction.InstructionID == 0)
                        {
                            // Adding a new instruction

                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                Facade.IPoint  facPoint      = new Facade.Point();
                                Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                                m_instruction.Point   = selectedPoint;
                                m_instruction.PointID = selectedPoint.PointId;
                            }

                            // Altering an existing instruction
                            // Cause the first collectdrop to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }
                        }
                    }
                    else
                    {
                        if (m_isAmendment)
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                Facade.IPoint  facPoint      = new Facade.Point();
                                Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                                m_instruction.Point   = selectedPoint;
                                m_instruction.PointID = selectedPoint.PointId;
                            }

                            // Cause the first point to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                    }

                    GoToStep("PD");
                }
            }
        }
Пример #25
0
 public OrganisationViewModel(Entities.Organisation organisation)
 {
     Info = new OrganisationInfoViewModel(organisation);
 }
 public OrganisationListItemViewModel(Entities.Organisation organisation)
 {
     OrganisationName = organisation.Entity.Name;
     OrganisationID   = organisation.ID;
     Avatar           = new ImageViewModel(organisation.Entity.ImgUrl);
 }
Пример #27
0
 public OrganisationEquipmentViewModel(Entities.Organisation company, Entities.Equipment equipment)
     : base(equipment)
 {
     Info = new OrganisationInfoViewModel(company);
 }
Пример #28
0
        private void BindJob()
        {
            using (Facade.IJob facJob = new Facade.Job())
            {
                LoadJob();

                using (Facade.IOrganisation facOrganisation = new Facade.Organisation())
                    m_organisation = facOrganisation.GetForIdentityId(m_job.IdentityId);

                XmlDocument          jobDocument = m_job.ToXml();
                XslCompiledTransform transformer = new XslCompiledTransform();
                transformer.Load(Server.MapPath(@"..\..\..\xsl\instructions.xsl"));
                XmlUrlResolver resolver  = new XmlUrlResolver();
                XPathNavigator navigator = jobDocument.CreateNavigator();

                // Populate the Collections.
                XsltArgumentList collectionArgs = new XsltArgumentList();
                if (m_job.JobType == eJobType.PalletReturn)
                {
                    collectionArgs.AddParam("InstructionTypeId", "", "5");
                }
                else
                {
                    collectionArgs.AddParam("InstructionTypeId", "", "1");
                }
                collectionArgs.AddParam("DocketText", "", m_organisation.DocketNumberText);
                collectionArgs.AddParam("webserver", "", Orchestrator.Globals.Configuration.WebServer);
                StringWriter sw = new StringWriter();
                transformer.Transform(navigator, collectionArgs, sw);
                lblCollections.Text = sw.GetStringBuilder().ToString();

                // Populate the Deliveries.
                sw = new StringWriter();
                XsltArgumentList deliveryArgs = new XsltArgumentList();
                deliveryArgs.AddParam("InstructionTypeId", "", "2,6,7");
                deliveryArgs.AddParam("DocketText", "", m_organisation.DocketNumberText);
                deliveryArgs.AddParam("webserver", "", Orchestrator.Globals.Configuration.WebServer);
                transformer.Transform(navigator, deliveryArgs, sw);
                lblDeliveries.Text = sw.GetStringBuilder().ToString();

                // Populate the Pallet Handling.
                sw = new StringWriter();
                XsltArgumentList leavePalletArgs = new XsltArgumentList();
                leavePalletArgs.AddParam("InstructionTypeId", "", "3");
                leavePalletArgs.AddParam("DocketText", "", m_organisation.DocketNumberText);
                leavePalletArgs.AddParam("webserver", "", Orchestrator.Globals.Configuration.WebServer);
                transformer.Transform(navigator, leavePalletArgs, sw);
                lblLeavePallets.Text = sw.GetStringBuilder().ToString();
                sw = new StringWriter();
                XsltArgumentList dehirePalletArgs = new XsltArgumentList();
                dehirePalletArgs.AddParam("InstructionTypeId", "", "4");
                dehirePalletArgs.AddParam("DocketText", "", m_organisation.DocketNumberText);
                dehirePalletArgs.AddParam("webserver", "", Orchestrator.Globals.Configuration.WebServer);
                transformer.Transform(navigator, dehirePalletArgs, sw);
                lblDeHirePallets.Text = sw.GetStringBuilder().ToString();

                if (lblLeavePallets.Text == lblDeHirePallets.Text)
                {
                    lblLeavePallets.Text  = "No Pallet Handling has been configured for this job.";
                    lblDeHirePallets.Text = String.Empty;
                }
            }

            LoadEmptyPallets();
        }
        private void LoadGrid()
        {
            int       clientId  = 0;
            DateTime  startDate = DateTime.MinValue;
            DateTime  endDate   = DateTime.MinValue;
            eJobState jobState  = new eJobState();

            Facade.IOrganisation  facOrg = new Facade.Organisation();
            Entities.Organisation enOrg  = new Entities.Organisation();

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

            if (cboClient.SelectedValue != "")
            {
                clientId          = Convert.ToInt32(cboClient.SelectedValue);
                enOrg             = facOrg.GetForIdentityId(Convert.ToInt32(cboClient.SelectedValue));
                cboClient.Text    = enOrg.OrganisationName;
                pnlFilter.Visible = true;
            }
            //else
            //    pnlFilter.Visible = false;

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

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

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

            bool posted = false;

            if (startDate != DateTime.MinValue || endDate != DateTime.MinValue)
            {
                dsInvoicing = facInvoice.GetJobsToInvoiceWithParamsAndDate(clientId, jobState, posted, startDate, endDate);
            }
            else
            {
                if (clientId == 0)
                {
                    dsInvoicing = facInvoice.GetAllJobsToInvoice();
                }
                else
                {
                    dsInvoicing = facInvoice.GetJobsToInvoiceWithParams(clientId, jobState, posted);
                }
            }

            // Check whether account is on hold
            if (dsInvoicing.Tables[0].Rows.Count > 0)
            {
                if (Convert.ToInt32(dsInvoicing.Tables[0].Rows[0]["OnHold"]) == 1)
                {
                    dlJob.Enabled = false;

                    if (string.IsNullOrEmpty(cboClient.Text))
                    {
                        lblOnHold.Visible = true;
                        lblOnHold.Text    = "Client accounts are on hold, please update their on-hold status in order to raise invoices.</A>";
                    }
                    else
                    {
                        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;
                }

                dlJob.Visible = true;
            }
            else
            {
                lblOnHold.Visible = true;
                lblOnHold.Text    = "With the given parameters no jobs have been found.";
                dlJob.Visible     = false;
            }

            DataView dvInvoice = new DataView(dsInvoicing.Tables[0]);

            // Sort By
            foreach (ListItem sortField in rdoSortType.Items)
            {
                if (sortField.Selected)
                {
                    dvInvoice.Sort = sortField.Text.Replace(" ", "");
                }
            }

            // Load List
            dlJob.DataSource = dvInvoice;

            dlJob.DataBind();

            lblJobCount.Text = "There are " + dlJob.Items.Count.ToString() + " jobs ready to invoice.";

            pnlNormalJob.Visible = true;
            btnFilter.Visible    = true;
            btnFilter1.Visible   = true;
            btnClear.Visible     = true;
            btnClear1.Visible    = true;
            pnlSort.Visible      = true;
            lblJobCount.Visible  = true;
        }
Пример #30
0
        private void ImportOrganisationValues()
        {
            cboEmail.Text              = String.Empty;
            cboEmail.SelectedValue     = String.Empty;
            cboEmail.DataSource        = null;
            cboFaxNumber.SelectedValue = String.Empty;
            cboFaxNumber.Text          = String.Empty;
            cboFaxNumber.DataSource    = null;
            txtFaxNumber.Text          = String.Empty;
            txtEmail.Text              = String.Empty;

            if (m_identityId > 0)
            {
                Facade.IOrganisation  facOrganisation = new Facade.Organisation();
                Entities.Organisation organisation    = facOrganisation.GetForIdentityId(m_identityId);

                //RJD: changed to use IndividualContacts instead of PrimaryContact STILL NEEDS WORK
                if (organisation != null && (organisation.IndividualContacts != null && organisation.IndividualContacts.Count > 0))
                {
                    DataSet emailDataSet = this.GetContactDataSet(organisation.IndividualContacts, eContactType.Email);

                    cboEmail.DataSource     = emailDataSet;
                    cboEmail.DataMember     = "contactTable";
                    cboEmail.DataValueField = "ContactDetail";
                    cboEmail.DataTextField  = "ContactDisplay";
                    cboEmail.DataBind();

                    if (this.cboEmail.Items.Count > 0)
                    {
                        this.txtEmail.Text = this.cboEmail.Items[0].Value;
                    }

                    DataSet faxDataSet = this.GetContactDataSet(organisation.IndividualContacts, eContactType.Fax);

                    if (organisation != null && organisation.Locations != null)
                    {
                        Entities.OrganisationLocation headOffice = organisation.Locations.GetHeadOffice();

                        if (!String.IsNullOrEmpty(headOffice.FaxNumber))
                        {
                            DataRow dr = faxDataSet.Tables[0].NewRow();
                            dr["ContactName"]    = "Head Office";
                            dr["ContactDetail"]  = headOffice.FaxNumber;
                            dr["ContactDisplay"] = String.Format("{0} - {1}", dr["ContactName"], headOffice.FaxNumber);
                            faxDataSet.Tables[0].Rows.InsertAt(dr, 0);
                        }
                    }

                    cboFaxNumber.DataSource     = faxDataSet;
                    cboFaxNumber.DataMember     = "contactTable";
                    cboFaxNumber.DataValueField = "ContactDetail";
                    cboFaxNumber.DataTextField  = "ContactDisplay";
                    cboFaxNumber.DataBind();

                    if (this.cboFaxNumber.Items.Count > 0)
                    {
                        this.txtFaxNumber.Text = this.cboFaxNumber.Items[0].Value;
                    }
                }
            }
            else
            {
                cboFaxNumber.Text = txtFaxNumber.Text = String.Empty;
            }
        }