protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        if (!IsPostBack)
        {
            // Get the query string values.
            NameValueCollection coll = Request.QueryString;

            int agentId    = Convert.ToInt32(coll.Get("aId"));
            int categoryId = Convert.ToInt32(coll.Get("cId"));
            int statusId   = Convert.ToInt32(coll.Get("sId"));

            // Set the report viewer control's size.
            ReportViewerControl.ReportWidth  = 875;
            ReportViewerControl.ReportHeight = 615;

            // Get the report data.
            try
            {
                DesignService.DesignService designService =
                    serviceLoader.GetDesign();
                IList <DesignService.DesignStatusInfo> statuses =
                    designService.GetDesignStatuses(agentId, categoryId, statusId);

                ReportViewerControl.DataSource     = statuses;
                ReportViewerControl.DataSourceName = "DesignStatusInfo";
                ReportViewerControl.ReportPath     = "Members/Reports/DesignStatusReport.rdlc";
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
예제 #2
0
    private bool Save(int statusId)
    {
        string approvedDesignRoot = ConfigurationManager.AppSettings["ApprovedDesignRoot"];

        // Get the logged in account information.
        RegistrationService.LoginInfo loginInfo =
            (RegistrationService.LoginInfo)Session["loginInfo"];

        // Get the upload location.
        string path = Server.MapPath("~/Members/UserData/" + AgentIdHiddenField.Value);

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        if (!ValidateFiles())
        {
            return(false);
        }

        // Upload the files.
        string lowResolutionFile  = LowResolutionFileHiddenField.Value;
        string highResolutionFile = HighResolutionFileHiddenField.Value;
        string additionalFile     = AdditionalFileHiddenField.Value;

        try
        {
            Util.Design.UploadFiles(path, ref lowResolutionFile,
                                    ref highResolutionFile, ref additionalFile,
                                    Convert.ToInt32(IdHiddenField.Value),
                                    LowResolutionFileUpload, HighResolutionFileUpload,
                                    AdditionalFileUpload, ref RemoveAdditionalFileHiddenField);

            try
            {
                if (statusId == (int)DesignStatus.Approved)
                {
                    if (StatusLabel.Text == "Submitted")
                    {
                        File.Copy(path + "\\" + lowResolutionFile,
                                  approvedDesignRoot + "\\" + lowResolutionFile, true);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Unknown Error", ex);
            }
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
            return(false);
        }

        // Save the data.
        try
        {
            string[] typeArgs = TypeDropDownList.SelectedValue.Split("|".ToCharArray());
            decimal  length = 0, width = 0;

            DesignService.DesignService designService = serviceLoader.GetDesign();
            DesignService.DesignInfo    design        = new DesignService.DesignInfo();

            // Design Details.
            design.DesignId = Convert.ToInt32(IdHiddenField.Value);
            design.UserId   = Convert.ToInt32(AgentIdHiddenField.Value);
            DesignService.LookupInfo category         = new DesignService.LookupInfo();
            category.LookupId = (int)DesignCategory.PowerKard;
            category.Name     = DesignCategory.PowerKard.ToString();
            design.Category   = category;
            DesignService.LookupInfo type             = new DesignService.LookupInfo();
            if (typeArgs[0] == DesignType.Standard.ToString().Substring(0, 1))
            {
                type.LookupId = (int)DesignType.Standard;
                type.Name     = DesignType.Standard.ToString();
                length        = Convert.ToDecimal(typeArgs[1]);
                width         = Convert.ToDecimal(typeArgs[2]);
            }
            else
            {
                type.LookupId = (int)DesignType.Custom;
                type.Name     = DesignType.Custom.ToString();
                length        = Convert.ToDecimal(LengthTextBox.Text);
                width         = Convert.ToDecimal(WidthTextBox.Text);
            }
            design.Type = type;
            DesignService.SizeF size = new DesignService.SizeF();
            size.Width  = (float)length;
            size.Height = (float)width;
            design.Size = size;

            // Attributes.
            design.Gender        = GenderDropDownList.SelectedValue;
            design.OnDesignName  = AgentNameTextBox.Text;
            design.Justification = (DesignService.JustificationType)Convert.ToInt32(JustificationDropDownList.SelectedValue);
            design.Gutter        = GutterDropDownList.SelectedValue;
            DesignService.RectangleF messageRectangle = new DesignService.RectangleF();
            messageRectangle.X      = MessageXTextBox.Text.Trim() != "" ? (float)Convert.ToDecimal(MessageXTextBox.Text.Trim()) : 0;
            messageRectangle.Y      = MessageYTextBox.Text.Trim() != "" ? (float)Convert.ToDecimal(MessageYTextBox.Text.Trim()) : 0;
            messageRectangle.Width  = MessageLengthTextBox.Text.Trim() != "" ? (float)Convert.ToDecimal(MessageLengthTextBox.Text.Trim()) : 0;
            messageRectangle.Height = MessageWidthTextBox.Text.Trim() != "" ? (float)Convert.ToDecimal(MessageWidthTextBox.Text.Trim()) : 0;
            design.MessageRectangle = messageRectangle;

            // Upload Files.
            design.LowResolutionFile  = lowResolutionFile;
            design.HighResolutionFile = highResolutionFile;
            design.ExtraFile          = additionalFile;

            // Additional fields.
            DesignService.LookupInfo status = new DesignService.LookupInfo();
            status.LookupId     = statusId;
            design.Status       = status;
            design.LastModifyBy = loginInfo.UserId;
            design.Comments     = NotesTextBox.Text;
            if (statusId == (int)DesignStatus.Approved)
            {
                design.ApproveBy = loginInfo.UserId;
            }
            else
            {
                design.ApproveBy = 0;
            }

            designService.Update(loginInfo.UserId, design);

            try
            {
                if (statusId == (int)DesignStatus.Approved)
                {
                    if (StatusLabel.Text == "Submitted")
                    {
                        Util.Design.SendEmailAsApproved(design, Request.ApplicationPath,
                                                        Request.Url.ToString());
                    }
                }
                else if (statusId == (int)DesignStatus.Submitted)
                {
                    if (design.UserId == design.LastModifyBy)
                    {
                        Util.Design.SendEmailAsSubmitted(design, Request.ApplicationPath,
                                                         Request.Url.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Unknown Error", ex);
            }

            return(true);
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
            return(false);
        }
    }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int     id        = Convert.ToInt32(coll.Get("id"));
        string  mode      = coll.Get("mode");
        string  type      = coll.Get("type");
        decimal length    = Convert.ToDecimal(coll.Get("length"));
        decimal width     = Convert.ToDecimal(coll.Get("width"));
        int     agentId   = Convert.ToInt32(coll.Get("aId"));
        string  agentName = coll.Get("aName");

        // Change the title of the page.
        Page.Title          = "Mailing Cycle " + mode + " PowerKard";
        PageTitleLabel.Text = mode + " PowerKard";
        if (mode == "Edit")
        {
            AddPageDescriptionPanel.Visible  = false;
            EditPageDescriptionPanel.Visible = true;
        }
        else if (mode == "Review")
        {
            AddPageDescriptionPanel.Visible    = false;
            ReviewPageDescriptionPanel.Visible = true;
        }
        else if (mode == "View")
        {
            AddPageDescriptionPanel.Visible  = false;
            ViewPageDescriptionPanel.Visible = true;
        }
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + "&nbsp;";
        }

        ErrorMessageLabel.Visible = false;

        if (!IsPostBack)
        {
            // Get the logged in account information.
            RegistrationService.LoginInfo loginInfo =
                (RegistrationService.LoginInfo)Session["loginInfo"];

            // Set the required query string varables into hidden fields.
            IdHiddenField.Value        = id.ToString();
            ModeHiddenField.Value      = mode.ToString();
            AgentIdHiddenField.Value   = agentId.ToString();
            AgentNameHiddenField.Value = agentName;

            // Set the controls based on the role.
            if (loginInfo.Role == RegistrationService.UserRole.Agent)
            {
                NotesRow.Visible = false;
            }

            // Set the design details section.
            TypeDropDownList.SelectedValue = type
                                             + "|" + (type == "S" ? length.ToString("####.####") : "0")
                                             + "|" + (type == "S" ? width.ToString("####.####") : "0");
            LengthTextBox.Text = length.ToString("####.####");
            WidthTextBox.Text  = width.ToString("####.####");
            if (type != "C")
            {
                LengthTextBox.Enabled = false;
                WidthTextBox.Enabled  = false;
            }

            // Get the design details, if one exists.
            if (id != 0)
            {
                try
                {
                    DesignService.DesignService designService = serviceLoader.GetDesign();

                    DesignService.DesignInfo design = designService.Get(id);

                    // Display Data - Status.
                    AgentIdHiddenField.Value = design.UserId.ToString();
                    StatusLabel.Text         = design.Status.Name;
                    UsedHiddenField.Value    = design.Used.ToString();

                    // Display Data - Attributes.
                    GenderDropDownList.SelectedValue        = design.Gender;
                    AgentNameTextBox.Text                   = design.OnDesignName;
                    JustificationDropDownList.SelectedValue = ((int)design.Justification).ToString();
                    GutterDropDownList.SelectedValue        = design.Gutter;
                    MessageXTextBox.Text      = design.MessageRectangle.X.ToString("####.####");
                    MessageYTextBox.Text      = design.MessageRectangle.Y.ToString("####.####");
                    MessageLengthTextBox.Text = design.MessageRectangle.Width.ToString("####.####");
                    MessageWidthTextBox.Text  = design.MessageRectangle.Height.ToString("####.####");

                    // Display Data - Upload Files.
                    string path = Server.MapPath("~/Members/UserData/" + AgentIdHiddenField.Value) + "\\";
                    string lowResolutionFile, highResolutionFile, additionalFile = string.Empty;

                    lowResolutionFile = design.LowResolutionFile;
                    LowResolutionFileHyperLink.Text        = lowResolutionFile.Substring(lowResolutionFile.IndexOf("_") + 1);
                    LowResolutionFileHyperLink.NavigateUrl = "~/Members/UserData/" +
                                                             AgentIdHiddenField.Value + "/" + lowResolutionFile;
                    LowResolutionFileHyperLink.Target = "_blank";
                    FileInfo file = new FileInfo(path + lowResolutionFile);
                    if (file.Exists)
                    {
                        LowResolutionFileSizeLabel.Text = Convert.ToInt32(file.Length / 1024).ToString() + " KB";
                    }
                    else
                    {
                        LowResolutionFileSizeLabel.Text = "-";
                    }
                    LowResolutionFileNotExistsPanel.Style.Value =
                        "position: absolute; visibility: hidden;";
                    LowResolutionFileExistsPanel.Style.Value =
                        "position: relative; visibility: visible;";
                    LowResolutionFileRequiredFieldValidator.Enabled = false;
                    LowResolutionFileHiddenField.Value = lowResolutionFile;

                    highResolutionFile = design.HighResolutionFile;
                    HighResolutionFileHyperLink.Text        = highResolutionFile.Substring(highResolutionFile.IndexOf("_") + 1);
                    HighResolutionFileHyperLink.NavigateUrl = "~/Members/UserData/" +
                                                              AgentIdHiddenField.Value + "/" + highResolutionFile;
                    HighResolutionFileHyperLink.Target = "_blank";
                    file = new FileInfo(path + highResolutionFile);
                    if (file.Exists)
                    {
                        HighResolutionFileSizeLabel.Text = Convert.ToInt32(file.Length / 1024).ToString() + " KB";
                    }
                    else
                    {
                        HighResolutionFileSizeLabel.Text = "-";
                    }
                    HighResolutionFileNotExistsPanel.Style.Value =
                        "position: absolute; visibility: hidden;";
                    HighResolutionFileExistsPanel.Style.Value =
                        "position: relative; visibility: visible;";
                    HighResolutionFileRequiredFieldValidator.Enabled = false;
                    HighResolutionFileHiddenField.Value = highResolutionFile;

                    if (design.ExtraFile != "")
                    {
                        additionalFile = design.ExtraFile;
                        AdditionalFileHyperLink.Text        = additionalFile.Substring(additionalFile.IndexOf("_") + 1);
                        AdditionalFileHyperLink.NavigateUrl = "~/Members/UserData/" +
                                                              AgentIdHiddenField.Value + "/" + additionalFile;
                        AdditionalFileHyperLink.Target = "_blank";
                        file = new FileInfo(path + additionalFile);
                        if (file.Exists)
                        {
                            AdditionalFileSizeLabel.Text = Convert.ToInt32(file.Length / 1024).ToString() + " KB";
                        }
                        else
                        {
                            AdditionalFileSizeLabel.Text = "-";
                        }
                        AdditionalFileNotExistsPanel.Style.Value =
                            "position: absolute; visibility: hidden;";
                        AdditionalFileExistsPanel.Style.Value =
                            "position: relative; visibility: visible;";
                        AdditionalFileHiddenField.Value = additionalFile;
                    }

                    // Display Data - History.
                    HistoryTextBox.Text = design.History;

                    if (mode == "View")
                    {
                        DisableDesignInformation();

                        NotesTextBox.Enabled = false;

                        AgentButtonsPanel.Visible        = false;
                        ReadOnlyButtonsPanel.Visible     = true;
                        AgentButtonsHelpPanel.Visible    = false;
                        ReadOnlyButtonsHelpPanel.Visible = true;
                    }
                    else if (mode == "Review")
                    {
                        AgentButtonsPanel.Visible   = false;
                        ReviewButtonsPanel.Visible  = true;
                        MessageLocnManLabel.Visible = true;
                        MessageSizeManLabel.Visible = true;
                        MessageXTextBoxRequiredFieldValidator.Enabled      = true;
                        MessageYTextBoxRequiredFieldValidator.Enabled      = true;
                        MessageLengthTextBoxRequiredFieldValidator.Enabled = true;
                        MessageWidthTextBoxRequiredFieldValidator.Enabled  = true;
                        AgentButtonsHelpPanel.Visible  = false;
                        ReviewButtonsHelpPanel.Visible = true;
                    }
                    else if (mode == "Edit")
                    {
                        if (StatusLabel.Text == "Uploaded")
                        {
                            if (loginInfo.Role != RegistrationService.UserRole.Agent)
                            {
                                AgentButtonsPanel.Visible         = false;
                                ReadWriteButtonsPanel.Visible     = true;
                                AgentButtonsHelpPanel.Visible     = false;
                                ReadWriteButtonsHelpPanel.Visible = true;
                            }
                        }
                        else if (StatusLabel.Text == "Submitted")
                        {
                            DisableDesignInformation();

                            AgentButtonsPanel.Visible         = false;
                            ReadWriteButtonsPanel.Visible     = true;
                            AgentButtonsHelpPanel.Visible     = false;
                            ReadWriteButtonsHelpPanel.Visible = true;
                        }
                        else if (StatusLabel.Text == "Approved")
                        {
                            DisableDesignInformation();

                            AgentButtonsPanel.Visible      = false;
                            DeleteButtonsPanel.Visible     = true;
                            AgentButtonsHelpPanel.Visible  = false;
                            DeleteButtonsHelpPanel.Visible = true;

                            // Check whether pages already extracted.
                            int    index = LowResolutionFileHiddenField.Value.LastIndexOf(".");
                            string approvedDesignPage =
                                ConfigurationManager.AppSettings["ApprovedDesignRoot"] +
                                "\\ExtractedPages\\" +
                                LowResolutionFileHiddenField.Value.Substring(0, index) +
                                "_Page.jpg";

                            file = new FileInfo(approvedDesignPage);
                            if (file.Exists)
                            {
                                ExtractPagesButton.Enabled = false;
                            }
                            else
                            {
                                ExtractPagesButton.Enabled = true;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                    ErrorMessageLabel.Visible = true;

                    log.Error("Unknown Error", ex);
                }
            }

            if (mode == "Add")
            {
                if (loginInfo.Role != RegistrationService.UserRole.Agent)
                {
                    AgentButtonsPanel.Visible         = false;
                    ReadWriteButtonsPanel.Visible     = true;
                    AgentButtonsHelpPanel.Visible     = false;
                    ReadWriteButtonsHelpPanel.Visible = true;
                }
            }
        }
    }
예제 #4
0
    protected void DeleteButton_Click(object sender, EventArgs e)
    {
        // Get the logged in account information.
        RegistrationService.LoginInfo loginInfo =
            (RegistrationService.LoginInfo)Session["loginInfo"];

        if (UsedHiddenField.Value == DesignUsed.Never.ToString())
        {
            string approvedDesignRoot = ConfigurationManager.AppSettings["ApprovedDesignRoot"];

            // Get the upload location.
            string path = Server.MapPath("~/Members/UserData/" + AgentIdHiddenField.Value);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            // Delete the files and the record.
            string lowResolutionFile  = LowResolutionFileHiddenField.Value;
            string highResolutionFile = HighResolutionFileHiddenField.Value;
            string additionalFile     = AdditionalFileHiddenField.Value;

            try
            {
                if (File.Exists(path + "\\" + lowResolutionFile))
                {
                    File.Delete(path + "\\" + lowResolutionFile);
                }

                // Delete the file from the approved designs location.
                // *********************************************************************
                string approvedDesign     = approvedDesignRoot + "\\" + lowResolutionFile;
                int    index              = lowResolutionFile.LastIndexOf(".");
                string approvedDesignPage = approvedDesignRoot +
                                            "\\ExtractedPages\\" + lowResolutionFile.Substring(0, index) +
                                            "_Page.jpg";

                if (File.Exists(approvedDesign))
                {
                    File.Delete(approvedDesign);
                }

                if (File.Exists(approvedDesignPage))
                {
                    File.Delete(approvedDesignPage);
                }
                // *********************************************************************

                if (File.Exists(path + "\\" + highResolutionFile))
                {
                    File.Delete(path + "\\" + highResolutionFile);
                }

                if (additionalFile != "")
                {
                    if (File.Exists(path + "\\" + additionalFile))
                    {
                        File.Delete(path + "\\" + additionalFile);
                    }
                }

                DesignService.DesignService designService = serviceLoader.GetDesign();

                int designId = Convert.ToInt32(IdHiddenField.Value);

                designService.Delete(designId, loginInfo.UserId);

                string queryString = "?aId=" + AgentIdHiddenField.Value;

                Response.Redirect("~/Members/DesignManagement.aspx" + queryString);
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
                ResetUploadFilePanels();
            }
        }
        else if (UsedHiddenField.Value == DesignUsed.Found.ToString())
        {
            if (Save((int)DesignStatus.Inactivated))
            {
                string queryString = "?aId=" + AgentIdHiddenField.Value;

                Response.Redirect("~/Members/DesignManagement.aspx" + queryString);
            }
            else
            {
                ResetUploadFilePanels();
            }
        }
    }
예제 #5
0
    protected void RejectButton_Click(object sender, EventArgs e)
    {
        // Get the logged in account information.
        RegistrationService.LoginInfo loginInfo =
            (RegistrationService.LoginInfo)Session["loginInfo"];

        // Get the upload location.
        string path = Server.MapPath("~/Members/UserData/" + AgentIdHiddenField.Value);

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        // Delete the files and the record.
        string lowResolutionFile  = LowResolutionFileHiddenField.Value;
        string highResolutionFile = HighResolutionFileHiddenField.Value;
        string additionalFile     = AdditionalFileHiddenField.Value;

        try
        {
            if (IdHiddenField.Value != "0")
            {
                if (File.Exists(path + "\\" + lowResolutionFile))
                {
                    File.Delete(path + "\\" + lowResolutionFile);
                }
            }

            if (IdHiddenField.Value != "0")
            {
                if (File.Exists(path + "\\" + highResolutionFile))
                {
                    File.Delete(path + "\\" + highResolutionFile);
                }
            }

            if (IdHiddenField.Value != "0" && additionalFile != "")
            {
                if (File.Exists(path + "\\" + additionalFile))
                {
                    File.Delete(path + "\\" + additionalFile);
                }
            }

            DesignService.DesignService designService = serviceLoader.GetDesign();

            int designId = Convert.ToInt32(IdHiddenField.Value);

            designService.Delete(designId, loginInfo.UserId);

            try
            {
                Util.Design.SendEmailAsRejected(Convert.ToInt32(AgentIdHiddenField.Value),
                                                "PowerKard", NotesTextBox.Text.Trim(), Request.ApplicationPath);
            }
            catch (Exception ex)
            {
                log.Error("Unknown Error", ex);
            }

            string queryString = "?aId=" + AgentIdHiddenField.Value;

            Response.Redirect("~/Members/DesignManagement.aspx" + queryString);
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
            ResetUploadFilePanels();
        }
    }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (IsPrinterRole)
            {
                DeleteFarmButton.Enabled = false;
                EditFarmButton.Enabled   = false;
                FirmUpButton.Enabled     = false;
                CreatePlotButton.Enabled = false;
            }
            int farmId = 0;
            if ((Request.QueryString["farmId"] != "") && (Request.QueryString["farmId"] != null))
            {
                int.TryParse(Request.QueryString["farmId"], out farmId);
            }

            if (farmId == 0)
            {
                Response.Redirect("~/Members/FarmManagement.aspx");
            }

            FarmIdHiddenField.Value = farmId.ToString();

            try
            {
                // Get the common web service instance.

                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();
                int userId = farmService.GetUserIdForFarm(farmId);
                UserIdHiddenField.Value = userId.ToString();
                if (!IsAgentRole)
                {
                    ForAgentLiteral.Visible = true;
                    RegistrationService.RegistrationService regservice = serviceLoader.GetRegistration();
                    RegistrationService.RegistrationInfo    regInfo    = regservice.GetDetails(userId);
                    ForAgentLiteral.Text            = "Selected Agent: " + regInfo.UserName + " / " + regInfo.FirstName + " " + regInfo.LastName + "&nbsp;";
                    ForAgentUserIdHiddenField.Value = userId.ToString();
                }
                else
                {
                    ForAgentLiteral.Visible = false;
                }

                FarmService.FarmInfo farm = farmService.GetFarmDetail(farmId);
                FarmNameLabel.Text    = farm.FarmName;
                MailingPlanLabel.Text = farm.MailingPlan.Title;
                CreateDateLabel.Text  = farm.CreateDate.ToShortDateString();
                if (farm.Firmup)
                {
                    FirmupStatusLabel.Text = "Firmed Up";
                }
                else
                {
                    FirmupStatusLabel.Text = "Not Firmed Up";
                }
                FarmContactCountLabel.Text = farm.ContactCount.ToString();
                PlotCountLabel.Text        = farm.PlotCount.ToString();

                FillPlotGrid(farm.Plots, 0);

                // ***************** Firm Up ***************** \\
                if (IsAgentRole)
                {
                    // Set the firm up button visible to agent.
                    FirmUpButtonPanel.Visible = true;

                    // Get the mailing plan of the farm.
                    int mailingPlanId = farm.MailingPlan.MailingPlanId;

                    // Get the design details of the agent.
                    DesignService.DesignService designService = serviceLoader.GetDesign();
                    DesignService.DesignInfo    design        = new DesignService.DesignInfo();
                    DesignService.DesignInfo    brochure      = new DesignService.DesignInfo();

                    RegistrationService.LoginInfo loginInfo =
                        (RegistrationService.LoginInfo)Session["loginInfo"];
                    IList <DesignService.DesignInfo> designs =
                        designService.GetList(loginInfo.UserId);

                    foreach (DesignService.DesignInfo designInfo in designs)
                    {
                        if (designInfo.Category.Name == "PowerKard")
                        {
                            design = designInfo;
                        }
                        else
                        {
                            brochure = designInfo;
                        }
                    }

                    // Get the credit card details of the logged in agent.
                    RegistrationService.RegistrationService registrationService =
                        serviceLoader.GetRegistration();
                    RegistrationService.CreditCardInfo creditCard =
                        registrationService.GetCreditCard(loginInfo.UserId);
                    bool isCreditCardValid = false;

                    if (creditCard != null)
                    {
                        DateTime expirationDate =
                            new DateTime(creditCard.ExpirationYear,
                                         creditCard.ExpirationMonth,
                                         1);

                        expirationDate = expirationDate.AddMonths(1);

                        if (expirationDate > DateTime.Today)
                        {
                            isCreditCardValid = true;
                        }
                    }

                    // Check whether the farm is ready for firm up.
                    if (mailingPlanId == 0)
                    {
                        FirmUpStatusHiddenField.Value = "MP_REQ";
                    }
                    else if (mailingPlanId == 100003)
                    {
                        // 8 x 8.
                        if (design.Status.Name != "Approved")
                        {
                            FirmUpStatusHiddenField.Value = "DESIGN_REQ";
                        }
                    }
                    else
                    {
                        if (design.Status.Name != "Approved" ||
                            brochure.Status.Name != "Approved")
                        {
                            FirmUpStatusHiddenField.Value = "DESIGN_REQ";
                        }
                    }

                    if (!isCreditCardValid)
                    {
                        FirmUpStatusHiddenField.Value = "CC_INVALID";
                    }

                    if (farm.Firmup)
                    {
                        FirmUpButton.Enabled = false;
                    }
                }
                // ******************************************* \\
            }
            catch (Exception ex)
            {
                log.Error("UNKNOWN ERROR:", ex);
                ErrorLiteral.Text = "Unknown Error Please contact Administrator:";
            }
        }
    }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["loginInfo"] == null || Session["loginInfo"] == "")
        {
            Response.Redirect("../userLogin.aspx?Message=SessionExpired");
        }

        RegistrationService.LoginInfo loginInfo = (RegistrationService.LoginInfo)Session["loginInfo"];
        bool          isAgent       = (loginInfo.Role == RegistrationService.UserRole.Agent);
        ServiceAccess serviceLoader = ServiceAccess.GetInstance();

        // ************Populate the Farm Data************

        FarmService.FarmService farmService = serviceLoader.GetFarm();
        int  farmCount    = 0;
        int  plotCount    = 0;
        long contactCount = 0;

        if (isAgent)
        {
            FarmService.FarmInfo[] farmInfo = farmService.GetFarmSummary(loginInfo.UserId);
            farmCount = farmInfo.Length;
            for (int i = 0; i < farmCount; i++)
            {
                plotCount    = plotCount + farmInfo[i].PlotCount;
                contactCount = contactCount + farmInfo[i].ContactCount;
            }
        }
        else
        {
            farmCount    = farmService.TotalActiveFarmCount();
            plotCount    = farmService.TotalActivePlotCount();
            contactCount = farmService.TotalActiveContactCount();
        }

        FarmPlotLabel.Text = farmCount.ToString() + " Farms / " + plotCount + " Plots";
        ContactLabel.Text  = contactCount.ToString() + " Contacts";

        // ************Populate Messages Data************
        MessageService messageService = serviceLoader.GetMessage();

        StandardMessagesLabel.Text = messageService.GetStandardMessageList(isAgent, string.Empty, string.Empty).Length + " messages";

        if (isAgent)
        {
            CustomMessagesLabel.Text = messageService.GetCustomMessageList(loginInfo.UserId).Length + " messages";
        }
        else
        {
            CustomMessagesLabel.Text = messageService.GetCustomMessageList(0).Length + " messages";
        }


        // ************Populate design Data************
        DesignService.DesignService designService = serviceLoader.GetDesign();

        if (isAgent)
        {
            IList <DesignService.DesignInfo> designs =
                designService.GetList(loginInfo.UserId);

            DesignService.DesignInfo design   = new DesignService.DesignInfo();
            DesignService.DesignInfo brochure = new DesignService.DesignInfo();

            foreach (DesignService.DesignInfo designInfo in designs)
            {
                if (designInfo.Category.Name == "PowerKard")
                {
                    design = designInfo;
                }
                else
                {
                    brochure = designInfo;
                }
            }

            PowerKardStatusLabel.Text = design.Status.Name.ToString();
            BrochureStatusLabel.Text  = brochure.Status.Name.ToString();
        }
        else
        {
            object[]  designStatusArray;
            DataTable designStatusTable = new DataTable();
            designStatusArray = designService.GetSummary();
            designStatusTable = Util.GetDataTable(designStatusArray);

            if (designStatusTable != null)
            {
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text + designStatusTable.Rows[0][3] + " - " + designStatusTable.Rows[0][4] + ",";
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text + designStatusTable.Rows[1][3] + " - " + designStatusTable.Rows[1][4] + ",";
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text + designStatusTable.Rows[4][3] + " - " + designStatusTable.Rows[4][4] + ",";
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Substring(0, PowerKardStatusLabel.Text.Length - 1);

                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Replace("Uploaded", "Upd");
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Replace("Submitted", "Sub");
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Replace("Approved", "App");

                BrochureStatusLabel.Text = BrochureStatusLabel.Text + designStatusTable.Rows[5][3] + " - " + designStatusTable.Rows[5][4] + ",";
                BrochureStatusLabel.Text = BrochureStatusLabel.Text + designStatusTable.Rows[6][3] + " - " + designStatusTable.Rows[6][4] + ",";
                BrochureStatusLabel.Text = BrochureStatusLabel.Text + designStatusTable.Rows[9][3] + " - " + designStatusTable.Rows[9][4] + ",";
                BrochureStatusLabel.Text = BrochureStatusLabel.Text.Substring(0, BrochureStatusLabel.Text.Length - 1);

                BrochureStatusLabel.Text = BrochureStatusLabel.Text.Replace("Uploaded", "Upd");
                BrochureStatusLabel.Text = BrochureStatusLabel.Text.Replace("Submitted", "Sub");
                BrochureStatusLabel.Text = BrochureStatusLabel.Text.Replace("Approved", "App");

                WelcomeHelpPanel.Visible = true;
            }
        }
        // ************Populate Inventory Data************

        ProductService.ProductService    productService = serviceLoader.GetProduct();
        ProductService.ProductItemInfo[] productItemInfo;

        if (isAgent)
        {
            productItemInfo = productService.GetInventoryTotalCount(loginInfo.UserId);
        }
        else
        {
            productItemInfo = productService.GetInventoryTotalCount(0);
        }

        if (productItemInfo.Length < 1)
        {
            InventoryLabel.Text = "PowerKards:0<br>Brochures:0";
        }

        InventoryRepeater.DataSource = productItemInfo;
        InventoryRepeater.DataBind();

        // ************Populate Schedule Management Data************
        ScheduleService.ScheduleService scheduleService = serviceLoader.GetSchedule();

        object[]  SchedulePlansArray;
        DataTable SchedulePlansTable = new DataTable();

        if (isAgent)
        {
            SchedulePlansArray = scheduleService.GetSummaryOfUser(loginInfo.UserId);
        }
        else
        {
            SchedulePlansArray = scheduleService.GetSummary();
        }

        SchedulePlansTable = Util.GetDataTable(SchedulePlansArray);

        if (SchedulePlansTable != null)
        {
            ActivePlansLabel.Text = SchedulePlansTable.Rows[0][0].ToString() + ": " + SchedulePlansTable.Rows[0][1].ToString();
            if (Convert.ToInt32(SchedulePlansTable.Rows[1][1].ToString()) > 0)
            {
                DelayedPlansLabel.Text = SchedulePlansTable.Rows[1][0].ToString() + ": " + SchedulePlansTable.Rows[1][1].ToString();
            }
        }

        //********* Populate User Management Info **********

        if (isAgent)
        {
            UserManagementPanel.Visible = false;
        }
        else
        {
            object[]  usersArray;
            DataTable usersTable = new DataTable();
            RegistrationService.RegistrationService registrationService = ServiceAccess.GetInstance().GetRegistration();

            usersArray = registrationService.GetApprovalRequiredUsers();
            usersTable = Util.GetDataTable(usersArray);
            RegistrationService.UserRole userRole;
            if (usersTable != null)
            {
                if (usersTable.Rows.Count < 1)
                {
                    UsersLabel.Text = "No Users waiting for approval";
                }
                else
                {
                    for (int i = 0; i < usersTable.Rows.Count; i++)
                    {
                        userRole        = (RegistrationService.UserRole)((Convert.ToInt32(usersTable.Rows[i][0].ToString()) - 1));
                        UsersLabel.Text = UsersLabel.Text + userRole.ToString() + " : " + usersTable.Rows[i][1].ToString() + "<br>";
                    }
                }
            }
        }
    }
예제 #8
0
    private void DisplayDesigns(int agentId)
    {
        try
        {
            DesignService.DesignService      designService = serviceLoader.GetDesign();
            IList <DesignService.DesignInfo> designs       =
                designService.GetListAll(agentId);

            DesignService.DesignInfo design = new DesignService.DesignInfo();
            design.Category          = new DesignService.LookupInfo();
            design.Category.LookupId = 17;
            design.Category.Name     = DesignCategory.PowerKard.ToString();
            design.Status            = new DesignService.LookupInfo();
            design.Status.LookupId   = 21;
            design.Status.Name       = "Not Uploaded";
            DesignService.DesignInfo brochure = new DesignService.DesignInfo();
            brochure.Category          = new DesignService.LookupInfo();
            brochure.Category.LookupId = 18;
            brochure.Category.Name     = DesignCategory.Brochure.ToString();
            brochure.Status            = new DesignService.LookupInfo();
            brochure.Status.LookupId   = 21;
            brochure.Status.Name       = "Not Uploaded";
            List <DesignService.DesignInfo> prevDesigns =
                new List <DesignService.DesignInfo>();
            List <DesignService.DesignInfo> prevBrochures =
                new List <DesignService.DesignInfo>();

            foreach (DesignService.DesignInfo designInfo in designs)
            {
                if (designInfo.Category.LookupId == (int)DesignCategory.PowerKard)
                {
                    if (designInfo.Status.LookupId == (int)DesignStatus.Inactivated)
                    {
                        prevDesigns.Add(designInfo);
                    }
                    else
                    {
                        design = designInfo;
                    }
                }
                else
                {
                    if (designInfo.Status.LookupId == (int)DesignStatus.Inactivated)
                    {
                        prevBrochures.Add(designInfo);
                    }
                    else
                    {
                        brochure = designInfo;
                    }
                }
            }

            SetControls(design, PowerKardLengthTextBox, PowerKardWidthTextBox,
                        PowerkardHyperLink, PowerKardTypeDropDownList, PowerKardEditButton,
                        PowerKardStatusLabel);
            SetControls(brochure, BrochureLengthTextBox, BrochureWidthTextBox,
                        BrochureHyperLink, BrochureTypeDropDownList, BrochureEditButton,
                        BrochureStatusLabel);

            DesignIdHiddenField.Value   = design.DesignId.ToString();
            BrochureIdHiddenField.Value = brochure.DesignId.ToString();

            // Display previous designs.
            if (prevDesigns.Count > 0)
            {
                PreviousDesignsRow.Visible = true;
                ShowPreviousDesigns(prevDesigns, PreviousDesignsGridView, "EditDesign");
            }
            else
            {
                PreviousDesignsRow.Visible = false;
            }
            if (prevBrochures.Count > 0)
            {
                PreviousBrochuresRow.Visible = true;
                ShowPreviousDesigns(prevBrochures, PreviousBrochuresGridView, "EditBrochure");
            }
            else
            {
                PreviousBrochuresRow.Visible = false;
            }
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }