Exemplo n.º 1
0
        private void LoadInventory()
        {
            List <StockInventoryItem> lstKVA = new List <StockInventoryItem>();
            List <StockVoltages>      lstStockVoltages;

            rblWindings.Items.Clear();
            rblWindings.DataSource = StockInventoryItem.GetAllItems().Select(r => r.Windings).Distinct().ToList().OrderBy(e => e);
            rblWindings.DataBind();
            rblWindings.SelectedIndex = 0;

            ddVoltage.Items.Clear();

            lstStockVoltages = StockVoltages.GetAllItems().Where(s => s.Windings == rblWindings.Items[0].Text).ToList();
            lstStockVoltages.Insert(0, new StockVoltages());
            ddVoltage.DataSource     = lstStockVoltages;
            ddVoltage.DataTextField  = "StockVoltageDisplay";
            ddVoltage.DataValueField = "StockVoltage";
            ddVoltage.DataBind();

            ddKVA.Items.Clear();
            lstKVA.Insert(0, new StockInventoryItem());
            ddKVA.DataSource     = lstKVA;
            ddKVA.DataTextField  = "sKVA";
            ddKVA.DataValueField = "KVA";
            ddKVA.DataBind();
        }
Exemplo n.º 2
0
        private bool DownloadInventoryCSV()
        {
            int    iInternal       = Convert.ToInt32(Session["Internal"]);
            string sRepID          = Session["RepID"].ToString();
            int    iAgentNo        = Utility.GetAgentNoFromRepID(Convert.ToInt32(sRepID));
            bool   bAll            = rbAllAgentInventory.Checked;
            bool   bSearch         = rbSearchAvailability.Checked;
            bool   bAgent          = rbSelectAgentInventory.Checked;
            string sKVA            = ddKVA.SelectedItem.Text == "ALL" ? "0" : ddKVA.SelectedItem.Text;
            string sCategory       = StockVoltages.GetCategory(ddVoltage.SelectedItem.Text, rblWindings.SelectedItem.Text);
            string sWinding        = rblWindings.SelectedItem.Text == "Aluminum" ? "Al" : "Cu";
            string sAgentWarehouse = ddlAgentsWithWarehouse.SelectedItem.Text;

            InventoryReportCSV irCDV = new InventoryReportCSV(iInternal, sRepID, iAgentNo, bAll, bSearch, bAgent,
                                                              sKVA, sCategory, sWinding, sAgentWarehouse, Response, false);

            return(irCDV.DownloadInventoryCSV());
        }
Exemplo n.º 3
0
        protected void rblWindings_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <StockInventoryItem> lstKVA = new List <StockInventoryItem>();
            List <StockVoltages>      lstStockVltgs;

            ddVoltage.Items.Clear();
            lstStockVltgs = StockVoltages.GetAllItems().Where(s => s.Windings == rblWindings.Items[rblWindings.SelectedIndex].Text).ToList();
            lstStockVltgs.Insert(0, new StockVoltages());
            ddVoltage.DataSource     = lstStockVltgs;
            ddVoltage.DataTextField  = "StockVoltageDisplay";
            ddVoltage.DataValueField = "StockVoltage";
            ddVoltage.DataBind();


            ddKVA.Items.Clear();
            lstKVA.Insert(0, new StockInventoryItem());
            ddKVA.DataSource     = lstKVA;
            ddKVA.DataTextField  = "sKVA";
            ddKVA.DataValueField = "KVA";
            ddKVA.DataSource     = lstKVA;
            ddKVA.DataBind();

            lblNoInventoryData.Text = "";
        }
Exemplo n.º 4
0
        /// <summary>
        /// Preview the selected report with the selected options.
        /// </summary>
        /// <param name="sTarget"></param>
        protected void Preview(string sTarget)
        {
            string sRptName   = "";
            string sUserName  = Session["UserName"].ToString();
            string sAgentName = "";
            int    iInternal  = Convert.ToInt32(Session["Internal"]);
            string sAgent     = "";
            string sAgentCode = "";
            string sError;

            if (sTarget == "Performance")
            {
                sRptName = "PerformancePDF";
            }
            else if (sTarget == "Gift Card")
            {
                sRptName = "GiftCardPromotionPDF";
            }
            else if (sTarget == "Agent Stock Prices")
            {
                sRptName = "AgentStockPricesPDF";
            }
            else if (sTarget == "Pending Approvals")
            {
                sRptName = "AdminPendingApprovals";
            }
            else if (sTarget == "M1 Customer Sales")
            {
                sRptName = "M1CustSales";
            }

            else if (sTarget == "Quote Status")
            {
                sRptName = "QuoteStatusPDF";
            }
            else if (sTarget == "Inventory")
            {
                sRptName = "InventoryPDF";
            }
            else if (sTarget == "Agent Dashboard")
            {
                sRptName = "AgentDashboard";
            }
            else
            {
                return;
            }

            string sRedirect = "";

            if (pnlCriteria.Visible == true)
            {
                if (ValidateDateRange() == true)
                {
                    string sRepID = "";
                    // 0 = Current Rep - Always this choice if not Admin.
                    if (rblAll.SelectedValue == "0" || rblAll.Visible == false)
                    {
                        sRepID = Session["RepID"].ToString();
                    }
                    // 1 = All Reps.
                    else
                    {
                        sRepID = "0";
                    }

                    string sDateFrom = txtFrom.Text.ToString();
                    string sDateTo   = txtTo.Text.ToString();

                    if (sTarget == "M1 Customer Sales")
                    {
                        string sProductCat = rblProductCat.SelectedValue;

                        if (ddlAgents.Visible == true)
                        {
                            sRepID = ddlAgents.SelectedValue;
                        }
                        else
                        {
                            sRepID = Session["MGMAgentNo"].ToString();
                        }

                        sRepID = string.IsNullOrEmpty(sRepID) ? "-1" : sRepID;
                        lblAgentReqd.Visible = false;

                        // If no rep selected, show Agent required and exit.
                        if (sRepID == "-1")
                        {
                            lblAgentReqd.Visible = true;
                            return;
                        }

                        sRedirect = "~/" + sRptName + ".aspx?AgentNo=" + sRepID + "&DateFrom=" + sDateFrom +
                                    "&DateTo=" + sDateTo + "&ProductCat=" + sProductCat;
                    }
                    else if (sTarget == "Performance")
                    {
                        sRedirect = "~/" + sRptName + ".aspx?DateFrom=" + sDateFrom +
                                    "&DateTo=" + sDateTo + "&RepID=" + sRepID + "&UserName="******"Quote Status")
                    {
                        sRedirect = "~/" + sRptName + ".aspx?DateFrom=" + sDateFrom +
                                    "&DateTo=" + sDateTo + "&UserName="******"Inventory")
                    {
                        if (ddlAgentsWithWarehouse.Visible == true)
                        {
                            sRepID = ddlAgentsWithWarehouse.SelectedValue;
                        }
                        else
                        {
                            sRepID = "-1";// Session["MGMAgentNo"].ToString();
                        }


                        if (rbSelectAgentInventory.Checked)
                        {
                            sRepID = string.IsNullOrEmpty(sRepID) ? "-1" : sRepID;
                            lblAgentReqd.Visible = false;

                            // If no rep selected, show Agent required and exit.
                            if (sRepID == "-1")
                            {
                                lblAgentReqd.Visible = true;
                                return;
                            }
                        }

                        sAgentName = ddlAgentsWithWarehouse.Items[ddlAgentsWithWarehouse.SelectedIndex].ToString();


                        sRedirect = "~/" + sRptName + ".aspx?Agent=" + sRepID + "&Name=" + Server.UrlEncode(sAgentName) + "&All=" +
                                    (rbAllAgentInventory.Checked ? "true" : "false") + "&KVA=0&VoltageCat=ALL&VoltageDisp=&Windings=&Searching=false";


                        if (rbSearchAvailability.Checked)
                        {
                            sRedirect = "~/" + sRptName + ".aspx?Agent=" + sRepID + "&Name=" + Server.UrlEncode(sAgentName) +
                                        "&All=true&KVA=" + (ddKVA.SelectedItem.Text == "ALL" ? "0" : ddKVA.SelectedItem.Text) +
                                        "&VoltageCat=" + StockVoltages.GetCategory(ddVoltage.SelectedItem.Text, rblWindings.SelectedItem.Text) +
                                        "&VoltageDisp=" + ddVoltage.SelectedItem.Text +
                                        "&Windings=" + (rblWindings.SelectedItem.Text == "Aluminum" ? "Al" : "Cu") +
                                        "&Searching=true";
                        }
                    }
                    else if (sTarget == "Agent Dashboard")
                    {
                        int _iStartDate = Convert.ToInt32(ddlDistributorDashboardFromYear.SelectedItem.ToString());
                        int _iEndDate   = Convert.ToInt32(ddlDistributorDashboardToYear.SelectedItem.ToString());

                        if (_iEndDate - _iStartDate + 1 > 6)
                        {
                            lblNotEnoughDataDashboard.Text = "Maximum 6 Years Time Span.";
                            return;
                        }

                        if (Convert.ToInt32(Session["Internal"]) == 1)
                        {
                            sAgent = Agent.GetAgentCode(Convert.ToInt32(ddlAgents.SelectedItem.Value), ddlAgents.SelectedItem.Text);
                        }
                        else
                        {
                            sAgent = Agent.GetAgentCode(Agent.GetMGMAgentNo(Session["RepName"].ToString()), Session["RepName"].ToString());
                        }

                        if (sAgent == "")
                        {
                            lblNotEnoughDataDashboard.Text = "Agent information not found.";
                            return;
                        }


                        sAgentName = Session["RepName"].ToString();

                        if (ddlAgents.Visible)
                        {
                            if ((ddlAgents.SelectedItem.Value == "-1") && (iInternal == 1))
                            {
                                lblInventoryExternal.ForeColor = System.Drawing.Color.Red;
                                lblInventoryExternal.Text      = "Agent Required";
                                lblInventoryExternal.Visible   = true;
                                return;
                            }

                            sAgent     = ddlAgents.SelectedItem.Value;
                            sAgentName = ddlAgents.SelectedItem.Text;
                        }

                        if (Convert.ToInt32(Session["Internal"]) == 1)
                        {
                            sAgentCode = Agent.GetAgentCode(Convert.ToInt32(sAgent), ddlAgents.SelectedItem.Text);
                        }
                        else
                        {
                            sAgentCode = Agent.GetAgentCode(Convert.ToInt32(sAgent), sAgentName);
                        }


                        AgentDashboardPDF adPDF = new AgentDashboardPDF(new DateTime(Convert.ToInt32(ddlDistributorDashboardFromYear.SelectedItem.ToString()), 1, 1),
                                                                        new DateTime(Convert.ToInt32(ddlDistributorDashboardToYear.SelectedItem.ToString()), 12, 31),
                                                                        sAgentName == "All Agents" ? "All Agents" : sAgentCode, sAgentName, sAgent, "");

                        if (!adPDF.IsThereData)
                        {
                            lblNotEnoughDataDashboard.Text = "Not enough Data to generate Dashboard";
                            return;
                        }
                        else
                        {
                            if (WebConfigurationManager.AppSettings["SaveAgentDashboard"] != null &&
                                WebConfigurationManager.AppSettings["SaveAgentDashboard"].ToString() == "1")
                            {
                                string sURL = "Agent Dashboard - [" + sAgentName.Replace("&", "and") + "," + ddlDistributorDashboardFromYear.SelectedItem.ToString() + "," +
                                              ddlDistributorDashboardToYear.SelectedItem.ToString() + "]" + ".pdf";
                                sURL = sURL.Replace("&", "and");

                                if (WebConfigurationManager.AppSettings["LocalMachine"] != null &&
                                    Convert.ToBoolean(WebConfigurationManager.AppSettings["LocalMachine"]) == true)
                                {
                                    if (WebConfigurationManager.AppSettings["LocalMachinePath"] == null)
                                    {
                                        lblDSRNoResults.Text = "No Path Setting";
                                        return;
                                    }

                                    adPDF.FileName = WebConfigurationManager.AppSettings["LocalMachinePath"] + sURL;
                                    adPDF.CreatePDF(out sError);


                                    if (WebConfigurationManager.AppSettings["LocalWebSiteURL"] == null)
                                    {
                                        lblDSRNoResults.Text = "Redirect Failed.";
                                        return;
                                    }
                                    ResponseHelper.Redirect(WebConfigurationManager.AppSettings["LocalWebSiteURL"] + sURL, "_blank", "");
                                }
                                else
                                {
                                    adPDF.FileName = "C:\\MGMQuotation\\pdfs\\" + sURL;
                                    adPDF.CreatePDF(out sError);
                                    ResponseHelper.Redirect("https://MGMQuotation.MGMTransformer.com//MGMQuotation//pdfs//" + sURL, "_blank", "");
                                }
                            }
                            else
                            {
                                sRedirect = "~/" + sRptName + ".aspx?YearFrom=" + ddlDistributorDashboardFromYear.SelectedItem.ToString() +
                                            "&YearTo=" + ddlDistributorDashboardToYear.SelectedItem.ToString() + "&AgentNo=" + sAgent +
                                            "&AgentName=" + sAgentName.Replace("&", "88");
                            }
                        }
                    }
                    else
                    {
                        sRedirect = "~/" + sRptName + ".aspx?DateFrom=" + sDateFrom +
                                    "&DateTo=" + sDateTo + "&RepID=" + sRepID;
                    }
                }
            }
            else
            {
                sRedirect = "~/" + sRptName + ".aspx";
            }

            // open PDF.
            ResponseHelper.Redirect(sRedirect, "_blank", "");
        }