Ejemplo n.º 1
0
        public bool Authenticate(string UserName, string Password)
        {
            Database data = new Database();

            SqlDataReader reader;

            SqlParameter[] prmtrs = {
                                        data.MakeInParam("@strUserName", SqlDbType.VarChar, 200, UserName),
                                        data.MakeInParam("@strPassword", SqlDbType.VarChar, 50, Password)
                                    };
            data.RunProc("sp_AuthenticateUser", prmtrs, out reader);
            if (reader.Read())
            {
                FormsAuthentication.SetAuthCookie(UserName, true);

                data.Close();
                data.Dispose();
                return true;
            }
            else
            {
                data.Close();
                data.Dispose();
                return false;
                // TODO:  USER IS NOT YET ACTIVATED
            }
        }
Ejemplo n.º 2
0
 private void LoadAccounts()
 {
     Database data = new Database();
     lstAccounts.DataSource =  data.GetClosedAccounts(User.EmployeeID);
     lstAccounts.DataTextField = "strAccountName";
     lstAccounts.DataValueField = "intAccountID";
     lstAccounts.DataBind();
     data.Close();
     data.Dispose();
 }
Ejemplo n.º 3
0
        public void LoadData()
        {
            int empID = Page.User.EmployeeID;
            Database data = new Database();

            gridAccounts.DataSource = data.GetEmployeesTop25(intEmployeeID, Month, Approved);

            gridAccounts.DataBind();
            data.Close();
            data.Dispose();
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "no-cache";
            Response.AddHeader("Pragma", "no-cache");

            if (!IsPostBack)
            {
                Database data = new Database();
                lstEmployeeType.DataSource = data.EmployeeTypes;
                lstEmployeeType.DataBind();
                data.Close();
                data.Dispose();
                lstEmployeeType.SelectedIndex= 2;
                LoadDeactivatedUsers();

            }
        }
Ejemplo n.º 5
0
 protected void btnActivate_Click(object sender, EventArgs e)
 {
     Database data = new Database();
     if (data.ReactivateUser(Convert.ToInt32(lstEmployees.SelectedValue)))
     {
         Message.Text = "User Activated.";
         Message.Visible = true;
     }
     else
     {
         Message.Text = "User Could Not Be Activated.";
         Message.Visible = true;
     }
     LoadDeactivatedUsers();
     data.Close();
     data.Dispose();
 }
Ejemplo n.º 6
0
 protected void btnActivate_Click(object sender, EventArgs e)
 {
     Database data = new Database();
     if (data.ReActivateAccount(Convert.ToInt32(lstAccounts.SelectedValue)))
     {
         Message.Text = "Account Activated.";
         Message.Visible = true;
     }
     else
     {
         Message.Text = "Account Could Not Be Activated.";
         Message.Visible = true;
     }
     LoadAccounts();
     data.Close();
     data.Dispose();
 }
Ejemplo n.º 7
0
 private void LoadDeactivatedUsers()
 {
     Database data = new Database();
     lstEmployees.DataSource =  data.GetDeactivatedUsers(int.Parse(lstEmployeeType.SelectedValue));
     lstEmployees.DataTextField = "strFullName";
     lstEmployees.DataValueField = "intEmployeeID";
     lstEmployees.DataBind();
     data.Close();
     data.Dispose();
 }
Ejemplo n.º 8
0
        public void Save()
        {
            Database data = new Database();

            data.SaveEmployee(this);
            data.Close();
            data.Dispose();
        }
Ejemplo n.º 9
0
 public bool Find(int intEmployeeID)
 {
     Database data = new Database();
     SqlDataReader reader = data.FindUser(intEmployeeID);
     if (reader.Read())
     {
         LoadFromReader(reader);
         data.Close();
         data.Dispose();
         return true;
     }
     else
     {
         data.Close();
         data.Dispose();
         return false;
     }
 }
Ejemplo n.º 10
0
        private void LoadSummary()
        {
            Database data = new Database();
            DataView dv = data.GetTop25Summary(Convert.ToDateTime(lstStartMonth.SelectedValue),
                Convert.ToDateTime(lstEndMonth.SelectedValue),
                Convert.ToBoolean(lstApproved.SelectedValue),
                lstRegion.SelectedValue,
                lstArea.SelectedValue,
                lstLSO.SelectedValue,
                SalesManagerID);
            if (ViewState[SUMMARY_SORT_KEY] != null)
            {
                dv.Sort = Convert.ToString(ViewState[SUMMARY_SORT_KEY]);
            }

            grdSummary.DataSource = dv;
            grdSummary.DataBind();
            data.Close();
            data.Dispose();
        }
Ejemplo n.º 11
0
        private void LoadMenu(DropDownList list)
        {
            Database data = new Database();
            switch (list.ID)
            {
                case "lstRegion":
                    list.DataSource = data.Regions;
                    break;
                case "lstArea":
                    list.DataSource = data.Areas;
                    break;
                case "lstLSO":
                    list.DataSource = data.LSOs;
                    break;
                case "lstManagers":
                    list.DataSource = data.GetEmployees((int)Database.EmployeeType.SalesManager);
                    break;
                case "lstEmployeeType":
                    lstEmployeeType.DataSource = data.EmployeeTypes;
                    list.DataBind();
                    return;

            }
            list.DataBind();
            data.Close();
            data.Dispose();
            list.Items.Insert(0, new ListItem("Select...", ""));
            list.SelectedIndex = 0;
        }
Ejemplo n.º 12
0
        protected void btnClose_Click(object sender, System.EventArgs e)
        {
            if ((lstAccounts.SelectedValue != null)&&(int.Parse(lstAccounts.SelectedValue) > 0))
            {

                Top25Account account = new Top25Account(int.Parse(lstAccounts.SelectedValue));
                string NotifyAction = "CLOSED";
                Database data = new Database();
                data.QueueNotification(account.EmployeeID, account.AccountID,
                    account.AccountName, account.Month, NotifyAction);

                account.Close();

                ClearForm();
                BuildAccountsMenu();
                BuildMoveMenu();
                data.Close();
                data.Dispose();
            }
            else
            {
                lblMessage.Text = "You must select an account to delete.";
                lblMessage.Visible = true;
                return;
            }
        }
Ejemplo n.º 13
0
        protected void BuildEmployeesMenu()
        {
            Database data = new Database();
            SqlDataReader reader = data.GetSubordinates(User.EmployeeID, ForecastMonth, Convert.ToBoolean(lstStatus.SelectedValue));
            if (reader.HasRows)
            {
                lstEmployees.DataSource = reader;
                lstEmployees.DataTextField="EmployeeName";
                lstEmployees.DataValueField="intEmployeeID";
                lstEmployees.DataBind();
            }
            else
            {
                lstEmployees.Items.Clear();
            }
            if (lstEmployees.Items.Count > 0)
            {
                if((EmployeeID > 0)&&(lstEmployees.Items.FindByValue(EmployeeID.ToString()) != null))
                {
                    lstEmployees.SelectedValue = EmployeeID.ToString();
                }
                else
                {
                    lstEmployees.SelectedIndex = 0;
                    EmployeeID = int.Parse(lstEmployees.SelectedValue);
                }

            }

            data.Close();
            data.Dispose();
        }
Ejemplo n.º 14
0
 protected void BuildAccountsMenu()
 {
     Database data = new Database();
     if(User.IsInRole(Database.EmployeeType.SalesManager.ToString()))
     {
         lstAccounts.DataSource = data.GetAccountNames(EmployeeID, ForecastMonth, Convert.ToBoolean(lstStatus.SelectedValue), false);
     }
     else
     {
         lstAccounts.DataSource = data.GetAccountNames(EmployeeID, ForecastMonth, true);
     }
     lstAccounts.DataTextField="strAccountName";
     lstAccounts.DataValueField="intAccountID";
     lstAccounts.DataBind();
     if(!User.IsInRole(Database.EmployeeType.SalesManager.ToString()))
     {
         lstAccounts.Items.Insert(0, new ListItem("New Account (Enter Data Below)", ""));
     }
     lstAccounts.SelectedIndex = 0;
     data.Close();
     data.Dispose();
 }
Ejemplo n.º 15
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            Top25Account account;
            string NotifyAction = "";
            if((lstAccounts.SelectedValue != "")&&(int.Parse(lstAccounts.SelectedValue) > 0))
            {
                account = new Top25Account(int.Parse(lstAccounts.SelectedValue));
                if(User.IsInRole(Database.EmployeeType.SalesManager.ToString()))
                {
                    account.Status = AccountStatus.Approved; // managers can ony approve
                }
                else
                {
                    if (account.Status == AccountStatus.Approved)
                    { // if pending, or updated - status does not change
                        account.Status = AccountStatus.Updated;   // if approved, changes to updated
                        NotifyAction = "UPDATED";
                    }

                }
            }
            else if (!User.IsInRole(Database.EmployeeType.SalesManager.ToString())) // managers can not create accounts
            {
                if (lstAccounts.Items.Contains(lstAccounts.Items.FindByText(txtAccountName.Text)))
                    // if an account with this name already exists for this month, you can't add it
                {
                    lblMessage.Text = "Account already exists for this month.";
                    lblMessage.Visible = true;
                    return;
                }
                else
                {
                    account = new Top25Account();
                    account.EmployeeID = User.EmployeeID;
                    account.Status = AccountStatus.Pending;
                    NotifyAction = "CREATED";
                }

            }
            else
            {
                return;
            }

            account.Month = ForecastMonth;
            account.AccountName = txtAccountName.Text;
            account.Contact = txtContact.Text;
            account.Phone = txtPhone.Text;
            if((txtLocations.Text != null)&&(txtLocations.Text != ""))
            {
                account.Locations = int.Parse(txtLocations.Text);
            }
            account.ClosedRMR = Utils.GetDecimal(txtClosedRMR.Text);
            account.ClosedRSS = Utils.GetDecimal(txtClosedRSS.Text);
            account.RMR_10 = Utils.GetDecimal(txtRMR_10.Text);
            account.RSS_10 = Utils.GetDecimal(txtRSS_10.Text);
            account.RMR_50 = Utils.GetDecimal(txtRMR_50.Text);
            account.RSS_50 = Utils.GetDecimal(txtRSS_50.Text);
            account.RMR_90 = Utils.GetDecimal(txtRMR_90.Text);
            account.RSS_90 = Utils.GetDecimal(txtRSS_90.Text);
            account.Save();

            if (NotifyAction != "")
            {
                Database data = new Database();
                data.QueueNotification(account.EmployeeID, account.AccountID,
                    account.AccountName, account.Month, NotifyAction);
                notify.SendNotificationQueue();
                data.Close();
                data.Dispose();
            }

            ClearForm();
            BuildEmployeesMenu();
            BuildAccountsMenu();
            BuildMoveMenu();
            LoadAccountInfo();
        }
Ejemplo n.º 16
0
 public void Close()
 {
     Database data = new Database();
     data.CloseAccount(this);
     data.Close();
     data.Dispose();
 }
Ejemplo n.º 17
0
        public bool Find(int AccountID, bool ApprovedOnly)
        {
            Database data = new Database();
            SqlDataReader reader = data.GetAccountInfo(AccountID, ApprovedOnly);
            if (reader.Read())
            {
                this.EmployeeID = (int)reader["intEmployeeID"];
                this.intAccountID = (int)reader["intAccountID"];
                this.AccountName = (string)reader["strAccountName"];
                this.Contact = (string)reader["strContact"];
                this.Phone = (string)reader["strPhone"];
                this.Locations = (int)reader["intLocations"];
                this.ClosedRMR = (Decimal)reader["mnyClosedRMR"];
                this.ClosedRSS = (Decimal)reader["mnyClosedRSS"];
                this.RMR_10 = (Decimal)reader["mnyRMR_10"];
                this.RSS_10 = (Decimal)reader["mnyRSS_10"];
                this.RMR_50 = (Decimal)reader["mnyRMR_50"];
                this.RSS_50 = (Decimal)reader["mnyRSS_50"];
                this.RMR_90 = (Decimal)reader["mnyRMR_90"];
                this.RSS_90 = (Decimal)reader["mnyRSS_90"];
                this.Month = (DateTime)reader["dtmMonth"];
                this.blActive = (bool)reader["bitActive"];

                switch (((string)reader["charStatus"]).Trim())
                {
                    case "P":
                        this.Status = AccountStatus.Pending;
                        break;
                    case "A":
                        this.Status = AccountStatus.Approved;
                        break;
                    case "U":
                        this.Status = AccountStatus.Updated;
                        break;
                }

                data.Close();
                data.Dispose();
                return true;
            }
            data.Close();
            data.Dispose();
            return false;
        }
Ejemplo n.º 18
0
        private void BuildForecastTable()
        {
            ArrayList t25Array = new ArrayList();
            Database data = new Database();
            for(int i = 0; i < numMonths; i++)
            {
                t25Array.Add(new Top25MonthlySummary(summaryMonth.AddMonths(i)));
            }

            string[] headers = {"Month:",
                                   "Actual RSS:",
                                   "Actual RMR:",
                                   "RSS 10%:",
                                   "RMR 10%:",
                                   "RSS 50%:",
                                   "RMR 50%:",
                                   "RSS 90%:",
                                   "RMR 90%:",
                                   "Projected RSS:",
                                   "Projected RMR:",
                                   "Total Proposed RSS:"};

            for (int i=0; i < 12; i++)
            {
                tblForecast.Rows.Add(new TableRow());
                TableCell tc = new TableCell();
                tc.Text = headers[i];
                tc.HorizontalAlign = HorizontalAlign.Right;
                tc.CssClass= "Top25RowHeader";
                tblForecast.Rows[i].Cells.Add(tc);

                for (int j=0; j < t25Array.Count; j++)
                {
                    tc = new TableCell();

                    switch (i)
                    {
                        case 0:
                            tc.Text = ((Top25MonthlySummary)t25Array[j]).SummaryMonth.ToString("MMMM yyyy");
                            tc.HorizontalAlign = HorizontalAlign.Center;
                            tc.CssClass= "Top25ColumnHeader";
                            break;
                        case 1:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).ClosedRSS);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 2:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).ClosedRMR);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 3:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).RSS_10);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 4:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).RMR_10);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 5:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).RSS_50);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 6:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).RMR_50);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 7:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).RSS_90);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 8:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).RMR_90);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 9:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).ProjectedRSS);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 10:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).ProjectedRMR);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                        case 11:
                            tc.Text = string.Format("{0:C}", ((Top25MonthlySummary)t25Array[j]).TotalProposedRSS);
                            tc.HorizontalAlign = HorizontalAlign.Right;
                            break;
                    }
                    if (i != 0)
                    {
                        tc.CssClass= "Top25Data";
                    }

                    tblForecast.Rows[i].Cells.Add(tc);
                    data.Close();
                    data.Dispose();
                }

            }
        }
Ejemplo n.º 19
0
        public static DataTable SendNotificationQueue()
        {
            Database data = new Database();
            DataTable dt = data.GetNotificationQueue();

            string msgBody = "";
            int intRecipientID = -1;
            int intEmployeeID = -1;
            ArrayList Messages = new ArrayList();
            AuthenticatedMail msg = null;
            DMXUser user = new DMXUser();
            SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["SmtpServer"];

            foreach (DataRow row in dt.Rows)
            {
                if (intRecipientID != Convert.ToInt32(row["intRecipientID"]))
                {
                    if (msg !=null)
                    {
                        msg.Body = msgBody;
                        Messages.Add(msg);
                        SmtpMail.Send(msg);
                    }
                    intRecipientID = Convert.ToInt32(row["intRecipientID"]);
                    msg = new AuthenticatedMail();
                    msg.BodyFormat = MailFormat.Html;
                    user.Find(intRecipientID);
                    if ((string)ConfigurationSettings.AppSettings["TestingServer"] == "true")
                    {
                        msg.To = "*****@*****.**"; // FOR TESTING
                    }
                    else
                    {
                        msg.To = user.Email;
                        //msg.Bcc = "*****@*****.**"; // FOR TESTING
                    }
                    msg.From = ConfigurationSettings.AppSettings["SystemEmail"];
                    msg.Subject = "Top 25 Account Updates";

                    msgBody += user.FullName + ",\n\nThe following changes have been made:\n\n<pre>\n";
                }

                intEmployeeID = Convert.ToInt32(row["intEmployeeID"]);
                user.Find(intEmployeeID);
                msgBody += Convert.ToString(row["strAction"]) + ":\t" + Convert.ToString(row["strAccountName"]) +
                    " - " + user.FullName +
                    ", " + Convert.ToDateTime(row["dtmCreated"]).ToString("M-d-yy, h:mm") + "\n";

                row["dtmSent"] = DateTime.Now;

            }
            //			if (msg !=null)
            //			{
            //				msg.Body = msgBody + "</pre>\n\n<a href=\"http://www.top25hpa.com\">Log in to Top25HPA.com</a> \n\n";
            //				Messages.Add(msg);
            //				SmtpMail.Send(msg);
            //			}

            //			dt.AcceptChanges();
            data.UpdateNotificationQueue(dt);
            data.Close();
            data.Dispose();
            return dt;
        }
Ejemplo n.º 20
0
        private void LoadData(DateTime myMonth)
        {
            Database data = new Database();
            SqlDataReader reader = data.GetTop25SummaryForMonth(myMonth);
            if (reader.Read())
            {
                _ClosedRSS = (Decimal)reader["ClosedRSS"];
                _ClosedRMR = (Decimal)reader["ClosedRMR"];
                _RSS_10 = (Decimal)reader["RSS_10"];
                _RMR_10 = (Decimal)reader["RMR_10"];
                _RSS_50 = (Decimal)reader["RSS_50"];
                _RMR_50 = (Decimal)reader["RMR_50"];
                _RSS_90 = (Decimal)reader["RSS_90"];
                _RMR_90 = (Decimal)reader["RMR_90"];
            }

            CalculateForecast();
            data.Close();
            data.Dispose();
        }
Ejemplo n.º 21
0
        public void LoadQuotas()
        {
            Database data = new Database();
            SqlDataReader reader = data.GetQuotaFunnel(EmployeeID, ReportMonth);

            if (reader.Read())
            {
                RMRQuota = DataUtility.RetrieveDecimal(reader, "mnyRMRQuota", 0.0m);
                RMRFunnel = DataUtility.RetrieveDecimal(reader, "mnyRMRFunnel", 0.0m);
                RSSQuota = DataUtility.RetrieveDecimal(reader, "mnyRSSQuota", 0.0m);
                RSSFunnel = DataUtility.RetrieveDecimal(reader, "mnyRSSFunnel", 0.0m);

                tblQuotaFunnels.Rows[1].Cells[0].Text = RMRQuota.ToString("C");
                tblQuotaFunnels.Rows[1].Cells[1].Text = RMRFunnel.ToString("C");
                tblQuotaFunnels.Rows[1].Cells[2].Text = RSSQuota.ToString("C");
                tblQuotaFunnels.Rows[1].Cells[3].Text = RSSFunnel.ToString("C");
            }

            data.Close();
            data.Dispose();
        }
Ejemplo n.º 22
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "no-cache";
            Response.AddHeader("Pragma", "no-cache");

            if(!IsPostBack)
            {
                if (User.IsInRole(Database.EmployeeType.SalesManager.ToString()))
                {
                    this.SalesManagerID = User.EmployeeID;
                }
                else
                {
                    this.SalesManagerID = -1;
                }
                lblName.Text = User.FullName;
                lnkHome.NavigateUrl = User.HomePage;
                LoadMonthMenu(lstStartMonth);
                LoadMonthMenu(lstEndMonth);
                lstStartMonth.SelectedValue = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)).ToString();
                lstEndMonth.SelectedValue = (new DateTime(DateTime.Now.AddMonths(2).Year, DateTime.Now.AddMonths(2).Month, 1)).ToString();
                Database data = new Database();
                LoadMenu(lstRegion);
                LoadMenu(lstArea);
                LoadMenu(lstLSO);
                LoadSummary();
                LoadEmployees();
                data.Close();
                data.Dispose();
            }
        }
Ejemplo n.º 23
0
 public bool Find(string strUserName)
 {
     Database data = new Database();
     SqlDataReader reader = data.FindUser(strUserName);
     if (reader.Read())
     {
         LoadFromReader(reader);
         data.Close();
         data.Dispose();
         return true;
     }
     else
     {
         data.Close();
         data.Dispose();
         return false;
     }
 }
Ejemplo n.º 24
0
        public void LoadData()
        {
            Database data = new Database();

            DataView dv = data.GetEmployeesTop25(EmployeeID, ReportMonth, Approved);
            if (ViewState[EMPLOYEES_SORT_KEY] != null)
            {
                dv.Sort = Convert.ToString(ViewState[EMPLOYEES_SORT_KEY]);
            }

            gridAccounts.DataSource = dv;
            gridAccounts.DataBind();
            data.Close();
            data.Dispose();
        }