public static ConsultationSheet SelectCurrentConsultationSheet(int employeeID)
        {
            var conn  = DatabaseConnection.GetExEventDatabaseConnection();
            var query = @"SELECT sheet_id, employee_id, created_date FROM card_sheets WHERE employee_id = @employeeID AND completed_date IS NULL";
            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 retrievedSheet = new ConsultationSheet();
                reader.Read();
                retrievedSheet.sheetID     = reader.GetInt32(0);
                retrievedSheet.employeeID  = reader.GetInt32(1);
                retrievedSheet.createdDate = reader.GetSqlDateTime(2).ToString();


                return(retrievedSheet);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
        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 CloseCardSheet(ConsultationSheet oldSheet, ConsultationSheet newSheet)
        {
            int rowsAffected = 0;
            var conn         = DatabaseConnection.GetExEventDatabaseConnection();
            var cmdText      = "spCloseCardSheet";
            var cmd          = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@sheet_id", newSheet.sheetID);
            cmd.Parameters.AddWithValue("@employee_id", newSheet.employeeID);
            cmd.Parameters.AddWithValue("@completed_date", newSheet.completedDate);

            cmd.Parameters.AddWithValue("@original_sheet_id", oldSheet.sheetID);
            cmd.Parameters.AddWithValue("@original_employee_id", oldSheet.employeeID);
            cmd.Parameters.AddWithValue("@original_completed_date", oldSheet.completedDate);

            try
            {
                conn.Open();

                rowsAffected = cmd.ExecuteNonQuery();

                if (rowsAffected == 0)
                {
                    throw new ApplicationException("Card Close Failed. Please refresh and try again.");
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(rowsAffected);
        }
Exemple #4
0
 public void CloseCardSheet(ConsultationSheet oldSheet, ConsultationSheet newSheet)
 {
     try
     {
         ConsultationAccessor.CloseCardSheet(oldSheet, newSheet);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #5
0
 public ConsultationSheet SelectCurrentConsultationSheet(int employeeID)
 {
     try
     {
         ConsultationSheet currentConsultationSheet = ConsultationAccessor.SelectCurrentConsultationSheet(employeeID);
         return(currentConsultationSheet);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public static List <ConsultationSheet> SelectConsultationSheetDates(int month)
        {
            var    conn        = DatabaseConnection.GetExEventDatabaseConnection();
            var    query       = @"SELECT created_date, completed_date FROM card_sheets WHERE created_date > @monthStart AND completed_date != '1/1/2000 12:00:00 PM' AND completed_date IS NOT NULL";
            var    cmd         = new SqlCommand(query, conn);
            string currentYear = DateTime.Now.Year.ToString();
            string monthStart  = month + "/1/" + currentYear;

            cmd.Parameters.AddWithValue("@monthStart", monthStart);

            List <ConsultationSheet> sheetList = new List <ConsultationSheet>();

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();

                if (!reader.HasRows)
                {
                    throw new ApplicationException("No methods found!");
                }
                while (reader.Read())
                {
                    ConsultationSheet currentSheet = new ConsultationSheet();

                    currentSheet.createdDate   = reader.GetSqlDateTime(0).ToString();
                    currentSheet.completedDate = reader.GetSqlDateTime(1).ToString();
                    sheetList.Add(currentSheet);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(sheetList);
        }
        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?&#10;How do they communicate with customers?&#10;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?&#10;Who is the national competition?&#10;What are their competitors doing right?&#10;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?&#10;What is their 5 year goal?&#10;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?&#10;Are they currently hiring?&#10;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?&#10;How many customers do they work with daily?&#10;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?&#10;How do they stay in touch with customers?&#10;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?&#10;What is their favorite thing about what they do?&#10;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…&#10;Because the rest of your account is out [term], I’d recommend doing the same term.&#10;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?&#10;How long are they planning to be in business?&#10;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?&#10;When was it last updated?&#10;Who maintains it?&#10;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);
        }