private void PopulateTreeView(int parentId, TreeNode treeNode) { foreach (var pair in treeNodeRelationship.Where(x => x.Value == parentId)) { var key = pair.Key; var value = pair.Value; DAO_PLEXUS_DATARECORD dr = plexRecords.Find(x => x.AmbNum == key); TreeNode child = new TreeNode { Text = dr.AmbNum.ToString(), Value = dr.AmbNum.ToString() }; if (parentId == -1) { myTree.Nodes.Add(child); PopulateTreeView(int.Parse(child.Value), child); } else { treeNode.ChildNodes.Add(child); PopulateTreeView(int.Parse(child.Value), child); } } }
private int getAccuratePayPoints(int ambNum) { int parentAmbNum = ambNum; int runningPoints = 0; DAO_PLEXUS_DATARECORD parentAmbN = plexRecords.Find(x => x.AmbNum == ambNum); foreach (int childAmbNum in lookDown(ambNum)) { DAO_PLEXUS_DATARECORD dr = plexRecords.Find(x => x.AmbNum == childAmbNum); int inContextPayLevel = dr.PayLvl - parentAmbN.PayLvl; int inContextLevel = dr.Level - parentAmbN.Level; if (dr.PointsPv >= 100) { runningPoints = runningPoints + payPoints(inContextPayLevel); } //if ((dr.Points != 0) && (dr.Level <= 7)) //{ // //runningPoints = runningPoints + payPoints(getAccuratePayLevel(childAmbNum, ambNum)); // runningPoints = runningPoints + payPoints(inContextPayLevel); //} //else if ((dr.Pv > 100) && (dr.Level > 7) && (dr.Pv != 199.00)) //{ // //runningPoints = runningPoints + payPoints(getAccuratePayLevel(childAmbNum, ambNum)); // runningPoints = runningPoints + payPoints(inContextPayLevel); //} } return(runningPoints); }
private void PopulateTreeView(int parentId, TreeNode treeNode) { foreach (var pair in treeNodeRelationship.Where(x => x.Value == parentId)) { var key = pair.Key; var value = pair.Value; DAO_PLEXUS_DATARECORD dr = plexRecords.Find(x => x.AmbNum == key); TreeNode child = new TreeNode { Text = getColorForTreeNode(dr) + "<B>" + dr.Name + " (" + dr.Level + ")</B> PV: $" + String.Format("{0:0.00}", dr.Pv.ToString("0.00")) + " PointsPV: $" + String.Format("{0:0.00}", dr.PointsPv.ToString("0.00")) + " WelcomePV: $" + String.Format("{0:0.00}", dr.WelcomePv.ToString("0.00")) + " Join: " + dr.JoinDate.ToShortDateString() + " Total Points: " + dr.TotalPoints + "</span>", Value = dr.AmbNum.ToString() }; if (parentId == -1) { TreeView_plexTree.Nodes.Add(child); PopulateTreeView(int.Parse(child.Value), child); } else { treeNode.ChildNodes.Add(child); PopulateTreeView(int.Parse(child.Value), child); } } }
private string getColorForTreeNode(DAO_PLEXUS_DATARECORD dr) { //#36dbca = Active //#93db70 = New if (IsTheSameMonth(dr.JoinDate)) { return("<span style='background-color: #93db70;'>"); } else if (dr.Active == "Y") { return("<span style='background-color: #36dbca;'>"); } return("<span>"); }
private Boolean recursivePayLevelEngine(int childAmbNum, int parentAmbNum) { List <int> tmp = new List <int>(); foreach (var pair in treeNodeRelationship.Where(x => x.Value == parentAmbNum)) { var key = pair.Key; var value = pair.Value; DAO_PLEXUS_DATARECORD dr = plexRecords.Find(x => x.AmbNum == key); //if (dr.Pv >= 100) tmp.Add(key); } if (tmp.Contains(childAmbNum)) { foundIt = true; } else { currentlevel = currentlevel + 1; foreach (int child in tmp) { foundIt = recursivePayLevelEngine(childAmbNum, child); if (!foundIt) { currentlevel = currentlevel - 1; } else { DAO_PLEXUS_DATARECORD dr = plexRecords.Find(x => x.AmbNum == child); if (dr.Pv < 100) { compressLevel = compressLevel + 1; } return(foundIt); } } } return(foundIt); }
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); } }
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; } }
private string getColorForTreeNode(DAO_PLEXUS_DATARECORD dr) { //#36dbca = Active //#93db70 = New if (IsTheSameMonth(dr.JoinDate)) { return "<span style='background-color: #93db70;'>"; } else if (dr.Active == "Y") { return "<span style='background-color: #36dbca;'>"; } return "<span>"; }