protected void btnClear_Click(object sender, EventArgs e) { checkLogin(); int consultantID = Convert.ToInt32(Request.QueryString["agent"]); ConsultationCard oldCard = _myConsultationCardManager.FindCard(consultantID); ConsultationCard currentCard = oldCard; currentCard.EmployeeID = consultantID; currentCard.Communication = 0; currentCard.Competitors = 0; currentCard.Goals = 0; currentCard.Growth = 0; currentCard.Headcount = 0; currentCard.Market = 0; currentCard.Rapport = 0; currentCard.Recommended = 0; currentCard.Term = 0; currentCard.Website = 0; currentCard.TotalEntries = 0; _myConsultationCardManager.UpdateConsultationCard(oldCard, currentCard); ConsultationSheet currentSheet = _myConsultationCardManager.SelectCurrentConsultationSheet(consultantID); ConsultationSheet updatedSheet = currentSheet; updatedSheet.completedDate = "1/1/2000 12:00:00"; _myConsultationCardManager.CloseCardSheet(currentSheet, updatedSheet); _myConsultationCardManager.CreateNewCardSheet(consultantID); Response.Redirect(Request.RawUrl); }
public static int UpdateConsultationEntries(ConsultationCard oldC, ConsultationCard newC) { int rowsAffected = 0; var conn = DatabaseConnection.GetExEventDatabaseConnection(); var cmdText = "spUpdateEntries"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@employee_id", newC.EmployeeID); cmd.Parameters.AddWithValue("@total_entries", newC.TotalEntries); cmd.Parameters.AddWithValue("@lifetime_entries", newC.LifetimeEntries); cmd.Parameters.AddWithValue("@original_employee_id", oldC.EmployeeID); cmd.Parameters.AddWithValue("@original_total_entries", oldC.TotalEntries); cmd.Parameters.AddWithValue("@original_lifetime_entries", oldC.LifetimeEntries); try { conn.Open(); rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new ApplicationException("Concurrency Exception:Your record has been changed by another user. Please refresh and try again."); } } catch (Exception) { throw; } return(rowsAffected); }
public void UpdateConsultationEntries(ConsultationCard oldC, ConsultationCard newC) { try { ConsultationAccessor.UpdateConsultationEntries(oldC, newC); } catch (Exception) { throw; } }
public void CreateConsultationCard(ConsultationCard newC) { try { ConsultationAccessor.CreateConsultationCard(newC); } catch (Exception) { throw; } }
public void addEntry(int empID) { ConsultationCard currentCard = _myConsultationCardManager.FindCard(empID); ConsultationCard newCard = currentCard; newCard.TotalEntries += 1; newCard.LifetimeEntries += 1; newCard.Communication = 0; newCard.Competitors = 0; newCard.Goals = 0; newCard.Growth = 0; newCard.Headcount = 0; newCard.Market = 0; newCard.Rapport = 0; newCard.Recommended = 0; newCard.Term = 0; newCard.Website = 0; _myConsultationCardManager.UpdateConsultationCard(currentCard, newCard); }
public static int CreateConsultationCard(ConsultationCard newC) { int rowsAffected = 0; var conn = DatabaseConnection.GetExEventDatabaseConnection(); var cmdText = "spCreateConsultationCard"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@employee_id", newC.EmployeeID); cmd.Parameters.AddWithValue("@communication_request_date", newC.CommunicationRequestDate); cmd.Parameters.AddWithValue("@competitors_request_date", newC.CompetitorsRequestDate); cmd.Parameters.AddWithValue("@goals_request_date", newC.GoalsRequestDate); cmd.Parameters.AddWithValue("@growth_request_date", newC.GrowthRequestDate); cmd.Parameters.AddWithValue("@headcount_request_date", newC.HeadcountRequestDate); cmd.Parameters.AddWithValue("@market_request_date", newC.MarketRequestDate); cmd.Parameters.AddWithValue("@rapport_request_date", newC.RapportRequestDate); cmd.Parameters.AddWithValue("@recommended_request_date", newC.RecommendedRequestDate); cmd.Parameters.AddWithValue("@term_request_date", newC.TermRequestDate); cmd.Parameters.AddWithValue("@website_request_date", newC.WebsiteRequestDate); try { conn.Open(); rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new ApplicationException("Concurrency Exception:Your record has been changed by another user. Please refresh and try again."); } } catch (Exception) { throw; } return(rowsAffected); }
private void createEmployee() { //check for empty form fields if (txtFirstName.Text != "" && txtLastName.Text != "" && txtUsername.Text != "" && txtEmailAddress.Text != "") { string roleName = listRole.SelectedValue; string departmentName = listDepartment.SelectedValue; int supervisorID = Convert.ToInt32(listLeader.SelectedValue); string firstName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(txtFirstName.Text); string lastName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(txtLastName.Text); string username = txtUsername.Text; string password1 = txtPassword.Text; string password2 = txtPassword2.Text; string emailAddress = txtEmailAddress.Text; //make sure passwords match if (password1.Equals(password2)) { if (_myEmployeeManager.isValidPassword(password1) == true) { string pwdHash = _myEmployeeManager.GeneratePasswordHash(password1); try { //retrieve info for reporting supervisor/lead BusinessObjects.Employee currentSup = _myEmployeeManager.FindSingleEmployee(supervisorID); string supervisorFirstName = currentSup.FirstName; string supervisorLastName = currentSup.LastName; try { //check to see if username is taken BusinessObjects.Employee checkUsername = _myEmployeeManager.FindEmployee(username); if (checkUsername.Username != null) { System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('Username already exists');", true); } Response.End(); } catch (Exception) { } //create new employee BusinessObjects.Employee newEmployee = new BusinessObjects.Employee(); newEmployee.RoleName = roleName; newEmployee.DepartmentName = departmentName; newEmployee.SupervisorFirstName = supervisorFirstName; newEmployee.SupervisorLastName = supervisorLastName; newEmployee.FirstName = firstName; newEmployee.LastName = lastName; newEmployee.Username = username; newEmployee.Password = pwdHash; newEmployee.EmailAddress = emailAddress; try { //add new employee to db _myEmployeeManager.AddNewEmployee(newEmployee); Employee newEmp = _myEmployeeManager.FindEmployee(newEmployee.Username); ConsultationCard newCard = new ConsultationCard(); newCard.EmployeeID = newEmp.EmployeeID; newCard.CommunicationRequestDate = "1/1/1900 12:00:00"; newCard.CompetitorsRequestDate = "1/1/1900 12:00:00"; newCard.GoalsRequestDate = "1/1/1900 12:00:00"; newCard.GrowthRequestDate = "1/1/1900 12:00:00"; newCard.HeadcountRequestDate = "1/1/1900 12:00:00"; newCard.MarketRequestDate = "1/1/1900 12:00:00"; newCard.RapportRequestDate = "1/1/1900 12:00:00"; newCard.RecommendedRequestDate = "1/1/1900 12:00:00"; newCard.TermRequestDate = "1/1/1900 12:00:00"; newCard.WebsiteRequestDate = "1/1/1900 12:00:00"; _myConsultationCardManager.CreateConsultationCard(newCard); _myConsultationCardManager.CreateNewCardSheet(newEmp.EmployeeID); try { //attempt to auto log in new user account Employee loginEmployee = _myEmployeeManager.FindEmployee(username); Session["loggedInUser"] = loginEmployee; //set flag for agentview page to identify a new user was created. Session["newUser"] = "******"; } catch (Exception) { } } catch (Exception) { } } catch (Exception) { } //System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('User Created Successfully.');", true); //Employee redirectCheck = Employee(Session["loggedInUser"]); Employee checkRedirect = (Employee)Session["loggedInUser"]; if (checkRedirect.RoleName == "Manager") { Response.Redirect("ManagerView.aspx"); } else { Response.Redirect("AgentView.aspx"); } } else { System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('Password must contain at least one uppercase, one lowercase, one number, and one special character.');", true); } } else { System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('Passwords do not match.');", true); } } else { System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('All fields required!');", true); } }
public void updateCard(string a, string c, int empID) { ConsultationCard oldCard = _myConsultationCardManager.FindCard(empID); ConsultationCard updatedCard = oldCard; if (a == "Add") { lblCard.Text = c; lblAgent.Text = empID.ToString(); switch (c) { case "Communication": if (oldCard.CommunicationRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; case "Competitors": if (oldCard.CompetitorsRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; case "Goals": if (oldCard.GoalsRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; case "Growth": if (oldCard.GrowthRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; case "Headcount": if (oldCard.HeadcountRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; case "Market": if (oldCard.MarketRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; case "Rapport": if (oldCard.RapportRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; case "Recommended": if (oldCard.RecommendedRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; case "Term": if (oldCard.TermRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; case "Website": if (oldCard.WebsiteRequestDate != "1/1/1900 12:00:00 PM") { lblRequested.Text = "true"; } else { lblRequested.Text = "false"; } break; } //updatedCard.RequestDate = "1/1/1900 12:00:00"; //_myConsultationCardManager.UpdateConsultationCard(oldCard, updatedCard); //Employee currentEmp = _myEmployeeManager.FindSingleEmployee(updatedCard.EmployeeID); //SendMail(currentEmp.FirstName, c, currentEmp.EmailAddress); //if (updatedCard.Communication == 1 && updatedCard.Competitors == 1 && updatedCard.Goals == 1 && updatedCard.Growth == 1 && updatedCard.Headcount == 1 && updatedCard.Market == 1 && updatedCard.Rapport == 1 && updatedCard.Recommended == 1 && updatedCard.Term == 1 && updatedCard.Website == 1) //{ // int consultantID = Convert.ToInt32(Request.QueryString["agent"]); // addEntry(consultantID); // SendEntryMail(currentEmp.FirstName, currentEmp.EmailAddress); //Response.Redirect(Request.RawUrl); ScriptManager.RegisterStartupScript(this, GetType(), "showModalPopUp", "showModalPopUp();", true); } else if (a == "Remove" || a == "Reject") { switch (c) { case "Communication": updatedCard.Communication = 0; updatedCard.CommunicationRequestDate = "1/1/1900 12:00:00"; break; case "Competitors": updatedCard.Competitors = 0; updatedCard.CompetitorsRequestDate = "1/1/1900 12:00:00"; break; case "Goals": updatedCard.Goals = 0; updatedCard.GoalsRequestDate = "1/1/1900 12:00:00"; break; case "Growth": updatedCard.Growth = 0; updatedCard.GrowthRequestDate = "1/1/1900 12:00:00"; break; case "Headcount": updatedCard.Headcount = 0; updatedCard.HeadcountRequestDate = "1/1/1900 12:00:00"; break; case "Market": updatedCard.Market = 0; updatedCard.MarketRequestDate = "1/1/1900 12:00:00"; break; case "Rapport": updatedCard.Rapport = 0; updatedCard.RapportRequestDate = "1/1/1900 12:00:00"; break; case "Recommended": updatedCard.Recommended = 0; updatedCard.RecommendedRequestDate = "1/1/1900 12:00:00"; break; case "Term": updatedCard.Term = 0; updatedCard.TermRequestDate = "1/1/1900 12:00:00"; break; case "Website": updatedCard.Website = 0; updatedCard.WebsiteRequestDate = "1/1/1900 12:00:00"; break; } _myConsultationCardManager.UpdateConsultationCard(oldCard, updatedCard); if (a == "Remove") { ConsultationSheet currentSheet = _myConsultationCardManager.SelectCurrentConsultationSheet(empID); _myConsultationCardManager.RemoveCard(currentSheet.sheetID, c); } Response.Redirect(Request.RawUrl); } else if (a == "Request") { switch (c) { case "Communication": updatedCard.Communication = 2; updatedCard.CommunicationRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case "Competitors": updatedCard.Competitors = 2; updatedCard.CompetitorsRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case "Goals": updatedCard.Goals = 2; updatedCard.GoalsRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case "Growth": updatedCard.Growth = 2; updatedCard.GrowthRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case "Headcount": updatedCard.Headcount = 2; updatedCard.HeadcountRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case "Market": updatedCard.Market = 2; updatedCard.MarketRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case "Rapport": updatedCard.Rapport = 2; updatedCard.RapportRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case "Recommended": updatedCard.Recommended = 2; updatedCard.RecommendedRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case "Term": updatedCard.Term = 2; updatedCard.TermRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; case "Website": updatedCard.Website = 2; updatedCard.WebsiteRequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; } _myConsultationCardManager.UpdateConsultationCard(oldCard, updatedCard); Response.Redirect(Request.RawUrl); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["loggedInUser"] != null) { Employee loggedInEmployee = Session["loggedInUser"] as Employee; int consultantID = Convert.ToInt32(Request.QueryString["agent"]); ConsultationCard currentConsultantCard = _myConsultationCardManager.FindCard(consultantID); Employee currentConsultant = _myEmployeeManager.FindSingleEmployee(consultantID); if (!IsPostBack) { lblConsultantName.Text += (currentConsultant.FirstName + " " + currentConsultant.LastName); } TableRow tRow1 = new TableRow(); agentCardViewTable.Rows.Add(tRow1); TableCell communication = new TableCell(); communication.Text = string.Format("<img src=./images/full-communication" + currentConsultantCard.Communication + ".png title='How are they communicating in the office? How do they communicate with customers? How do customers communicate with them?'/>"); tRow1.Controls.Add(communication); TableCell competitors = new TableCell(); competitors.Text = string.Format("<img src=./images/full-competitors" + currentConsultantCard.Competitors + ".png title='Who is the local competition? Who is the national competition? What are their competitors doing right? What makes them better than the competitors?'/>"); tRow1.Controls.Add(competitors); TableCell goals = new TableCell(); goals.Text = string.Format("<img src=./images/full-goals" + currentConsultantCard.Goals + ".png title='What is their goal for this year? What is their 5 year goal? What are they trying to do with the business currently?'/>"); tRow1.Controls.Add(goals); TableCell growth = new TableCell(); growth.Text = string.Format("<img src=./images/full-growth" + currentConsultantCard.Growth + ".png title='How big would they like the company to be? Are they currently hiring? How quickly are they growing?'/>"); tRow1.Controls.Add(growth); TableCell headcount = new TableCell(); headcount.Text = string.Format("<img src=./images/full-headcount" + currentConsultantCard.Headcount + ".png title='How many employee are their? How many customers do they work with daily? How many customers would they like to have?'/>"); tRow1.Controls.Add(headcount); TableRow tRow1c = new TableRow(); agentCardViewTable.Rows.Add(tRow1c); TableRow tRow1b = new TableRow(); agentCardViewTable.Rows.Add(tRow1b); Button communicationButton = new Button(); communicationButton.Click += new EventHandler(communicationButton_Click); string btnText = checkPropertyValue(currentConsultantCard.Communication, loggedInEmployee.RoleName); communicationButton.Text = btnText; TableCell communicationButtonCell = new TableCell(); communicationButtonCell.Controls.Add(communicationButton); Button communicationRequestButton = new Button(); communicationRequestButton.Click += new EventHandler(communicationButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Communication == 1 || currentConsultantCard.Communication == 2) { communicationButtonCell.Controls.Remove(communicationButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Communication == 2) { communicationRequestButton.Text = "Reject"; communicationButtonCell.Controls.Add(communicationRequestButton); } } tRow1b.Controls.Add(communicationButtonCell); TableCell communicationRequestDate = new TableCell(); if (currentConsultantCard.Communication == 2) { communicationRequestDate.Text = currentConsultantCard.CommunicationRequestDate; } else { communicationRequestDate.Text = ""; } tRow1c.Controls.Add(communicationRequestDate); Button competitorsButton = new Button(); competitorsButton.Click += new EventHandler(competitorsButton_Click); btnText = checkPropertyValue(currentConsultantCard.Competitors, loggedInEmployee.RoleName); competitorsButton.Text = btnText; TableCell competitorsButtonCell = new TableCell(); competitorsButtonCell.Controls.Add(competitorsButton); Button competitorsRequestButton = new Button(); competitorsRequestButton.Click += new EventHandler(competitorsButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Competitors == 1 || currentConsultantCard.Competitors == 2) { competitorsButtonCell.Controls.Remove(competitorsButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Competitors == 2) { competitorsRequestButton.Text = "Reject"; competitorsButtonCell.Controls.Add(competitorsRequestButton); } } tRow1b.Controls.Add(competitorsButtonCell); TableCell competitorsRequestDate = new TableCell(); if (currentConsultantCard.Competitors == 2) { competitorsRequestDate.Text = currentConsultantCard.CompetitorsRequestDate; } else { competitorsRequestDate.Text = ""; } tRow1c.Controls.Add(competitorsRequestDate); Button goalsButton = new Button(); goalsButton.Click += new EventHandler(goalsButton_Click); btnText = checkPropertyValue(currentConsultantCard.Goals, loggedInEmployee.RoleName); goalsButton.Text = btnText; TableCell goalsButtonCell = new TableCell(); goalsButtonCell.Controls.Add(goalsButton); Button goalsRequestButton = new Button(); goalsRequestButton.Click += new EventHandler(goalsButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Goals == 1 || currentConsultantCard.Goals == 2) { goalsButtonCell.Controls.Remove(goalsButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Goals == 2) { goalsRequestButton.Text = "Reject"; goalsButtonCell.Controls.Add(goalsRequestButton); } } tRow1b.Controls.Add(goalsButtonCell); TableCell goalsRequestDate = new TableCell(); if (currentConsultantCard.Goals == 2) { goalsRequestDate.Text = currentConsultantCard.GoalsRequestDate; } else { goalsRequestDate.Text = ""; } tRow1c.Controls.Add(goalsRequestDate); Button growthButton = new Button(); growthButton.Click += new EventHandler(growthButton_Click); btnText = checkPropertyValue(currentConsultantCard.Growth, loggedInEmployee.RoleName); growthButton.Text = btnText; TableCell growthButtonCell = new TableCell(); growthButtonCell.Controls.Add(growthButton); Button growthRequestButton = new Button(); growthRequestButton.Click += new EventHandler(growthButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Growth == 1 || currentConsultantCard.Growth == 2) { growthButtonCell.Controls.Remove(growthButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Growth == 2) { growthRequestButton.Text = "Reject"; growthButtonCell.Controls.Add(growthRequestButton); } } tRow1b.Controls.Add(growthButtonCell); TableCell growthRequestDate = new TableCell(); if (currentConsultantCard.Growth == 2) { growthRequestDate.Text = currentConsultantCard.GrowthRequestDate; } else { growthRequestDate.Text = ""; } tRow1c.Controls.Add(growthRequestDate); Button headcountButton = new Button(); headcountButton.Click += new EventHandler(headcountButton_Click); btnText = checkPropertyValue(currentConsultantCard.Headcount, loggedInEmployee.RoleName); headcountButton.Text = btnText; TableCell headcountButtonCell = new TableCell(); headcountButtonCell.Controls.Add(headcountButton); Button headcountRequestButton = new Button(); headcountRequestButton.Click += new EventHandler(headcountButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Headcount == 1 || currentConsultantCard.Headcount == 2) { headcountButtonCell.Controls.Remove(headcountButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Headcount == 2) { headcountRequestButton.Text = "Reject"; headcountButtonCell.Controls.Add(headcountRequestButton); } } tRow1b.Controls.Add(headcountButtonCell); TableCell headcountRequestDate = new TableCell(); if (currentConsultantCard.Headcount == 2) { headcountRequestDate.Text = currentConsultantCard.HeadcountRequestDate; } else { headcountRequestDate.Text = ""; } tRow1c.Controls.Add(headcountRequestDate); TableRow tRow2 = new TableRow(); agentCardViewTable.Rows.Add(tRow2); TableCell market = new TableCell(); market.Text = string.Format("<img src=./images/full-market" + currentConsultantCard.Market + ".png title='What is the current customer base? How do they stay in touch with customers? How do they reach potential new customers?'/>"); tRow2.Controls.Add(market); TableCell rapport = new TableCell(); rapport.Text = string.Format("<img src=./images/full-rapport" + currentConsultantCard.Rapport + ".png title='How did they get started in their business? What is their favorite thing about what they do? Other than [issue that initiated call], how are they doing today?'/>"); tRow2.Controls.Add(rapport); TableCell recommended = new TableCell(); recommended.Text = string.Format("<img src=./images/full-recommended" + currentConsultantCard.Recommended + ".png title='Based on what you said, I’d recommend… Because the rest of your account is out [term], I’d recommend doing the same term. Needs based suggestion'/>"); tRow2.Controls.Add(recommended); TableCell term = new TableCell(); term.Text = string.Format("<img src=./images/full-term" + currentConsultantCard.Term + ".png title='How long have they been in business? How long are they planning to be in business? What are they doing to ensure they stick around?'/>"); tRow2.Controls.Add(term); TableCell website = new TableCell(); website.Text = string.Format("<img src=./images/full-website" + currentConsultantCard.Website + ".png title='Who built it? When was it last updated? Who maintains it? What are their goals for it?'/>"); tRow2.Controls.Add(website); TableRow tRow2c = new TableRow(); agentCardViewTable.Rows.Add(tRow2c); TableRow tRow2b = new TableRow(); agentCardViewTable.Rows.Add(tRow2b); Button marketButton = new Button(); marketButton.Click += new EventHandler(marketButton_Click); btnText = checkPropertyValue(currentConsultantCard.Market, loggedInEmployee.RoleName); marketButton.Text = btnText; TableCell marketButtonCell = new TableCell(); marketButtonCell.Controls.Add(marketButton); Button marketRequestButton = new Button(); marketRequestButton.Click += new EventHandler(marketButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Market == 1 || currentConsultantCard.Market == 2) { marketButtonCell.Controls.Remove(marketButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Market == 2) { marketRequestButton.Text = "Reject"; marketButtonCell.Controls.Add(marketRequestButton); } } tRow2b.Controls.Add(marketButtonCell); TableCell marketRequestDate = new TableCell(); if (currentConsultantCard.Market == 2) { marketRequestDate.Text = currentConsultantCard.MarketRequestDate; } else { marketRequestDate.Text = ""; } tRow2c.Controls.Add(marketRequestDate); Button rapportButton = new Button(); rapportButton.Click += new EventHandler(rapportButton_Click); btnText = checkPropertyValue(currentConsultantCard.Rapport, loggedInEmployee.RoleName); rapportButton.Text = btnText; TableCell rapportButtonCell = new TableCell(); rapportButtonCell.Controls.Add(rapportButton); Button rapportRequestButton = new Button(); rapportRequestButton.Click += new EventHandler(rapportButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Rapport == 1 || currentConsultantCard.Rapport == 2) { rapportButtonCell.Controls.Remove(rapportButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Rapport == 2) { rapportRequestButton.Text = "Reject"; rapportButtonCell.Controls.Add(rapportRequestButton); } } tRow2b.Controls.Add(rapportButtonCell); TableCell rapportRequestDate = new TableCell(); if (currentConsultantCard.Rapport == 2) { rapportRequestDate.Text = currentConsultantCard.RapportRequestDate; } else { rapportRequestDate.Text = ""; } tRow2c.Controls.Add(rapportRequestDate); Button recommendedButton = new Button(); recommendedButton.Click += new EventHandler(recommendedButton_Click); btnText = checkPropertyValue(currentConsultantCard.Recommended, loggedInEmployee.RoleName); recommendedButton.Text = btnText; TableCell recommendedButtonCell = new TableCell(); recommendedButtonCell.Controls.Add(recommendedButton); Button recommendedRequestButton = new Button(); recommendedRequestButton.Click += new EventHandler(recommendedButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Recommended == 1 || currentConsultantCard.Recommended == 2) { recommendedButtonCell.Controls.Remove(recommendedButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Recommended == 2) { recommendedRequestButton.Text = "Reject"; recommendedButtonCell.Controls.Add(recommendedRequestButton); } } tRow2b.Controls.Add(recommendedButtonCell); TableCell recommendedRequestDate = new TableCell(); if (currentConsultantCard.Recommended == 2) { recommendedRequestDate.Text = currentConsultantCard.RecommendedRequestDate; } else { recommendedRequestDate.Text = ""; } tRow2c.Controls.Add(recommendedRequestDate); Button termButton = new Button(); termButton.Click += new EventHandler(termButton_Click); btnText = checkPropertyValue(currentConsultantCard.Term, loggedInEmployee.RoleName); termButton.Text = btnText; TableCell termButtonCell = new TableCell(); termButtonCell.Controls.Add(termButton); Button termRequestButton = new Button(); termRequestButton.Click += new EventHandler(termButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Term == 1 || currentConsultantCard.Term == 2) { termButtonCell.Controls.Remove(termButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Term == 2) { termRequestButton.Text = "Reject"; termButtonCell.Controls.Add(termRequestButton); } } tRow2b.Controls.Add(termButtonCell); TableCell termRequestDate = new TableCell(); if (currentConsultantCard.Term == 2) { termRequestDate.Text = currentConsultantCard.TermRequestDate; } else { termRequestDate.Text = ""; } tRow2c.Controls.Add(termRequestDate); Button websiteButton = new Button(); websiteButton.Click += new EventHandler(websiteButton_Click); btnText = checkPropertyValue(currentConsultantCard.Website, loggedInEmployee.RoleName); websiteButton.Text = btnText; TableCell websiteButtonCell = new TableCell(); websiteButtonCell.Controls.Add(websiteButton); Button websiteRequestButton = new Button(); websiteRequestButton.Click += new EventHandler(websiteButton_Click); if (loggedInEmployee.RoleName == "Agent") { if (currentConsultantCard.Website == 1 || currentConsultantCard.Website == 2) { websiteButtonCell.Controls.Remove(websiteButton); } } else if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { if (currentConsultantCard.Website == 2) { websiteRequestButton.Text = "Reject"; websiteButtonCell.Controls.Add(websiteRequestButton); } } tRow2b.Controls.Add(websiteButtonCell); TableCell websiteRequestDate = new TableCell(); if (currentConsultantCard.Website == 2) { websiteRequestDate.Text = currentConsultantCard.WebsiteRequestDate; } else { websiteRequestDate.Text = ""; } tRow2c.Controls.Add(websiteRequestDate); if (loggedInEmployee.RoleName == "Agent") { btnClear.Visible = false; if (loggedInEmployee.EmployeeID != consultantID) { tRow1b.Visible = false; tRow2b.Visible = false; tRow1c.Visible = false; tRow2c.Visible = false; } } ConsultationSheet currentSheet = _myConsultationCardManager.SelectCurrentConsultationSheet(consultantID); int currentMonth = DateTime.Now.Month; string[] currentSheetMonthSplit = currentSheet.createdDate.Split('/'); int currentSheetMonth = Convert.ToInt32(currentSheetMonthSplit[0]); if (currentMonth != currentSheetMonth) { if (loggedInEmployee.RoleName == "Agent") { lblCardExpired.Text = "This sheet was started last month. Please ask your supervisor to submit your earned entries for last month, and reset your sheet."; } lblCardExpired.Visible = true; communicationButton.Visible = false; communicationRequestButton.Visible = false; competitorsButton.Visible = false; competitorsRequestButton.Visible = false; goalsButton.Visible = false; goalsRequestButton.Visible = false; growthButton.Visible = false; growthRequestButton.Visible = false; headcountButton.Visible = false; headcountRequestButton.Visible = false; marketButton.Visible = false; marketRequestButton.Visible = false; rapportButton.Visible = false; rapportRequestButton.Visible = false; recommendedButton.Visible = false; recommendedRequestButton.Visible = false; termButton.Visible = false; termRequestButton.Visible = false; websiteButton.Visible = false; websiteRequestButton.Visible = false; } } else { Response.Redirect("AgentView.aspx"); } }
public void updateCard(string c, int empID) { Employee loggedInEmployee = (Employee)Session["loggedInUser"]; ConsultationCard oldCard = _myConsultationCardManager.FindCard(empID); ConsultationCard updatedCard = oldCard; int consultantID = Convert.ToInt32(Request.QueryString["agent"]); ConsultationSheet currentSheet = _myConsultationCardManager.SelectCurrentConsultationSheet(consultantID); SheetCard newSheetCard = new SheetCard(); newSheetCard.sheetID = currentSheet.sheetID; int cardCount = _myConsultationCardManager.SelectCurrentCardSheetCount(currentSheet.sheetID); int newCount = cardCount + 1; newSheetCard.cardSlot = newCount; newSheetCard.cardName = c; switch (c) { case "Communication": updatedCard.Communication = 1; newSheetCard.requestedDate = updatedCard.CommunicationRequestDate; break; case "Competitors": updatedCard.Competitors = 1; newSheetCard.requestedDate = updatedCard.CompetitorsRequestDate; break; case "Goals": updatedCard.Goals = 1; newSheetCard.requestedDate = updatedCard.GoalsRequestDate; break; case "Growth": updatedCard.Growth = 1; newSheetCard.requestedDate = updatedCard.GrowthRequestDate; break; case "Headcount": updatedCard.Headcount = 1; newSheetCard.requestedDate = updatedCard.HeadcountRequestDate; break; case "Market": updatedCard.Market = 1; newSheetCard.requestedDate = updatedCard.MarketRequestDate; break; case "Rapport": updatedCard.Rapport = 1; newSheetCard.requestedDate = updatedCard.RapportRequestDate; break; case "Recommended": updatedCard.Recommended = 1; newSheetCard.requestedDate = updatedCard.RecommendedRequestDate; break; case "Term": updatedCard.Term = 1; newSheetCard.requestedDate = updatedCard.TermRequestDate; break; case "Website": updatedCard.Website = 1; newSheetCard.requestedDate = updatedCard.WebsiteRequestDate; break; } newSheetCard.awardDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); newSheetCard.awardedBy = loggedInEmployee.FirstName + " " + loggedInEmployee.LastName; newSheetCard.awardMethod = ddlMethod.SelectedValue; newSheetCard.awardNote = txtNote.Text; //updatedCard.RequestDate = "1/1/1900 12:00:00"; _myConsultationCardManager.InsertCard(newSheetCard); _myConsultationCardManager.UpdateConsultationCard(oldCard, updatedCard); Employee currentEmp = _myEmployeeManager.FindSingleEmployee(updatedCard.EmployeeID); SendMail(currentEmp.FirstName, c, currentEmp.EmailAddress); if (updatedCard.Communication == 1 && updatedCard.Competitors == 1 && updatedCard.Goals == 1 && updatedCard.Growth == 1 && updatedCard.Headcount == 1 && updatedCard.Market == 1 && updatedCard.Rapport == 1 && updatedCard.Recommended == 1 && updatedCard.Term == 1 && updatedCard.Website == 1) { ConsultationSheet newSheet = currentSheet; newSheet.completedDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); _myConsultationCardManager.CloseCardSheet(currentSheet, newSheet); _myConsultationCardManager.CreateNewCardSheet(consultantID); addEntry(consultantID); SendEntryMail(currentEmp.FirstName, currentEmp.EmailAddress); } Response.Redirect(Request.RawUrl); }
public static ConsultationCard SelectCard(int employeeID) { var conn = DatabaseConnection.GetExEventDatabaseConnection(); var query = @"SELECT employee_id, communication, competitors, goals, growth, headcount, market, rapport, recommended, term, website, total_entries, lifetime_entries, communication_request_date, competitors_request_date, goals_request_date, growth_request_date, headcount_request_date, market_request_date, rapport_request_date, recommended_request_date, term_request_date, website_request_date FROM consultation WHERE employee_id = @employeeID"; var cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@employeeID", employeeID); try { conn.Open(); var reader = cmd.ExecuteReader(); if (!reader.HasRows) { throw new ApplicationException("Consultation Card not found."); } var retrievedCard = new ConsultationCard(); reader.Read(); retrievedCard.EmployeeID = reader.GetInt32(0); retrievedCard.Communication = reader.GetInt32(1); retrievedCard.Competitors = reader.GetInt32(2); retrievedCard.Goals = reader.GetInt32(3); retrievedCard.Growth = reader.GetInt32(4); retrievedCard.Headcount = reader.GetInt32(5); retrievedCard.Market = reader.GetInt32(6); retrievedCard.Rapport = reader.GetInt32(7); retrievedCard.Recommended = reader.GetInt32(8); retrievedCard.Term = reader.GetInt32(9); retrievedCard.Website = reader.GetInt32(10); retrievedCard.TotalEntries = reader.GetInt32(11); retrievedCard.LifetimeEntries = reader.GetInt32(12); retrievedCard.CommunicationRequestDate = reader.GetSqlDateTime(13).ToString(); retrievedCard.CompetitorsRequestDate = reader.GetSqlDateTime(14).ToString(); retrievedCard.GoalsRequestDate = reader.GetSqlDateTime(15).ToString(); retrievedCard.GrowthRequestDate = reader.GetSqlDateTime(16).ToString(); retrievedCard.HeadcountRequestDate = reader.GetSqlDateTime(17).ToString(); retrievedCard.MarketRequestDate = reader.GetSqlDateTime(18).ToString(); retrievedCard.RapportRequestDate = reader.GetSqlDateTime(19).ToString(); retrievedCard.RecommendedRequestDate = reader.GetSqlDateTime(20).ToString(); retrievedCard.TermRequestDate = reader.GetSqlDateTime(21).ToString(); retrievedCard.WebsiteRequestDate = reader.GetSqlDateTime(22).ToString(); int numCards = 0; if (retrievedCard.Communication == 1) { numCards += 1; } if (retrievedCard.Competitors == 1) { numCards += 1; } if (retrievedCard.Goals == 1) { numCards += 1; } if (retrievedCard.Growth == 1) { numCards += 1; } if (retrievedCard.Headcount == 1) { numCards += 1; } if (retrievedCard.Market == 1) { numCards += 1; } if (retrievedCard.Rapport == 1) { numCards += 1; } if (retrievedCard.Recommended == 1) { numCards += 1; } if (retrievedCard.Term == 1) { numCards += 1; } if (retrievedCard.Website == 1) { numCards += 1; } int entryTotal = retrievedCard.TotalEntries * 10; int totalPoints = entryTotal + numCards; retrievedCard.NumEarned = totalPoints; return(retrievedCard); } catch (Exception) { throw; } finally { conn.Close(); } }
protected void btnViewReport_Click(object sender, EventArgs e) { checkLogin(); try { Employee loggedInEmployee = (Employee)Session["loggedInUser"]; } catch (Exception) { Response.Redirect("AgentView.aspx"); } if (listTopLevel.SelectedValue == "Supervisor" || listTopLevel.SelectedValue == "Lead") { string fullSupName = listRepresentative.SelectedItem.Text; string[] splitSupName = fullSupName.Split(','); for (int i = 0; i < splitSupName.Length; i++) { splitSupName[i] = splitSupName[i].Trim(); } string supLastName = splitSupName[0].ToString(); string supFirstName = splitSupName[1].ToString(); _employeeList = _myEmployeeManager.FindLeadReports(supFirstName, supLastName); List <ConsultationCard> empList = new List <ConsultationCard>(); if (_employeeList.Count() != 0) { Session["currentEmployeeList"] = _employeeList; Session["SortDirection"] = "ASC"; for (int x = 0; x < _employeeList.Count; x++) { ConsultationCard currentCard = _myConsultationCardManager.FindCard(_employeeList[x].EmployeeID); empList.Add(currentCard); } List <ConsultationCard> SortedList = empList.OrderBy(o => o.NumEarned).Reverse().ToList(); for (int x = 0; x < SortedList.Count; x++) { TableRow tRow = new TableRow(); consultTable.Rows.Add(tRow); TableCell agent = new TableCell(); agent.Text = (_myEmployeeManager.FindSingleEmployee(SortedList[x].EmployeeID)).FullName; tRow.Cells.Add(agent); TableCell cards = new TableCell(); cards.Text = string.Format( "<img src='./images/communication" + SortedList[x].Communication.ToString() + ".png' title='Ask about TYPE OF COMMUNICATION they use in their business' />" + " " + "<img src='./images/competitors" + SortedList[x].Competitors.ToString() + ".png' title='Ask about COMPETITORS in their market' />" + " " + "<img src='./images/goals" + SortedList[x].Goals.ToString() + ".png' title='Ask about PRESENT AND FUTURE GOALS of their business' />" + " " + "<img src='./images/growth" + SortedList[x].Growth.ToString() + ".png' title='Gauge GROWTH of the business' />" + " " + "<img src='./images/headcount" + SortedList[x].Headcount.ToString() + ".png' title='Gauge HEADCOUNT for their business' />" + " " + "<img src='./images/market" + SortedList[x].Market.ToString() + ".png' title='Gauge HOW THEY MARKET' />" + " " + "<img src='./images/rapport" + SortedList[x].Rapport.ToString() + ".png' title='Ask RAPPORT BUILDING questions' />" + " " + "<img src='./images/recommended" + SortedList[x].Recommended.ToString() + ".png' title='RECOMMEND the right products' />" + " " + "<img src='./images/term" + SortedList[x].Term.ToString() + ".png' title='Gauge TERM of the business' />" + " " + "<img src='./images/website" + SortedList[x].Website.ToString() + ".png' title='ASK ABOUT THEIR WEBSITE for their business' />" + " " ); tRow.Cells.Add(cards); TableCell numEarned = new TableCell(); int numCards = 0; if (SortedList[x].Communication == 1) { numCards += 1; } if (SortedList[x].Competitors == 1) { numCards += 1; } if (SortedList[x].Goals == 1) { numCards += 1; } if (SortedList[x].Growth == 1) { numCards += 1; } if (SortedList[x].Headcount == 1) { numCards += 1; } if (SortedList[x].Market == 1) { numCards += 1; } if (SortedList[x].Rapport == 1) { numCards += 1; } if (SortedList[x].Recommended == 1) { numCards += 1; } if (SortedList[x].Term == 1) { numCards += 1; } if (SortedList[x].Website == 1) { numCards += 1; } numEarned.Text = numCards + " / 10"; tRow.Cells.Add(numEarned); TableCell entries = new TableCell(); entries.Text = SortedList[x].TotalEntries.ToString(); tRow.Cells.Add(entries); Employee loggedInEmployee = (Employee)Session["loggedInUser"]; if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { Button editCardsButton = new Button(); editCardsButton.Text = "Edit Cards"; editCardsButton.PostBackUrl = ("./AgentCardView.aspx?agent=" + SortedList[x].EmployeeID); TableCell editCards = new TableCell(); editCards.Controls.Add(editCardsButton); tRow.Controls.Add(editCards); } else if (loggedInEmployee.RoleName == "Agent") { Button viewCardsButton = new Button(); viewCardsButton.Text = "View Cards"; viewCardsButton.PostBackUrl = ("./AgentCardView.aspx?agent=" + SortedList[x].EmployeeID); TableCell viewCards = new TableCell(); viewCards.Controls.Add(viewCardsButton); tRow.Controls.Add(viewCards); } } } } //if event list is empty, hide gridview and display 'no records' message else if (listTopLevel.SelectedValue == "Agent") { int representative = Convert.ToInt32(listRepresentative.SelectedItem.Value); Employee employee = _myEmployeeManager.FindSingleEmployee(representative); ConsultationCard currentCard = _myConsultationCardManager.FindCard(employee.EmployeeID); TableRow tRow = new TableRow(); consultTable.Rows.Add(tRow); TableCell agent = new TableCell(); agent.Text = employee.FullName; tRow.Cells.Add(agent); TableCell cards = new TableCell(); cards.Text = string.Format( "<img src='./images/communication" + currentCard.Communication.ToString() + ".png' title='Ask about TYPE OF COMMUNICATION they use in their business' />" + " " + "<img src='./images/competitors" + currentCard.Competitors.ToString() + ".png' title='Ask about COMPETITORS in their market' />" + " " + "<img src='./images/goals" + currentCard.Goals.ToString() + ".png' title='Ask about PRESENT AND FUTURE GOALS of their business' />" + " " + "<img src='./images/growth" + currentCard.Growth.ToString() + ".png' title='Gauge GROWTH of the business' />" + " " + "<img src='./images/headcount" + currentCard.Headcount.ToString() + ".png' title='Gauge HEADCOUNT for their business' />" + " " + "<img src='./images/market" + currentCard.Market.ToString() + ".png' title='Gauge HOW THEY MARKET' />" + " " + "<img src='./images/rapport" + currentCard.Rapport.ToString() + ".png' title='Ask RAPPORT BUILDING questions' />" + " " + "<img src='./images/recommended" + currentCard.Recommended.ToString() + ".png' title='RECOMMEND the right products' />" + " " + "<img src='./images/term" + currentCard.Term.ToString() + ".png' title='Gauge TERM of the business' />" + " " + "<img src='./images/website" + currentCard.Website.ToString() + ".png' title='ASK ABOUT THEIR WEBSITE for their business' />" + " " ); tRow.Cells.Add(cards); TableCell numEarned = new TableCell(); int numCards = 0; if (currentCard.Communication == 1) { numCards += 1; } if (currentCard.Competitors == 1) { numCards += 1; } if (currentCard.Goals == 1) { numCards += 1; } if (currentCard.Growth == 1) { numCards += 1; } if (currentCard.Headcount == 1) { numCards += 1; } if (currentCard.Market == 1) { numCards += 1; } if (currentCard.Rapport == 1) { numCards += 1; } if (currentCard.Recommended == 1) { numCards += 1; } if (currentCard.Term == 1) { numCards += 1; } if (currentCard.Website == 1) { numCards += 1; } numEarned.Text = numCards + " / 10"; tRow.Cells.Add(numEarned); TableCell entries = new TableCell(); entries.Text = currentCard.TotalEntries.ToString(); tRow.Cells.Add(entries); Employee loggedInEmployee = (Employee)Session["loggedInUser"]; if (loggedInEmployee.RoleName == "Manager" || loggedInEmployee.RoleName == "Supervisor" || loggedInEmployee.RoleName == "Lead") { Button editCardsButton = new Button(); editCardsButton.Text = "Edit Cards"; editCardsButton.PostBackUrl = ("./AgentCardView.aspx?agent=" + currentCard.EmployeeID); TableCell editCards = new TableCell(); editCards.Controls.Add(editCardsButton); tRow.Controls.Add(editCards); } else if (loggedInEmployee.RoleName == "Agent") { Button viewCardsButton = new Button(); viewCardsButton.Text = "View Cards"; viewCardsButton.PostBackUrl = ("./AgentCardView.aspx?agent=" + currentCard.EmployeeID); TableCell viewCards = new TableCell(); viewCards.Controls.Add(viewCardsButton); tRow.Controls.Add(viewCards); } } }