Example #1
0
 private void btnSendReport_Click(object sender, System.EventArgs e)
 {
     string sText, sEmail, sSubj;
     clsUsers user = null;
     try
     {
         user = new clsUsers();
         user.cAction = "S";
         user.iId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
         user.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
         user.UserDetails();
         sText = "The Error Report from " + user.sFirstName.Value + " " + user.sLastName.Value + " [" + user.sEmail.Value + "] at " + DateTime.Now.ToUniversalTime()  + " GMT <br>";
         sText += "Error Description:<br>";
         sText += "-------------------------------------------------------------<br>";
         sText += ViewState["error_report"].ToString();
         sSubj = "The Error Report from FleetPro Application";
         sEmail = _functions.GetValueFromConfig("Report.DevEmail");
         _functions.SendEmail(sEmail, sSubj, sText);
         Response.Redirect(btnSendReport.CommandArgument, false);
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, "error.aspx.cs");
     }
     finally
     {
         if(user != null)
         {
             user.Dispose();
         }
     }
 }
Example #2
0
 private void btnAddGroup_Click(object sender, System.EventArgs e)
 {
     try
     {
         user2 = new clsUsers();
         user2.cAction = "U";
         user2.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
         user2.iGroupId = 0;
         user2.sGroupName = tbGroupName.Text;
         tbGroupName.Text = "";
         if(user2.GroupDetails() == -1)
         {
             Session["lastpage"] = "admin_groups.aspx";
             Session["error"] = _functions.ErrorMessage(117);
             Response.Redirect("error.aspx", false);
             return;
         }
         ShowGroups();
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_groups.aspx";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(user2 != null)
             user2.Dispose();
     }
 }
Example #3
0
 private void ShowGroups()
 {
     try
     {
         user = new clsUsers();
         user.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
         dtGroups = user.GetGroupsList();
         dgGroups.DataSource = new DataView(dtGroups);
         dgGroups.DataBind();
     }
     catch(Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
     finally
     {
         if(user != null)
             user.Dispose();
     }
 }
        /// <summary>
        /// Activating/Inactivating the user account
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            try
            {
                equip = new clsEquipment();
                equip.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                foreach(RepeaterItem _item in repOperatorEquipments.Items)
                {
                    DropDownList ddlOperators = (DropDownList)_item.FindControl("ddlOperators");
                    bool IsNobody = Convert.ToBoolean(ddlOperators.Attributes["IsNobody"]);
                    if(!IsNobody && ddlOperators.SelectedValue == "0")
                    {
                        Header.ErrorMessage = "Operator is required";
                        return;
                    }
                    equip.iOrgId = OrgId;
                    equip.iId = Convert.ToInt32(ddlOperators.Attributes["EquipId"]);
                    equip.iEquipOperatorId = Convert.ToInt32(ddlOperators.SelectedValue);
                    equip.sNote = "Deactivated Operator - Reassigned New Operator";
                    equip.EquipAssignedTo();
                }
                user = new clsUsers();
                user.iOrgId = OrgId;
                user.daCreated = DateTime.Now;
                user.iLoginId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                foreach(RepeaterItem _item in repWorkOrders.Items)
                {
                    DropDownList ddlTechs = (DropDownList)_item.FindControl("ddlTechs");
                    bool IsNobody = Convert.ToBoolean(ddlTechs.Attributes["IsNobody"]);
                    if(!IsNobody && ddlTechs.SelectedValue == "0")
                    {
                        Header.ErrorMessage = "Technician is required";
                        return;
                    }
                    user.iOrderId = Convert.ToInt32(ddlTechs.Attributes["OrderId"]);
                    user.iId = Convert.ToInt32(ddlTechs.SelectedValue);
                    user.SetNewTechToWorkOrder();
                }
                user = new clsUsers();
                user.iOrgId = OrgId;
                user.iId = UserId;
                user.bActiveStatus = (bool)ViewState["Active"];
                if(user.UserActive() == -1)
                {
                    Session["lastpage"] = "admin_user_detail_active.aspx?id=" + UserId.ToString();
                    Session["error"] = _functions.ErrorMessage(134);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                if(UserId == _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true))
                    Response.Redirect("default.aspx", false);
                else
                {
                    // redirect to the finish screen
                    BackFinishScreen finish = new BackFinishScreen();
                    if(((bool)ViewState["Active"]))
                        finish.sMainText = "The user has been activated successfully";
                    else
                        finish.sMainText = "The user has been deactivated successfully";

                    finish.bMainMenuVisible = true;
                    finish.sMainMenuText = "[Return to Main Menu]";
                    finish.sMainMenuURL = "selectMode.aspx";

                    finish.bContinueVisible = false;

                    finish.bViewVisible = true;
                    finish.sViewText = "[View the User Detail]";
                    finish.sViewURL = "admin_user_detail.aspx?id=" + UserId.ToString();

                    finish.bAdditionalVisible = false;

                    finish.bPrintVisible = false;

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                }
            }

            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "admin_user_detail_active.aspx?id=" + UserId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
                if(equip != null)
                    equip.Dispose();
            }
        }
 private void ddlTechnicians_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     try
     {
         user = new clsUsers();
         user.iOrgId = OrgId;
         user.iOrderId = OrderId;
         user.iId = Convert.ToInt32(ddlTechnicians.SelectedValue);
         if(user.GetTechnicianInfo() != -1)
         {
             tbHourlyRate.Text = user.dmHourlyRate.Value.ToString("F");
             if(!user.bTechCanViewHourlyRate.Value)
             {
                 ViewState["HourlyRate"] = user.dmHourlyRate.Value;
                 html_tblMain.Rows[12].Visible = false;
                 html_trTotalCosts.Visible = false;
             }
             else
             {
                 ViewState["HourlyRate"] = null;
                 html_tblMain.Rows[12].Visible = true;
                 html_trTotalCosts.Visible = true;
             }
         }
         else
         {
             html_tblMain.Rows[12].Visible = true;
             html_trTotalCosts.Visible = true;
             tbHourlyRate.Text = "0.0";
             ViewState["HourlyRate"] = null;
         }
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "wo_updateTimeLog.aspx?id=" + OrderId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(user != null)
             user.Dispose();
     }
 }
        private void btNext_FormSubmit(object sender, EventArgs e)
        {
            try
            {
                user = new clsUsers();
                user.iOrgId = OrgId;
                user.sLastName = tbLastName.Text;
                user.sPIN = tbPIN.Text;
                if(user.AuthOperator() != 0)
                {
                    if(!user.bActiveStatus.Value)
                    {
                        lblError.Text = "<ul><li>" + _functions.ErrorMessage(202) + "</li></ul>";
                    }
                    else
                    {
                        Response.Cookies["bfp_operator"].Value =  (new OperatorInfo(user.iId.Value, user.sFirstName.Value)).ToString();
                        Response.Cookies["bfp_operator"].Path = "/";
                        Response.Cookies["bfp_operator"].Expires = DateTime.Now.AddYears(1);

                        Response.Redirect("ok_mainDetails.aspx?id=" + OrderId.ToString() + "&back=authcredentials", false);
                    }
            //					switch(m_sOperation)
            //					{
            //						case "CheckIn":
            //							Response.Redirect("ok_selectEquipment.aspx?orderid=" + OrderId.ToString(), false);
            //							break;
            //						case "CheckOut":
            //							Response.Redirect("ok_selectWorkOrder.aspx?id=" + OrderId.ToString(), false);
            //							break;
            //						case "CheckOutSpare":
            //							Response.Redirect("ok_selectSpareEquip.aspx?op=CheckOutSpare&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString(), false);
            //							break;
            //						case "AddIssue":
            //							Response.Redirect("ok_addIssues.aspx?op=AddIssue&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString(), false);
            //							break;
            //						default:
            //							Response.Redirect("ok_selectEquipment.aspx?orderid=" + OrderId.ToString(), false);
            //							break;
            //					}
                }
                else
                {
                    lblError.Text = "<ul><li>The PIN code is incorrect</li></ul>";
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "ok_authCredentials.aspx?orderid=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
            }
        }
Example #7
0
        private void btLogin_Click(object sender, System.EventArgs e)
        {
            string sUserData;
            string[] roles;
            string roleStr = "";
            DataTable dtGroups = null;
            int iReturn;
            try
            {
                user = new clsUsers();
                user.sEmail = tbEmail.Text;
                user.sPass = tbPassword.Text;
                iReturn = user.Authenticate();
                switch(iReturn)
                {
                    case 0:
                        lbErr.Visible = false;
                        sUserData = user.iId.Value.ToString() + ":" + user.iOrgId.Value.ToString();

                        dtGroups = user.GetUserGroupsList();

                        foreach (DataRow dr in dtGroups.Rows)
                        {
                            roleStr += String.Format("{0};", dr["vchDesc"]);
                        }
                        roleStr = roleStr.Remove(roleStr.Length - 1, 1);

                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                            1,
                            sUserData,
                            DateTime.Now,
                            DateTime.Now.AddHours(1),
                            false,
                            roleStr
                            );

                        roles = roleStr.Split(new char[] {';'});

                        string cookieStr = FormsAuthentication.Encrypt(ticket);

                        Response.Cookies["bfp_roles"].Value = cookieStr;
                        Response.Cookies["bfp_roles"].Path = "/";
                        Response.Cookies["bfp_roles"].Expires = DateTime.Now.AddHours(1);

                        FormsAuthentication.SetAuthCookie(sUserData, true);
                        Response.Redirect("main.aspx", false);
                        break;
                    case 1:
                        tblLogin.Rows[0].Visible = true;
                        tblLogin.Rows[1].Visible = true;
                        tblLogin.Rows[2].Visible = false;
                        tblLogin.Rows[3].Visible = false;
                        tblLogin.Rows[4].Visible = false;
                        ViewState["UserId"] = user.iId.Value;
                        dgOrgs.DataSource = new DataView(user.GetOrgListFromUser());
                        dgOrgs.DataBind();
                        lbErr.Visible = false;
                        break;
                    case -1:
                        lbErr.Visible = true;
                        break;
                    default:
                        lbErr.Visible = true;
                        break;
                }

            }
            catch(Exception ex)
            {
                _functions.Log(ex, "", "default.aspx.cs");
                lbErr.Visible = true;
                lbErr.Text = ex.Message;
            }
            finally
            {
                if(user != null)
                {
                    user.Dispose();
                }
            }
        }
        /// <summary>
        /// Adding the user to selected group
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddGroup_Click(object sender, System.EventArgs e)
        {
            try
            {

                user = new clsUsers();
                user.cAction = "I";
                user.iId = UserId;
                user.iOrgId = OrgId;
                user.iGroupId = Convert.ToInt32(ddlGroup.SelectedValue);
                if(user.UsersGroupsDetail() == -1)
                {
                    Session["lastpage"] = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                    Session["error"] = _functions.ErrorMessage(117);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                // showing the groups after adding
                dgGroups.DataSource = new DataView(user.GetUserGroupsList());
                dgGroups.DataBind();
                ddlGroup.DataSource = new DataView(user.GetGroupsListByNotUser());
                ddlGroup.DataBind();
                if(ddlGroup.Items.Count == 0)
                {
                    ddlGroup.Enabled = false;
                    btnAddGroup.Enabled = false;
                }
                else
                {
                    ddlGroup.Enabled = true;
                    btnAddGroup.Enabled = true;
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
            }
        }
Example #9
0
 /// <summary>
 /// Showing found users
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnFilter_Click(object sender, System.EventArgs e)
 {
     try
     {
         user = new clsUsers();
         user.iOrgId = OrgId;
         user.sFirstName = tbFirstName.Text;
         user.sLastName = tbLastName.Text;
         user.sEmail = tbEmail.Text;
         user.iTypeId = Convert.ToInt32(ddlUserTypes.SelectedValue);
         user.iActiveStatus = Convert.ToInt32(ddlActiveStatus.SelectedValue);
         user.iGroupId = Convert.ToInt32(ddlGroups.SelectedValue);
         uFilter = new UserFilter();
         uFilter.sFirstName = user.sFirstName.Value;
         uFilter.sLastName = user.sLastName.Value;
         uFilter.sEmail = user.sEmail.Value;
         uFilter.iTypeId = user.iTypeId.Value;
         uFilter.iActiveStatus = user.iActiveStatus.Value;
         uFilter.iGroupId = user.iGroupId.Value;
         Session["UserFilter"] = uFilter;
         dgUserList.DataSource = new DataView(user.GetUserList_Filter());
         dgUserList.DataBind();
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_users.aspx";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(user!=null)
             user.Dispose();
     }
 }
        /// <summary>
        /// Adding the user to groups
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddUser_Click(object sender, System.EventArgs e)
        {
            try
            {
                user = new clsUsers();
                user.cAction = "I";
                user.iId = Convert.ToInt32(ddlUsers.SelectedValue);
                user.iOrgId = OrgId;
                user.iGroupId = GroupId;
                if(user.UsersGroupsDetail() == -1)
                {
                    Session["lastpage"] = "admin_groups_users.aspx?id=" + GroupId.ToString();
                    Session["error"] = _functions.ErrorMessage(117);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                else
                    Response.Redirect("admin_groups_users.aspx?id=" + GroupId.ToString(), false);

            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "admin_groups_users.aspx?id=" + GroupId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
            }
        }
 /// <summary>
 /// Deleting user from group
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 private void dgUsers_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         user = new clsUsers();
         user.cAction = "D";
         user.iId = Convert.ToInt32(e.Item.Cells[0].Text);
         user.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
         user.iGroupId = GroupId;
         if(user.UsersGroupsDetail() == -1)
         {
             Session["lastpage"] = "admin_groups_users.aspx?id=" + GroupId.ToString();
             Session["error"] = _functions.ErrorMessage(117);
             Response.Redirect("error.aspx", false);
             return;
         }
         else
             Response.Redirect("admin_groups_users.aspx?id=" + GroupId.ToString(), false);
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_groups_users.aspx?id=" + GroupId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(user != null)
             user.Dispose();
     }
 }
Example #12
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btLogin_Click(object sender, System.EventArgs e)
        {
            string sUserData;
            string[] roles;
            string roleStr = "";
            DataTable dtGroups = null;
            int iReturn;
            try
            {
                lbErr.Visible = false;
                user = new clsUsers();
                user.sEmail = tbEmail.Text;
                // User authenticating
                if(user.Authenticate() == -1)
                {
                    lbErr.Visible = true;
                }
                else
                {
                    if(!user.bActiveStatus.Value)
                    {
                        lbErr.Visible = true;
                        lbErr.Text = _functions.ErrorMessage(202);
                        return;
                    }
                    string dbPasswordHash = user.sPass.Value;
                    string salt = user.sSalt.Value;
                    // Now take the salt and the password entered by the user
                    // and concatenate them together.
                    string passwordAndSalt = String.Concat(tbPassword.Text, salt);
                    // Now hash them
                    string hashedPasswordAndSalt =
                        FormsAuthentication.HashPasswordForStoringInConfigFile(
                        passwordAndSalt,
                        "SHA1");
                    // Now verify them. Returns true if they are equal
                    if(!hashedPasswordAndSalt.Equals(dbPasswordHash))
                    {
                        lbErr.Visible = true;
                    }
                    else
                    {
                        // Getting info about user
                        iReturn = user.LoginInfo();
                        switch(iReturn)
                        {
                            case 0:
                                Response.Cookies["bfp_logo"].Value = user.sLogo.Value;
                                Response.Cookies["bfp_logo"].Path = "/";
                                Response.Cookies["bfp_logo"].Expires = DateTime.Now.AddYears(1);

                                // The authenticate was done successfully
                                lbErr.Visible = false;
                                // Creating the user's identifying string
                                sUserData = user.iId.Value.ToString() + ":" + user.iOrgId.Value.ToString();

                                // creating the roles's string for user from groups list
                                dtGroups = user.GetUserGroupsList();

                                foreach (DataRow dr in dtGroups.Rows)
                                {
                                    roleStr += String.Format("{0};", dr["vchDesc"]);
                                }
                                roleStr = roleStr.Remove(roleStr.Length - 1, 1);

                                // creating a ticket for user with his roles
                                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                                    1,
                                    sUserData,
                                    DateTime.Now,
                                    DateTime.Now.AddYears(1),
                                    false,
                                    roleStr
                                    );

                                roles = roleStr.Split(new char[] {';'});

                                // encrypting ticket for setting to cookie
                                string cookieStr = FormsAuthentication.Encrypt(ticket);

                                Response.Cookies["bfp_roles"].Value = cookieStr;
                                Response.Cookies["bfp_roles"].Path = "/";
                                Response.Cookies["bfp_roles"].Expires = DateTime.Now.AddYears(1);

                                // setting the user's identifying string to cookie
                                FormsAuthentication.SetAuthCookie(sUserData, true);

                                if(Request.QueryString["ReturnUrl"] != null)
                                    Response.Redirect(Request.QueryString["ReturnUrl"], false);
                                else
                                    Response.Redirect("selectMode.aspx", false);
                                break;
                            case 1:
                                // if there are many organization for current user then we are showing they on screen for choosing
                                tblLogin.Rows[0].Visible = true;
                                tblLogin.Rows[1].Visible = true;
                                tblLogin.Rows[2].Visible = false;
                                tblLogin.Rows[3].Visible = false;
                                tblLogin.Rows[4].Visible = false;
                                ViewState["UserId"] = user.iId.Value;
                                dgOrgs.DataSource = new DataView(user.GetOrgListFromUser());
                                dgOrgs.DataBind();
                                lbErr.Visible = false;
                                break;
                            case -1:
                                lbErr.Visible = true;
                                break;
                            default:
                                lbErr.Visible = true;
                                break;
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, "", SourcePageName);
                lbErr.Visible = true;
                lbErr.Text = ex.Message;
            }
            finally
            {
                if(user != null)
                {
                    user.Dispose();
                }
            }
        }
Example #13
0
        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            try
            {
                user = new clsUsers();
                user.iOrgId = OrgId;
                user.sLastName = tbLastName.Text;
                user.sPIN = tbPIN.Text;
                if(user.AuthOperator() != 0)
                {
                    if(!user.bActiveStatus.Value)
                    {
                        Header.ErrorMessage =  "<font size=3>" + _functions.ErrorMessage(202) + "</font>";
                        return;
                    }

                    Response.Cookies["bfp_operator"].Value =  (new OperatorInfo(user.iId.Value, user.sFirstName.Value)).ToString();
                    Response.Cookies["bfp_operator"].Path = "/";
                    Response.Cookies["bfp_operator"].Expires = DateTime.Now.AddYears(1);

            //					 scenario:
            //					 0 - if operator hasn't assigned the redirect to ok_selectEquipment.aspx
            //					 1 - if operator has only one assigned equipment
            //						1.1 - if this equipment is active (i.e. it exists in active table of equipments)
            //						then redirect to screen where operator select operation for this equipment ok_mainDetails.aspx?id=OrderId
            //						1.2 - if equipment is not activety then redirect to ok_selectEquipment.aspx?equipid=EquipId
            //					 2 - If operator has many assigned equipment then redirect to ok_mainMenu2.aspx
            //					 There over, operator select equipment what he will be processing
            //					during selecting, if he select not active equipment then repeat the point 1.2
            //					if active then 1.1
                    switch(user.GetUserInfoForKiosk())
                    {
                        case 0:
                            Response.Redirect("ok_selectEquipment.aspx?orderid=0&back=mainmenu", false);
                            break;
                        case 1:
                            dtOrders = (DataTable)ViewState["ActivityOrders"];
                            DataView dwOrders = new DataView(dtOrders);
                            dwOrders.RowFilter = "EquipId=" + user.iEquipId.Value.ToString();
                            if(dwOrders.Count == 0)
                                Response.Redirect("ok_selectEquipment.aspx?orderid=0&equipid=" + user.iEquipId.Value.ToString() + "&back=mainmenu", false);
                            if(dwOrders.Count == 1)
                                Response.Redirect("ok_mainDetails.aspx?id=" + dwOrders[0]["Id"].ToString() + "&back=mainmenu", false);
                            if(dwOrders.Count > 1)
                                Header.ErrorMessage = "<font size=3>" + _functions.ErrorMessage(165) + "</font>";
                            break;
                        case 2:
                            Response.Redirect("ok_mainMenu2.aspx", false);
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    Header.ErrorMessage = "<font size=3>" + _functions.ErrorMessage(201) + "</font>";
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "ok_mainMenu.aspx";
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
            }
        }
Example #14
0
        private void dgGroups_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            try
            {
                switch(e.CommandName)
                {
                    case "Delete":
                        user2 = new clsUsers();
                        user2.cAction = "D";
                        user2.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                        user2.iGroupId = Convert.ToInt32(e.Item.Cells[0].Text);
                        switch(user2.GroupDetails())
                        {
                            case -1:
                                Session["lastpage"] = "admin_groups.aspx";
                                Session["error"] = _functions.ErrorMessage(117);
                                Response.Redirect("error.aspx", false);
                                return;
                            case 1:
                                Session["lastpage"] = "admin_groups.aspx";
                                Session["error"] = _functions.ErrorMessage(118);
                                Response.Redirect("error.aspx", false);
                                return;
                            case 0:
                                dgGroups.EditItemIndex = -1;
                                ShowGroups();
                                break;
                            default:
                                break;
                        }
                        break;
                    case "Cancel":
                        dgGroups.EditItemIndex = -1;
                        ShowGroups();
                        break;
                    case "Edit":
                        dgGroups.EditItemIndex = e.Item.ItemIndex;
                        ShowGroups();
                        break;
                    case "Update":
                        user2 = new clsUsers();
                        user2.cAction = "U";
                        user2.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                        user2.iGroupId = Convert.ToInt32(((Label)e.Item.FindControl("lblEditId")).Text);
                        user2.sGroupName = ((TextBox)e.Item.FindControl("tbNameEdit")).Text;
                        if(user2.GroupDetails() == -1)
                        {
                            Session["lastpage"] = "admin_groups.aspx";
                            Session["error"] = _functions.ErrorMessage(117);
                            Response.Redirect("error.aspx", false);
                            return;
                        }

                        dgGroups.EditItemIndex = -1;
                        ShowGroups();
                        break;
                    default:
                        break;
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "admin_groups.aspx";
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user2 != null)
                    user2.Dispose();
            }
        }
Example #15
0
        private void dgOrgs_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            string sUserData;
            string[] roles;
            string roleStr = "";
            DataTable dtGroups = null;
            string sOrg;
            try
            {
                lbErr.Visible = false;
                sOrg = ((LinkButton)dgOrgs.SelectedItem.FindControl("lbSelect")).CommandArgument;
                sUserData = ((int)ViewState["UserId"]).ToString() + ":" + sOrg;

                user = new clsUsers();
                user.iOrgId = Convert.ToInt32(sOrg);
                user.iId = (int)ViewState["UserId"];
                dtGroups = user.GetUserGroupsList();

                foreach (DataRow dr in dtGroups.Rows)
                {
                    roleStr += String.Format("{0};", dr["vchDesc"]);
                }
                roleStr = roleStr.Remove(roleStr.Length - 1, 1);

                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                    1,
                    sUserData,
                    DateTime.Now,
                    DateTime.Now.AddHours(1),
                    false,
                    roleStr
                    );

                roles = roleStr.Split(new char[] {';'});

                string cookieStr = FormsAuthentication.Encrypt(ticket);

                Response.Cookies["bfp_roles"].Value = cookieStr;
                Response.Cookies["bfp_roles"].Path = "/";
                Response.Cookies["bfp_roles"].Expires = DateTime.Now.AddHours(1);

                FormsAuthentication.SetAuthCookie(sUserData, true);
                Response.Redirect("main.aspx", false);
            }
            catch(Exception ex)
            {
                lbErr.Visible = true;
                _functions.Log(ex, "", "default.aspx.cs");
                lbErr.Text = ex.Message;
            }
            finally
            {
                if(user != null)
                {
                    user.Dispose();
                }
            }
        }
 private void btnSearch_Click(object sender, System.EventArgs e)
 {
     try
     {
         pnlVerifyOperator.Visible = false;
         pnlSelectOperator.Visible = true;
         user = new clsUsers();
         user.iOrgId = OrgId;
         user.sFirstName = tbFirstName.Text;
         user.sLastName = tbLastName.Text;
         user.sEmail = "";
         user.iGroupId = 0;
         user.iActiveStatus = 0;
         user.iTypeId = (int)UserTypes.All;
         repOperators.DataSource = new DataView(user.GetUserList_Filter());
         repOperators.DataBind();
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "wo_selectOperator.aspx?equipid=" + EquipId.ToString() + "&orderid=" + OrderId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(user != null)
             user.Dispose();
     }
 }
        /// <summary>
        /// Updating the user information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            bool bSavePassword = false, bSavePIN = false;
            string salt;
            try
            {
                user = new clsUsers();
                user.cAction = "U";
                user.iOrgId = OrgId;
                user.iId = UserId;

                if(tbNewPassword.Text.Length > 0 && tbConfirmPassword.Text.Length > 0)
                {
                    if(tbNewPassword.Text != tbConfirmPassword.Text)
                    {
                        lblComfirmPassword.Visible = true;
                        if(tbNewPIN.Text != tbConfirmPIN.Text)
                            lblConfirmPIN.Visible = true;
                        return;
                    }
                    else
                    {
                        bSavePassword = true;
                        lblConfirmPIN.Visible = false;
                    }
                }

                if(tbNewPIN.Text.Length > 0 && tbConfirmPIN.Text.Length > 0)
                {
                    if(tbNewPIN.Text != tbConfirmPIN.Text)
                    {
                        lblConfirmPIN.Visible = true;
                        return;
                    }
                    else
                    {
                        bSavePIN = true;
                        lblConfirmPIN.Visible = false;
                    }
                }

                user.sFirstName = tbFirstName.Text;
                user.sLastName = tbLastName.Text;
                user.sInitials = tbInitial.Text.ToUpper();
                user.sTypeName = ddlType.SelectedValue;
                user.sEmail = tbEmail.Text;
                user.iLoginId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                user.daCreated = DateTime.Now;
                user.dmHourlyRate = Convert.ToDecimal(tbHourlyRate.Text);
                if(user.UserDetails() == -1)
                {
                    Session["lastpage"] = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                    Session["error"] = _functions.ErrorMessage(134);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                if(bSavePassword || UserId == 0)
                {
                    // set a new password
                    salt = _functions.CreateSalt(5);
                    string passwordHash = _functions.CreatePasswordHash(tbNewPassword.Text, salt);

                    user.sPass = passwordHash;
                    user.sSalt = salt;
                    if(user.SetPassword() == -1)
                    {
                        Header.ErrorMessage = _functions.ErrorMessage(134);
                        return;
                    }
                }

                if(bSavePIN || UserId == 0)
                {
                    // set a new PIN code
                    user.sPIN = tbNewPIN.Text;
                    if(user.SetPIN() == -1)
                    {
                        Header.ErrorMessage = _functions.ErrorMessage(134);
                        return;
                    }
                }

                bool bRedirect = false;
                string sText = "";

                if(UserId == 0)
                {
                    bRedirect = true;
                    sText = "A new user has been added successfully!";
                    // adding group to user
                    user.cAction = "I";
                    user.iGroupId = Convert.ToInt32(ddlGroup.SelectedValue);
                    if(user.UsersGroupsDetail() == -1)
                    {
                        Session["lastpage"] = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                        Session["error"] = _functions.ErrorMessage(117);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                }
                else
                {
                    if(bSavePassword || bSavePIN)
                    {
                        bRedirect = true;
                        if(bSavePassword && bSavePIN)
                            sText = "The user's password and PIN Code have been sucessfully updated.";
                        else if(bSavePassword && !bSavePIN)
                            sText = "The user's password have been sucessfully updated.";
                        else if(!bSavePassword && bSavePIN)
                            sText = "The PIN Code have been sucessfully updated.";
                    }
                    else bRedirect = false;
                }
                if(bRedirect)
                {
                    // redirect to the finish screen
                    BackFinishScreen finish = new BackFinishScreen();

                    finish.sMainText = sText;

                    finish.bMainMenuVisible = true;
                    finish.sMainMenuText = "[Return to Main Menu]";
                    finish.sMainMenuURL = "selectMode.aspx";

                    finish.bContinueVisible = false;

                    finish.bViewVisible = true;
                    finish.sViewText = "[View the User Detail]";
                    finish.sViewURL = "admin_user_detail.aspx?id=" + user.iId.Value.ToString();

                    finish.bAdditionalVisible = false;

                    finish.bPrintVisible = false;

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                }
                else
                    Response.Redirect("admin_user_detail.aspx?id=" + user.iId.Value.ToString(), false);
            }
            catch(FormatException fex)
            {
                Header.ErrorMessage = _functions.ErrorMessage(108);
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
            }
        }