Exemplo n.º 1
0
    protected override void AdminPageHandling(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            if (Request[WebConstants.Request.USER_ID] != null)
            {
                int userId = int.Parse(Request[WebConstants.Request.USER_ID]);
                UserTableAdapters.un_co_user_detailsTableAdapter userTA = new UserTableAdapters.un_co_user_detailsTableAdapter();

                IEnumerator iEnum = userTA.GetUserById(userId).GetEnumerator();
                if (iEnum.MoveNext())
                {
                    User.un_co_user_detailsRow user = (User.un_co_user_detailsRow)iEnum.Current;
                    ddlCompany.SelectedValue = user.co_id.ToString();
                    tbUserLevel.Text = user.user_level.ToString();
                    tbUserName.Text = user.user_name;
                    tbUserLogon.Text = user.user_logon;
                    tbUserEnableReminder.Text = user.user_enable_reminder;
                    if(user.Isuser_telephoneNull() == false)  tbTelephone.Text = user.user_telephone;
                    if (user.Isuser_tel_extNull() == false) tbTelExt.Text = user.user_tel_ext;
                    if (user.Isuser_tel_mobileNull() == false) tbMobile.Text = user.user_tel_mobile;
                    if (user.Isuser_emailNull() == false) tbEmail.Text = user.user_email;
                    if (user.Isuser_departmentNull() == false) tbDepartment.Text = user.user_department;
                    if (user.Isuser_locationNull() == false) tbLocation.Text = user.user_location;
                    ddlRole.SelectedValue = user.role;
                    btnSave.Visible = false;
                    btnUpdate.Visible = true;
                    ddlCompany.Enabled = false;
                }
            }
        }
    }
Exemplo n.º 2
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        UserTableAdapters.un_co_user_detailsTableAdapter userTA = new UserTableAdapters.un_co_user_detailsTableAdapter();
        if (userTA.GetUserByLogonName(tbUserLogon.Text, (int)Session[WebConstants.Session.REG_USER_ID]).GetEnumerator().MoveNext())
        {
            SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS);
        }
        else
        {
            IEnumerator ieUsers = userTA.GetUserById((int)Session[WebConstants.Session.REG_USER_ID]).GetEnumerator();
            if (ieUsers.MoveNext())
            {
                User.un_co_user_detailsRow user = (User.un_co_user_detailsRow)ieUsers.Current;
                //user.user_name = tbUserName.Text;
                user.user_telephone = tbTelephone.Text;
                user.user_tel_ext = tbTelExt.Text;
                user.user_tel_mobile = tbMobile.Text;
                user.user_email = tbEmail.Text;
                user.user_department = tbDepartment.Text;
                user.user_location = tbLocation.Text;
                user.date_last_amended = DateTime.Now;

                userTA.Update(user);

                TransferTableAdapters.TransferTableAdapter tranTA = new TransferTableAdapters.TransferTableAdapter();
                tranTA.TransferAll(int.Parse(ConfigurationSettings.AppSettings["SourceCompanyId"]),
                    int.Parse(ConfigurationSettings.AppSettings["SourceDepartmentId"]), (int)Session[WebConstants.Session.REG_CO_ID],
                    (int)Session[WebConstants.Session.REG_DEPT_ID], (int)Session[WebConstants.Session.REG_USER_ID]);
                UpdateTrialLicense();
                Session[WebConstants.Session.WIZARD_STEP] = 4;
                Response.Redirect("~/Register/UploadOrders.aspx");
            }
        }
    }
Exemplo n.º 3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        UserTableAdapters.un_co_user_detailsTableAdapter userTA = new UserTableAdapters.un_co_user_detailsTableAdapter();
        if (tbUserEnable.Text != tbConfirmUserEnable.Text)
        {
            SetErrorMessage("Passwords do not match");
            return;
        }
        if (userTA.GetUserByLogonName(tbUserLogon.Text, null).GetEnumerator().MoveNext())
        {
            SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS);
        }
        else
        {
            IEnumerator ie = userTA.InsertAndReturn(false, (int)Session[WebConstants.Session.REG_CO_ID],1, tbUserName.Text, tbUserLogon.Text,
                Utility.GetMd5Sum(tbUserEnable.Text), tbUserEnableReminder.Text, tbTelephone.Text, tbTelExt.Text, tbMobile.Text, tbEmail.Text, tbDepartment.Text,
                tbLocation.Text, null, DateTime.Now, null, DateTime.Now,WebConstants.Roles.User).GetEnumerator();
            if(ie.MoveNext())
            {
                User.un_co_user_detailsRow user = (User.un_co_user_detailsRow)ie.Current;
                Session[WebConstants.Session.REG_USER_ID] = user.user_id;
                SetInfoMessage(WebConstants.Messages.Information.RECORD_SAVED);
                TransferTableAdapters.TransferTableAdapter tranTA = new TransferTableAdapters.TransferTableAdapter();
                tranTA.TransferAll(int.Parse(AppSettings["SourceCompanyId"]),
                    int.Parse(AppSettings["SourceDepartmentId"]), (int)Session[WebConstants.Session.REG_CO_ID],
                    (int)Session[WebConstants.Session.REG_DEPT_ID], user.user_id);
                UpdateTrialLicense();
                Session[WebConstants.Session.WIZARD_STEP] = 4;
                Response.Redirect("~/Register/UploadOrders.aspx");

            }
        }
    }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     UserTableAdapters.un_co_user_detailsTableAdapter ta = new UserTableAdapters.un_co_user_detailsTableAdapter();
     IEnumerator ie = ta.GetAllUsers().GetEnumerator();
     while (ie.MoveNext())
     {
         User.un_co_user_detailsRow user = (User.un_co_user_detailsRow)ie.Current;
         user.user_enable = Utility.GetMd5Sum(user.user_enable);
         ta.Update(user);
     }
 }
Exemplo n.º 5
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     if (IsValid())
     {
         UserTableAdapters.un_co_user_detailsTableAdapter userTA = new UserTableAdapters.un_co_user_detailsTableAdapter();
         if (userTA.GetUserByLogonName(tbUserLogon.Text, int.Parse(Request[WebConstants.Request.USER_ID])).GetEnumerator().MoveNext())
         {
             SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS);
         }
         else
         {
             userTA.Update(int.Parse(tbUserLevel.Text), tbUserName.Text, tbUserLogon.Text, Utility.GetMd5Sum(tbUserEnable.Text), tbUserEnableReminder.Text, tbTelephone.Text,
                 tbTelExt.Text, tbMobile.Text, tbEmail.Text, tbDepartment.Text, tbLocation.Text, loggedInUserId, DateTime.Now, int.Parse(Request[WebConstants.Request.USER_ID]));
             SetInfoMessage(WebConstants.Messages.Information.RECORD_SAVED);
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["userEmail"] != null && Request["clientIP"] != null && Request["key"] != null && Request["key"].Equals("CC17DEC2-5727-4FA8-937A-C4D3107BBE8B"))
     {
         UserTableAdapters.un_co_user_detailsTableAdapter ta = new UserTableAdapters.un_co_user_detailsTableAdapter();
         IEnumerator ie = ta.GetUserByLogonName(Request["userEmail"], null).GetEnumerator();
         if (ie.MoveNext())
         {
             User.un_co_user_detailsRow user = (User.un_co_user_detailsRow)ie.Current;
             Session[WebConstants.Session.USER_ID] = user.user_id;
             Session[WebConstants.Session.USER_ROLE] = user.role;
             Session[WebConstants.Session.USER_CO_ID] = user.co_id;
             Session[WebConstants.Session.COMPANY_NAME] = user.co_name_short;
             TimeSpan SessTimeOut = new TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0);
             Cache.Insert(user.user_id.ToString(), Request["clientIP"], null, DateTime.MaxValue, SessTimeOut, System.Web.Caching.CacheItemPriority.NotRemovable, null);
             Company.un_co_detailsRow company = DatabaseUtility.GetCompany(user.co_id);
             if (company != null && company.flg_show_wizard)
             {
                 Session[WebConstants.Session.REG_CO_ID] = company.co_id;
                 Session[WebConstants.Session.REG_USER_ID] = user.user_id;
                 DepartmentTableAdapters.DepartmentSelectCommandTableAdapter deptTA = new DepartmentTableAdapters.DepartmentSelectCommandTableAdapter();
                 IEnumerator ieDept = deptTA.GetDepartmentsByCoId(company.co_id).GetEnumerator();
                 if (ieDept.MoveNext())
                 {
                     Department.DepartmentSelectCommandRow department = (Department.DepartmentSelectCommandRow)ieDept.Current;
                     Session[WebConstants.Session.REG_DEPT_ID] = department.dept_id;
                 }
                 Response.Redirect("~/Register/AddCompany.aspx");
             }
             else
             {
                 Response.Redirect("~/UserHome.aspx");
             }
         }
         else
         {
             Response.Redirect(ConfigurationManager.AppSettings["SCurl"]);
         }
     }
     else
     {
         Response.Redirect(ConfigurationManager.AppSettings["SCurl"]);
     }
 }
Exemplo n.º 7
0
    public bool Process(Page page,ref int loggedInUserId, ref int loggedInUserCoId, ref string loggedInUserRole)
    {
        bool authenticated = false;
        if (bool.Parse(AppSettings["UseFormsAuthentication"]) == false)
        {
            if (HttpContext.Current.Session[WebConstants.Session.USER_ID] == null)
            {
                HttpContext.Current.Session[WebConstants.Session.RETURN_URL] = HttpContext.Current.Request.Url;
                HttpContext.Current.Response.Redirect("~/Login.aspx?" + WebConstants.Request.SESSION_EXPIRED + "=true");
            }
            else
            {
                loggedInUserId = (int)HttpContext.Current.Session[WebConstants.Session.USER_ID];
                authenticated = true;
            }
        }
        else
        {
            if (page.User.Identity.IsAuthenticated )
            {
                SimplicityEntities databaseContext = new SimplicityEntities();
                Simplicity.Data.Session session = (from ses in databaseContext.Sessions where ses.SessionUID == page.User.Identity.Name select ses).FirstOrDefault();
                int HSProductId = int.Parse(AppSettings["HSProductIDInSimplicity"]);

                UserTableAdapters.un_co_user_detailsTableAdapter userTa = new UserTableAdapters.un_co_user_detailsTableAdapter();
                IEnumerator<User.un_co_user_detailsRow> users = userTa.GetBySimplicityID(session.User.UserID).GetEnumerator();
                if (users.MoveNext())
                {
                    authenticated = true;
                    loggedInUserId = users.Current.user_id;
                    /*if (HttpContext.Current.Cache[loggedInUserId.ToString()] == null)
                    {
                        HandlePostLoginProcess(users.Current.user_id, users.Current.role, users.Current.co_id);
                    }*/
                }
                else
                {
                    HttpContext.Current.Session[WebConstants.Session.RETURN_URL] = HttpContext.Current.Request.Url;
                    HttpContext.Current.Response.Redirect("~/Login.aspx?" + WebConstants.Request.SESSION_EXPIRED + "=true");
                }
            }
            else
            {
                HttpContext.Current.Session[WebConstants.Session.RETURN_URL] = HttpContext.Current.Request.Url;
                HttpContext.Current.Response.Redirect("~/Login.aspx?" + WebConstants.Request.SESSION_EXPIRED + "=true");
            }
        }
        if(authenticated)
        {

            if (HttpContext.Current.Session[WebConstants.Session.USER_ID] == null)
            {
                HttpContext.Current.Session[WebConstants.Session.RETURN_URL] = HttpContext.Current.Request.Url;
                HttpContext.Current.Response.Redirect("~/Login.aspx?" + WebConstants.Request.INVALID_CACHE + "=true");
            }
            else
            {
                if (HttpContext.Current.Session[WebConstants.Session.USER_CO_ID] != null)
                {
                    loggedInUserCoId = (int)HttpContext.Current.Session[WebConstants.Session.USER_CO_ID];
                }
                else
                {
                    //Admin roles dont need a co.
                    loggedInUserCoId = 0;
                }

                if (HttpContext.Current.Session[WebConstants.Session.USER_ROLE] == null)
                {
                    loggedInUserRole = WebConstants.Roles.User;
                }
                else
                {
                    loggedInUserRole = (string)HttpContext.Current.Session[WebConstants.Session.USER_ROLE];
                }
                return true;
            }
        }
        return false;
    }
Exemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[WebConstants.Session.WIZARD_STEP] == null ||
            (int)Session[WebConstants.Session.WIZARD_STEP] < 3)
        {
            Response.Redirect("~/Register/AddDeparment.aspx");
        }
        if (IsPostBack == false)
        {
            if (Session[WebConstants.Session.REG_CO_ID] != null
                && Session[WebConstants.Session.REG_DEPT_ID] != null
                && Session[WebConstants.Session.REG_USER_ID] != null)
            {
                int userId = (int)Session[WebConstants.Session.REG_USER_ID];
                UserTableAdapters.un_co_user_detailsTableAdapter userTA = new UserTableAdapters.un_co_user_detailsTableAdapter();

                IEnumerator iEnum = userTA.GetUserById(userId).GetEnumerator();
                if (iEnum.MoveNext())
                {
                    User.un_co_user_detailsRow user = (User.un_co_user_detailsRow)iEnum.Current;
                    tbUserName.Text = user.user_name;
                    tbUserLogon.Text = user.user_logon;
                    if (user.Isuser_telephoneNull() == false) tbTelephone.Text = user.user_telephone;
                    if (user.Isuser_tel_extNull() == false) tbTelExt.Text = user.user_tel_ext;
                    if (user.Isuser_tel_mobileNull() == false) tbMobile.Text = user.user_tel_mobile;
                    if (user.Isuser_emailNull() == false) tbEmail.Text = user.user_email;
                    if (user.Isuser_departmentNull() == false) tbDepartment.Text = user.user_department;
                    if (user.Isuser_locationNull() == false) tbLocation.Text = user.user_location;
                    btnSave.Visible = false;
                    btnUpdate.Visible = true;
                }
            }
            else
            {
                tbUserEnable.Visible = true;
                tbConfirmUserEnable.Visible = true;
                tbUserEnableReminder.Visible = true;
                tbUserLogon.Enabled = true;
            }
        }
    }