Exemple #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                processFBImage();
                dropDownRecordsPerPage.SelectedValue = "25";
            }

            if (Session["setOfData"] != null)
            {
                GridView_plexRecords.DataSource = (List <DAO_PLEXUS_DATARECORD>)Session["setOfData"];
                GridView_plexRecords.DataBind();

                hideUpload();
            }
            else
            {
                showUpload();
            }
        }
Exemple #2
0
        private void SortGridView(string sortExpression, string direction, string filter)
        {
            List <DAO_PLEXUS_DATARECORD> allRecords = (List <DAO_PLEXUS_DATARECORD>)Session["setOfData"];

            DataTable  dt            = new DataTable();
            DataColumn col_level     = new DataColumn("Level", typeof(Int32));
            DataColumn col_ambNum    = new DataColumn("AmbNum", typeof(Int32));
            DataColumn col_name      = new DataColumn("Name", typeof(String));
            DataColumn col_payLvl    = new DataColumn("PayLvl", typeof(String));
            DataColumn col_joinDate  = new DataColumn("JoinDate", typeof(DateTime));
            DataColumn col_point     = new DataColumn("Points", typeof(Int32));
            DataColumn col_cq        = new DataColumn("Cq", typeof(String));
            DataColumn col_active    = new DataColumn("Active", typeof(String));
            DataColumn col_rank      = new DataColumn("Rank", typeof(String));
            DataColumn col_cust      = new DataColumn("Customers", typeof(Int32));
            DataColumn col_pv        = new DataColumn("Pv", typeof(double));
            DataColumn col_pointspv  = new DataColumn("PointsPv", typeof(double));
            DataColumn col_welcomepv = new DataColumn("WelcomePv", typeof(double));
            DataColumn col_phone     = new DataColumn("Phone", typeof(String));
            DataColumn col_email     = new DataColumn("Email", typeof(String));
            DataColumn col_totPoints = new DataColumn("TotalPoints", typeof(Int32));

            dt.Columns.Add(col_level);
            dt.Columns.Add(col_ambNum);
            dt.Columns.Add(col_name);
            dt.Columns.Add(col_point);
            dt.Columns.Add(col_pv);
            dt.Columns.Add(col_pointspv);
            dt.Columns.Add(col_welcomepv);
            dt.Columns.Add(col_payLvl);
            dt.Columns.Add(col_joinDate);
            dt.Columns.Add(col_cq);
            dt.Columns.Add(col_active);
            dt.Columns.Add(col_rank);
            dt.Columns.Add(col_cust);
            dt.Columns.Add(col_phone);
            dt.Columns.Add(col_email);
            dt.Columns.Add(col_totPoints);

            if (allRecords == null)
            {
                return;
            }

            foreach (DAO_PLEXUS_DATARECORD rec in allRecords)
            {
                DataRow drow = dt.NewRow();
                drow[col_level]     = rec.Level;
                drow[col_ambNum]    = rec.AmbNum;
                drow[col_name]      = rec.Name;
                drow[col_payLvl]    = rec.PayLvl;
                drow[col_joinDate]  = rec.JoinDate;
                drow[col_point]     = rec.Points;
                drow[col_cq]        = rec.Cq;
                drow[col_active]    = rec.Active;
                drow[col_rank]      = rec.Rank;
                drow[col_cust]      = rec.Customers;
                drow[col_pv]        = rec.Pv;
                drow[col_phone]     = rec.Phone;
                drow[col_email]     = rec.Email;
                drow[col_totPoints] = rec.TotalPoints;
                drow[col_pointspv]  = rec.PointsPv;
                drow[col_welcomepv] = rec.WelcomePv;
                dt.Rows.Add(drow);
            }

            DataView dv = new DataView(dt);

            if (sortExpression != "-1")
            {
                dv.Sort = sortExpression + direction;
            }
            dv.RowFilter = filter;
            GridView_plexRecords.DataSource = dv;
            GridView_plexRecords.DataBind();
        }
Exemple #3
0
        private Boolean getSuccessfullCSVFile()
        {
            try
            {
                if ((FileUpload1.PostedFile != null) && (FileUpload1.PostedFile.ContentLength > 0))
                {
                    try
                    {
                        if (FileUpload1.HasFile)
                        {
                            using (Stream fileStream = FileUpload1.PostedFile.InputStream)
                                using (StreamReader sr = new StreamReader(fileStream))
                                {
                                    string idNum = null;
                                    sr.ReadLine();
                                    int numActive = 0;
                                    int totPoints = 0;
                                    Session.Add("TotalPoints", 0);
                                    plexRecords.Clear();

                                    while ((idNum = sr.ReadLine()) != null)
                                    {
                                        string[] seps   = new string[] { ",\"" };
                                        string[] myItem = idNum.Split(seps, StringSplitOptions.None);

                                        DAO_PLEXUS_DATARECORD pRecord = new DAO_PLEXUS_DATARECORD();
                                        pRecord.Level       = Int32.Parse(new String(myItem[0].ToCharArray().Where(c => Char.IsDigit(c)).ToArray()));
                                        pRecord.AmbNum      = Int32.Parse(new String(myItem[1].ToCharArray().Where(c => Char.IsDigit(c)).ToArray()));
                                        pRecord.Name        = cleanString(myItem[2].ToString());
                                        pRecord.PayLvl      = Int32.Parse(new String(myItem[7].ToCharArray().Where(c => Char.IsDigit(c)).ToArray()));
                                        pRecord.JoinDate    = DateTime.Parse(cleanString(myItem[8].ToString()));
                                        pRecord.Points      = Int32.Parse(new String(myItem[3].ToCharArray().Where(c => Char.IsDigit(c)).ToArray()));
                                        pRecord.Cq          = cleanString(myItem[9].ToString());;
                                        pRecord.Active      = cleanString(myItem[10].ToString());
                                        pRecord.Rank        = getRankValue(cleanString(myItem[11].ToString()));
                                        pRecord.Customers   = Int32.Parse(new String(myItem[12].ToCharArray().Where(c => Char.IsDigit(c)).ToArray()));
                                        pRecord.Pv          = double.Parse(cleanString(myItem[4].ToString()));
                                        pRecord.Phone       = PhoneNumber(cleanString(myItem[13].ToString()));
                                        pRecord.Email       = cleanString(myItem[14].ToString());
                                        pRecord.TotalPoints = 0;
                                        pRecord.PointsPv    = double.Parse(cleanString(myItem[5].ToString()));
                                        pRecord.WelcomePv   = double.Parse(cleanString(myItem[6].ToString()));
                                        plexRecords.Add(pRecord);

                                        if (pRecord.Active == "Y")
                                        {
                                            numActive = numActive + 1;
                                            Session["TotalActive"] = numActive;
                                        }

                                        totPoints = totPoints + pRecord.Points;
                                    }
                                    Session["setOfData"]   = plexRecords;
                                    Session["TotalPoints"] = totPoints;
                                    Session["FileName"]    = FileUpload1.PostedFile.FileName;

                                    Label_TotPoints.Text = Session["TotalPoints"].ToString();
                                    Label_FileName.Text  = Session["FileName"].ToString();
                                }
                        }
                        else
                        {
                            //Do Something here at some point
                        }
                    }
                    catch (Exception ex)
                    {
                        //Response.Write("ERROR: " + ex.Message + "<br/>" + ex.StackTrace + "<br/><br/>");
                        Response.Write("Please make sure you are uploading the \"Ambassador Genealogy Report\" that you got off of your myplexusproducts.com page<br/>");
                        Response.Write("The file MUST be exported as a CSV file<br/><br/>");
                        Response.Write("How?<br/>");
                        Response.Write("To the right of the \"PROCESS REPORT\" button change the \"Export Options\" to \"Comma-delimited (*.csv)\"");

                        //Note: Exception.Message returns a detailed message that describes the current exception.
                        //For security reasons, we do not recommend that you return Exception.Message to end users in
                        //production environments. It would be better to return a generic error message.
                    }
                    finally
                    {
                        try
                        {
                            //string SaveLocation = Server.MapPath("Data") + "\\" + fn;
                            //File1.PostedFile.SaveAs(SaveLocation);
                            Response.Write("The file has been uploaded and processed.");
                            GridView_plexRecords.DataSource = (List <DAO_PLEXUS_DATARECORD>)Session["setOfData"];
                            GridView_plexRecords.DataBind();
                        }
                        catch (Exception ex)
                        {
                            Response.Write("Error: " + ex.Message);
                            //Note: Exception.Message returns a detailed message that describes the current exception.
                            //For security reasons, we do not recommend that you return Exception.Message to end users in
                            //production environments. It would be better to return a generic error message.
                        }
                        //conn.Close();
                    }
                    return(true);
                }
                else
                {
                    Response.Write("Please select a file to upload.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Response.Write("Houston we have a problem: " + ex.Message);
                return(false);
            }
        }