Esempio n. 1
0
 public CustomPrincipal(IIdentity identity, DMXUser user)
 {
     _identity = identity;
     FirstName = user.FirstName;
     LastName = user.LastName;
     EmployeeID = user.EmployeeID;
     HomePage = user.HomePage;
     _roles = new string[user.Roles.Length];
     user.Roles.CopyTo(_roles, 0);
     Array.Sort(_roles);
 }
Esempio n. 2
0
        protected void LoadEmployeeInfo(DMXUser user)
        {
            this.txtFirstName.Text = user.FirstName;
            this.txtLastName.Text = user.LastName;
            this.txtUserName.Text = user.UserName;
            this.txtPassword.Text = user.Password;
            this.txtAddress.Text = user.Address;
            this.txtEmail.Text = user.Email;
            this.txtPhone.Text = user.Phone;

            this.lstRegion.SelectedValue = user.Region;
            this.lstArea.SelectedValue = user.Area;
            this.lstLSO.SelectedValue = user.LSO;
            this.lstEmployeeType.SelectedValue = ((int)user.UserType).ToString();
            if (user.SalesManagerID > 0)
            {
                this.lstManagers.SelectedValue = user.SalesManagerID.ToString();
            }
        }
Esempio n. 3
0
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            user = new DMXUser();

            if (EmployeeID > 0)
            {
                user.Find(EmployeeID);
            }

            user.UserType = (Database.EmployeeType)int.Parse(lstEmployeeType.SelectedValue);
            user.UserName = this.txtUserName.Text;
            user.Password = this.txtPassword.Text;
            user.FirstName = this.txtFirstName.Text;
            user.LastName = this.txtLastName.Text;
            user.Address = this.txtAddress.Text;
            user.Phone = this.txtPhone.Text;
            user.Email = this.txtEmail.Text;

            if (int.Parse(lstEmployeeType.SelectedValue) != (int)Database.EmployeeType.Administrator)
            {
                user.Region = lstRegion.SelectedValue;
                user.Area = lstArea.SelectedValue;
                user.LSO = lstLSO.SelectedValue;

                if (int.Parse(lstEmployeeType.SelectedValue) == (int)Database.EmployeeType.Sales)
                {
                    if (lstManagers.SelectedValue != "")
                    {
                        user.SalesManagerID = int.Parse(lstManagers.SelectedValue);
                    }
                }

            }

            user.Save();

            lblMessage.Text = "Changes Saved.";
            lblMessage.Visible = true;
        }
Esempio n. 4
0
        public int SaveEmployee(DMXUser user)
        {
            string procName;
            SqlParameter empID;
            if (user.EmployeeID > 0)
            {
                procName = "sp_UpdateEmployee";
                empID = this.MakeInParam("@intEmpID", SqlDbType.Int, 4, user.EmployeeID);
            }
            else
            {
                procName = "sp_InsertEmployee";
                empID = this.MakeOutParam("@intEmpID", SqlDbType.Int, 4);
            }

            SqlParameter[] prams = {empID,
                                       this.MakeInParam("@intEmpTypeID", SqlDbType.Int, 4, (int)user.UserType),
                                       this.MakeInParam("@strUserName", SqlDbType.VarChar, user.UserName.Length, user.UserName),
                                       this.MakeInParam("@strPassword", SqlDbType.VarChar, user.Password.Length, user.Password),
                                       this.MakeInParam("@strFirstName", SqlDbType.VarChar, user.FirstName.Length, user.FirstName),
                                       this.MakeInParam("@strLastName", SqlDbType.VarChar, user.LastName.Length, user.LastName),
                                       this.MakeInParam("@strAddress", SqlDbType.VarChar, user.Address.Length, user.Address),
                                       this.MakeInParam("@strPhone", SqlDbType.VarChar, user.Phone.Length, user.Phone),
                                       this.MakeInParam("@strRegion", SqlDbType.VarChar, user.Region.Length, user.Region),
                                       this.MakeInParam("@strArea", SqlDbType.VarChar, user.Area.Length, user.Area),
                                       this.MakeInParam("@strLSO", SqlDbType.VarChar, user.LSO.Length, user.LSO),
                                       this.MakeInParam("@strEmail", SqlDbType.VarChar, user.Email.Length, user.Email),
                                       this.MakeInParam("@intSalesManagerID", SqlDbType.Int, 4, user.SalesManagerID)};

            this.RunProc(procName, prams);

            return (int)prams[0].Value;
        }
Esempio n. 5
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;
        }
Esempio n. 6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                // Extract the forms authentication cookie
                string cookieName = FormsAuthentication.FormsCookieName;
                HttpCookie authCookie = Context.Request.Cookies[cookieName];

                if (authCookie != null)
                {

                    authCookie.Expires = DateTime.Now.AddDays(-1);
                    Response.Cookies.Add(authCookie);
                }
                Session.Abandon();

            }
            else
            {
                DMXUser user = new DMXUser();

            //				User = new GenericPrincipal(

                if ((user.Find(txtUserName.Text))&&(user.Active))
                {
                    if(user.Password == txtPassword.Text)
                    {
                        // Create the authentication ticket
                        FormsAuthenticationTicket authTicket = new
                            FormsAuthenticationTicket(1,                          //  version
                            txtUserName.Text,           // user name
                            DateTime.Now,               // creation
                            DateTime.Now.AddMinutes(60),						// Expiration
                            false,                      //Persistent
                            user.ToXml() );            // Userdata

                        // Now encrypt the ticket.
                        string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

                        // Create a cookie and add the encrypted ticket to the
                        // cookie as data.
                        HttpCookie authCookie =
                            new HttpCookie(FormsAuthentication.FormsCookieName,
                            encryptedTicket);

                        // Add the cookie to the outgoing cookies collection.
                        Response.Cookies.Add(authCookie);

                        // this is a temp fix for old ASP security
                        Session.Add("EmployeeID", user.EmployeeID);

            //						Response.Redirect("Top25Report.aspx");
                        Response.Redirect(user.HomePage +
                            "?intEmpID=" + user.EmployeeID +
                            "&strLName=" + user.LastName +
                            "&strFName=" + user.FirstName);

                    }
                    else
                    {
                        Message.Text = "Password invalid.";
                        Message.Visible = true;
                    }
                }
                else
                {
                    Message.Text = "User not found.";
                    Message.Visible = true;
                }
            }
        }
Esempio n. 7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "no-cache";
            Response.AddHeader("Pragma", "no-cache");

            if (!IsPostBack)
            {
                LoadMenu(lstRegion);
                LoadMenu(lstArea);
                LoadMenu(lstLSO);
                LoadMenu(lstEmployeeType);
                LoadMenu(lstManagers);
                if ((Request["intEmpID"] != null)&&(Request["intEmpID"] != ""))
                {
                    EmployeeID = int.Parse(Request["intEmpID"]);
                    user = new DMXUser();
                    user.Find(EmployeeID);
                    LoadEmployeeInfo(user);
                }
                else
                {
                    this.lstEmployeeType.SelectedValue = ((int)Database.EmployeeType.Sales).ToString();

                }
            }

            switch (Convert.ToInt16(lstEmployeeType.SelectedValue))
            {
                case (short)Database.EmployeeType.Administrator:
                    rwRegion.Visible = false;
                    rwArea.Visible = false;
                    rwLSO.Visible = false;
                    rwManager.Visible = false;
                    break;
                case (short)Database.EmployeeType.Sales:
                    rwRegion.Visible = true;
                    rwArea.Visible = true;
                    rwLSO.Visible = true;
                    rwManager.Visible = true;
                    break;
                default:
                    rwRegion.Visible = true;
                    rwArea.Visible = true;
                    rwLSO.Visible = true;
                    rwManager.Visible = false;
                    break;
            }
        }
Esempio n. 8
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "no-cache";
            Response.AddHeader("Pragma", "no-cache");

            if(!IsPostBack)
            {
                if ((Request["eid"] != null)&&(Request["eid"] != ""))
                {
                    EmployeeID = Convert.ToInt32(Request["eid"]);
                }
                ReportMonth = Convert.ToDateTime(Request["month"]);
                Approved = Convert.ToBoolean(Request["approved"]);
                DMXUser user = new DMXUser();
                user.Find(EmployeeID);
                lblName.Text = user.FullName;
                LoadData();
                if (User.IsInRole(Database.EmployeeType.Executive.ToString()))
                {
                    lnkHome.Text = "Return to Top 25 Summary";
                    lnkHome.NavigateUrl = "top25Report.aspx";

                }

            }

            if (User.IsInRole(Database.EmployeeType.SalesManager.ToString()))
            {
                lnkHome.Text = "Return to Top 25 Approval";
                lnkHome.NavigateUrl = "top25forecast.aspx?eid=" + EmployeeID.ToString() +
                    "&approved=" + Approved.ToString() + "&month=" + ReportMonth.ToString();
            }
        }