Ejemplo n.º 1
0
        /// <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();
            }
        }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 3
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();
         }
     }
 }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        protected int OrgId; //Read from authentication ticket.

        #endregion Fields

        #region Methods

        /// <summary>
        /// Function is returning an access for input page.
        /// </summary>
        /// <param name="pageName">Input page</param>
        /// <returns>The access for input page, false - not permission, true - yes</returns>
        public bool CheckPermission(string pageName)
        {
            bool bResult = false;
            DataView dvPages = null;
            clsUsers user = null;
            try
            {
                if((pageName.ToLower() != "default.aspx") && (pageName.ToLower() != "error.aspx") && (pageName.ToLower() != "accessdenied.aspx"))
                {
                    dvPages = (DataView)Context.Cache["userPages"];
                    if(dvPages == null)
                    {
                        user = new clsUsers();
                        user.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                        dvPages = new DataView(user.GetPagesList());
                        Context.Cache.Insert("userPages", dvPages, null, DateTime.Now.AddHours(12), TimeSpan.Zero);
                    }
                    dvPages.RowFilter = "vchPageName = '" + pageName + "'";
                    if(dvPages.Count > 0)
                    {
                        foreach(string role in dvPages[0]["vchGroupList"].ToString().Split(new char[] {';'}))
                        {
                            if(Context.User.IsInRole(role))
                            {
                                bResult = true;
                            }
                        }
                    }
                    else
                        if(Context.User.IsInRole("Administrators"))
                            bResult = true;
                }
                else
                {
                    bResult = true;
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, "BFPPage.cs");
            }
            finally
            {
                if(user != null)
                {
                    user.Dispose();
                }
            }
            return bResult;
        }
Ejemplo n.º 6
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();
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// The common procedure what will save filled Repair 
        // and his used parts both Add mode and Edit mode.
        /// </summary>
        private void UpdateRepair(bool newRepair)
        {
            double Hours = 0.0;
            try
            {
                //				if(tbNotes.Text.Length > 0)
                //				{
                if (tbMinutes.Text.Length > 0 && Convert.ToDouble(tbMinutes.Text) >= 60)
                {
                    Header.ErrorMessage = _functions.ErrorMessage(206);
                    return;
                }
                if (tbHours.Text.Length > 0 || tbMinutes.Text.Length > 0)
                {
                    if (tbHours.Text.Length > 0) Hours += Convert.ToDouble(tbHours.Text);
                    if (tbMinutes.Text.Length > 0) Hours += Convert.ToDouble(tbMinutes.Text) / 60;
                }
                if (Hours >= 1000)
                {
                    Header.ErrorMessage = _functions.ErrorMessage(203);
                    return;
                }
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.sTypeService = sType;
                order.iItemId = ItemId;
                if (ServiceResult == "Repair")
                    order.iServiceResultId = (int)ServiceResults._Repaired;
                else
                    order.iServiceResultId = (int)ServiceResults._Replaced;
                if (Mode) // Add mode
                {
                    order.iRepairId = 0;
                }
                else // Edit mode
                    order.iRepairId = RepairId;

                if (RepairId == 0 && newRepair)
                {
                    order.iRepairId = preRepairId;
                    order.iInsert = true;
                }

                order.sRepairDesc = tbNotes.Text;
                order.iRepairItemId = Convert.ToInt32(ddlRepairItems.SelectedValue);
                order.iRepairCatId = Convert.ToInt32(ddlRepairCats.SelectedValue);
                if (order.UpdateRepair() == -1)
                {
                    Session["lastpage"] = sCurrentPage;
                    Session["error"] = _functions.ErrorMessage(128);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                RepairId = order.iRepairId.Value;
                // saving the parts for entered repair
                dtParts = (DataTable)ViewState["PartsUsed"];
                foreach (DataRow item in dtParts.Rows)
                {
                    if ((int)item["IsNew"] == 1)
                    {
                        order.cAction = "U";
                        order.iPartUsedId = 0;
                        order.iPartUsedQty = (int)item["Qty"];
                        order.sPartUsedStock = (string)item["Stock"];
                        order.sPartUsedDesc = (string)item["Desc"];
                        order.dmPartUsedCost = (decimal)item["Cost"];
                        order.PartsUsedDetails();
                    }
                    if ((int)item["IsDeleted"] == 1)
                    {
                        order.cAction = "D";
                        order.iPartUsedId = (int)item["Id"];
                        if (order.PartsUsedDetails() == -1)
                        {
                            Session["lastpage"] = sCurrentPage;
                            Session["error"] = _functions.ErrorMessage(125);
                            Response.Redirect("error.aspx", false);
                            return;
                        }
                    }
                }
                if (Mode && html_chNewRepair.Checked && sType == "II")
                {
                    order.iInspectItemId = ItemId;
                    foreach (RepeaterItem item in repReportedIssues.Items)
                    {
                        CheckBox cbTmp = (CheckBox)item.FindControl("cbIssue");
                        if (cbTmp.Checked && cbTmp.Enabled)
                        {
                            order.iReportedIssueId = Convert.ToInt32(cbTmp.Attributes["CommandArgument"]);
                            order.SetAssociationsIssue();
                        }
                    }
                }
                if (Hours > 0.0)
                {
                    user = new clsUsers();
                    user.iOrgId = OrgId;
                    user.iOrderId = OrderId;
                    if (user.GetTechnicianInfo() != -1)
                    {
                        order.cAction = "U";
                        order.iTimeLogId = 0;
                        order.iTechId = user.iId;
                        order.daStartTime = SqlDateTime.Null;
                        order.daStopTime = SqlDateTime.Null;
                        order.dmHours = Convert.ToDecimal(Hours);
                        order.dmHourlyRate = user.dmHourlyRate;
                        order.sNote = tbNotes.Text;
                        order.TimeLogDetails();
                    }
                }
                //				}
                //				else
                //					lblRequestor.Visible = true;
            }
            catch (FormatException fex)
            {
                Header.ErrorMessage = _functions.ErrorMessage(205);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (user != null)
                    user.Dispose();
                if (order != null)
                    order.Dispose();
            }
        }
Ejemplo n.º 8
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                if (Request.QueryString["repairid"] != null && !string.IsNullOrEmpty(Request.QueryString["repairid"]))
                    RepairId = Convert.ToInt32(Request.QueryString["repairid"]);
                if (Request.QueryString["mode"] == null || Request.QueryString["id"] == null || Request.QueryString["repairid"] == null)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    if (Request.QueryString["mode"] == "Add")
                        Mode = true;
                    else
                        Mode = false;
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);

                    if (Request.QueryString["inspectid"] != null)
                        InspectId = Convert.ToInt32(Request.QueryString["inspectid"]);
                    else
                        InspectId = 0;
                    if (Request.QueryString["itemid"] != null)
                        ItemId = Convert.ToInt32(Request.QueryString["itemid"]);
                    else
                        ItemId = 0;
                    if (Request.QueryString["type"] != null)
                        sType = Request.QueryString["type"]; //RI, PMI, II, FREE
                    else
                        sType = "";
                    if (Request.QueryString["op"] != null)
                        ServiceResult = Request.QueryString["op"]; //Repair, Replace
                    else
                        ServiceResult = "";
                    sCurrentPage = "wo_updateRepair.aspx?mode=" + (Mode ? "Add" : "Edit") + "&id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString() + "&inspectid=" + InspectId.ToString() + "&itemid=" + ItemId.ToString() + "&type=" + sType + "&op=" + ServiceResult;
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                // getting the Bread Crumbs from Cookie and add last item
                if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null)
                    Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value;
                Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#Repairs");

                if (sType == "II") // if came from Inspetion screen
                {
                    Header.AddBreadCrumb("Inspection Detail", "/wo_viewCompleteInspection.aspx?id=" + OrderId.ToString() + "&inspectid=" + InspectId.ToString());
                    sLastPage = "wo_viewCompleteInspection.aspx?id=" + OrderId.ToString() + "&inspectid=" + InspectId.ToString();
                }
                else
                    sLastPage = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#Repairs";

                if (Mode)
                    this.PageTitle = "Update Repair";
                else if (sType == "FREE")
                    this.PageTitle = "Add Repair";
                else
                    this.PageTitle = "Edit Repair";
                Header.AddJavaScriptFile("/wo_updateRepair.js");
                Header.BodyOnloadScript = "javascript:CheckEditMode();";

                SaveCancelControl.CausesValidation = false;
                SaveCancelControl.ButtonText = " Save & Back ";
                SaveCancelControl.IsCancel = false;

                ddlRepairCats.Attributes.Add("onchange", "javascript:ValidRepairItems();");
                ddlRepairItems.Attributes.Add("onchange", "javascript:ValidRepairItems();");

                clsWorkOrders orders = new clsWorkOrders();
                string key = orders.GetIntegrationKey(this.OrgId);

                clsUsers user = new clsUsers();
                user.cAction = "S";
                user.iOrgId = OrgId;
                user.iId = _functions.GetUserOrgId(Context.User.Identity.Name, true);
                user.UserDetails();

                if (RepairId == 0)
                {
                    preRepairId = orders.GetRepairPreId();
                    preRepairId++;
                }

                if (string.IsNullOrEmpty(key))
                    WarehousePanel.Visible = false;
                else
                {
                    string url = String.Format(_functions.GetValueFromConfig("WarehouseListnerPage") + "?action=create&key={0}&app=fleet&roid={1}&riid={2}&rufn={3}&ruln={4}&rue={5}&ron={6}&rofn={7}&shipto={8}&shiploc={9}", key, RepairId > 0 ? RepairId.ToString() : preRepairId.ToString(), string.Empty, user.sFirstName.Value, user.sLastName.Value, user.sEmail.Value, "Work Order", OrderId.ToString(), user.sFirstName.Value + " " + user.sLastName.Value, string.Empty);
                    string windowOpenScript = "function openWindow() { window.open('" + url + "','Warehouse','height=600,width=900,toolbar=0,status=1,location=0,menubar=0,scrollbars=1,resizable=1'); }";

                    if (!Page.ClientScript.IsClientScriptBlockRegistered("openWindow"))
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "openWindow", windowOpenScript, true);
                }

                if (!IsPostBack)
                {
                    order = new clsWorkOrders();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    order.iRepairId = RepairId;

                    dsRepairItemsCats = order.GetRepairItemsAndCats();

                    dsRepairItemsCats.Relations.Add(new DataRelation("Cats_Items", dsRepairItemsCats.Tables["Table"].Columns["Id"], dsRepairItemsCats.Tables["Table1"].Columns["CatId"]));

                    ddlRepairCats.DataSource = dsRepairItemsCats;
                    ddlRepairCats.DataBind();

                    ddlRepairItems.DataSource = dsRepairItemsCats;
                    ddlRepairItems.DataBind();

                    ListLink.DataBind();

                    if (Mode) // Add Mode
                    {
                        order.sTypeService = sType;
                        order.iItemId = ItemId;

                        if (sType == "II")
                        {
                            lblTableTitle.Text = "Please check the following to update any reported issues associated with this Inspection item";
                            DataTable dtReportedIssues = order.GetReportedIssuesListUpdate();
                            if (dtReportedIssues.Rows.Count > 0)
                            {
                                repReportedIssues.DataSource = new DataView(dtReportedIssues);
                                repReportedIssues.DataBind();
                            }
                            else
                            {
                                lblTableTitle.Text = "Serviced Repairs";
                                repReportedIssues.Visible = false;
                            }
                        }
                        else
                        {
                            lblTableTitle.Text = "Serviced Repairs";
                            repReportedIssues.Visible = false;
                        }

                        // showing all repaires with associations
                        repRepairs.DataSource = new DataView(order.GetRepairsListUpdate());
                        repRepairs.DataBind();

                        order.GetIssueInfo();

                        lblSourceType.Text = order.sTypeService.Value;
                        lblRepairCategory.Text = order.sRepairCatName.Value;
                        lblIssue.Text = order.sServiceName.Value;
                    }
                    else // Edit Mode
                    {
                        // hidding the controls for Edit mode
                        tblSource.Visible = false;
                        lblTableTitle.Text = "Repair";
                        repRepairs.Visible = false;
                        html_chNewRepair.Visible = false;
                        lblTableFooter.Visible = false;
                        RepairLogsLinksPanel.Visible = false;

                        // getting repair's info
                        order.RepairCommonDetails();
                        ddlRepairCats.SelectedValue = order.iRepairCatId.Value.ToString();
                        ddlRepairItems.SelectedValue = order.iRepairItemId.Value.ToString();
                        tbNotes.Text = order.sRepairDesc.Value;
                    }
                    dtParts = order.GetPartsUsedList();
                    ViewState["PartsUsed"] = dtParts;
                    dwParts = new DataView(dtParts);
                    dwParts.RowFilter = "IsDeleted=0";
                    repParts.DataSource = dwParts;
                    repParts.DataBind();
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = sLastPage;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (order != null)
                    order.Dispose();
            }
        }
Ejemplo n.º 9
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if(Request.QueryString["select"] == null)
                    sSelect = "AddOrder";
                else
                    sSelect = Convert.ToString(Request.QueryString["select"]);

                dgMainList.Controls.Clear();

                if(!IsPostBack)
                {
                    equip = new clsEquipment();
                    loc = new clsLocations();
                    dep = new clsDepartments();
                    user = new clsUsers();

                    equip.cAction = "S";
                    equip.iOrgId = OrgId;

                    ddlEquipTypes.DataSource = new DataView(equip.GetEquipTypesList());
                    ddlEquipTypes.DataBind();
                    ddlEquipTypes.Items.Insert(0, new ListItem("All","0"));

                    dep.iOrgId = OrgId;
                    ddlDepartments.DataSource = new DataView(dep.GetDepartmentsList());
                    ddlDepartments.DataBind();
                    ddlDepartments.Items.Insert(0, new ListItem("All","0"));

                    loc.iOrgId = OrgId;
                    ddlLocations.DataSource = new DataView(loc.GetLocationsList());
                    ddlLocations.DataBind();
                    ddlLocations.Items.Insert(0, new ListItem("All","0"));

                    user.iOrgId = OrgId;
                    user.iTypeId = (int)UserTypes.Operator;
                    ddlDrivers.DataSource = new DataView(user.GetUserListByType());
                    ddlDrivers.DataBind();
                    ddlDrivers.Items[0].Text = "All";

                    if(Session["EquipFilter"] == null)
                    {
            //						if(ddlDrivers.Items.FindByValue(_functions.GetUserOrgId(Context.User.Identity.Name, true).ToString()) != null)
            //							ddlDrivers.SelectedValue = _functions.GetUserOrgId(Context.User.Identity.Name, true).ToString();

                        equip.iTypeId = Convert.ToInt32(ddlEquipTypes.SelectedValue);
                        equip.iDeptId = Convert.ToInt32(ddlDepartments.SelectedValue);
                        equip.iLocId = Convert.ToInt32(ddlLocations.SelectedValue);
                        equip.iIsSpare = Convert.ToInt32(ddlSpare.SelectedValue);
                        equip.iUserId = Convert.ToInt32(ddlDrivers.SelectedValue);
                        equip.sEquipId_Filter = _functions.ConvertToSQLFilter(tbEquipId.Text);

                        eFilter = new EquipFilter();
                        eFilter.iTypeId = equip.iTypeId.Value;
                        eFilter.iIsSpare = equip.iIsSpare.Value;
                        eFilter.iDeptId = equip.iDeptId.Value;
                        eFilter.iLocId = equip.iLocId.Value;
                        eFilter.iOperatorId = equip.iUserId.Value;
                        eFilter.sEquipId = equip.sEquipId_Filter.Value;
                        Session["EquipFilter"] = eFilter;
                    }
                    else
                    {
                        eFilter = (EquipFilter)Session["EquipFilter"];
                        ddlEquipTypes.Items.FindByValue(eFilter.iTypeId.ToString()).Selected = true;
                        ddlSpare.Items.FindByValue(eFilter.iIsSpare.ToString()).Selected = true;
                        ddlDepartments.Items.FindByValue(eFilter.iDeptId.ToString()).Selected = true;
                        ddlLocations.Items.FindByValue(eFilter.iLocId.ToString()).Selected = true;
                        ddlDrivers.Items.FindByValue(eFilter.iOperatorId.ToString()).Selected = true;
                        tbEquipId.Text = _functions.ConvertFromSQLFilter(eFilter.sEquipId);

                        equip.iTypeId = eFilter.iTypeId;
                        equip.iDeptId = eFilter.iDeptId;
                        equip.iLocId = eFilter.iLocId;
                        equip.iIsSpare = eFilter.iIsSpare;
                        equip.iUserId = eFilter.iOperatorId;
                        equip.sEquipId_Filter = eFilter.sEquipId;
                    }

                    switch(sSelect)
                    {
                        case "AddOrder":
                            m_bShowUnassigned = false;
                            equip.sLink = "wo_existingWorkOrders.aspx";
                            break;
                        case "AddPastOrder":
                            m_bShowUnassigned = false;
                            equip.sLink = "wo_editAddInfo.aspx";
                            break;
                        case "AddIssue":
                            m_bShowUnassigned = false;
                            equip.sLink = "manageIssues.aspx";
                            break;
                        case "AddRoadside":
                            m_bShowUnassigned = false;
                            equip.sLink = "wo_selectOperator.aspx";
                            break;
                        case "ChangeTempOper":
                            m_bShowUnassigned = true;
                            equip.sLink = "e_selectTempOperator.aspx";
                            break;
                        default:
                            m_bShowUnassigned = false;
                            equip.sLink = "wo_existingWorkOrders.aspx";
                            break;
                    }

                    //dtEquipments = equip.GetEquipList_Filter(m_bShowUnassigned);
                    dtEquipments = equip.GetEquipList_Filter(true);
                    dgMainList.DataSource = new DataView(dtEquipments);
                    dgMainList.DataBind();

                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = ParentPageURL;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(equip != null)
                    equip.Dispose();
                if(loc != null)
                    loc.Dispose();
                if(dep != null)
                    dep.Dispose();
                if(user != null)
                    user.Dispose();
            }
        }
Ejemplo n.º 10
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();
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "admin_users.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    UserId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "admin_users.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                Header.AddBreadCrumb("Home", "/selectMode.aspx");
                Header.AddBreadCrumb("Administration", "/admin.aspx");
                Header.AddBreadCrumb("User Search", "/admin_users.aspx");
                Header.AddBreadCrumb("User Detail", "/admin_user_detail.aspx?id=" + UserId.ToString());
                Header.AddBreadCrumb("User Detail Edit", "/admin_user_detail_edit.aspx?id=" + UserId.ToString());

                this.PageTitle = "User Detail Activate";
                Header.LeftBarHtml = "User Activating/Deactivating";

                SaveCancelControl.ParentPageURL= this.ParentPageURL;

                if(!IsPostBack)
                {
                    user = new clsUsers();
                    user.cAction = "S";
                    user.iOrgId = OrgId;
                    user.iId = UserId;

                    if(user.UserDetails() == -1)
                    {
                        Session["lastpage"] = "admin_user_detail.aspx?id=" + UserId.ToString();
                        Session["error"] = _functions.ErrorMessage(134);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblFirstName.Text = user.sFirstName.Value;
                    lblLastName.Text = user.sLastName.Value;
                    lblEmail.Text = user.sEmail.Value;
                    lblType.Text = user.sTypeName.Value;
                    lblCreatedDate.Text = user.daCreated.Value.ToLongDateString() + " " + user.daCreated.Value.ToLongTimeString();
                    if(user.bActiveStatus.Value)
                    {
                        ViewState["Active"] = false;
                        lblUserActivateStatus.Text = "Activated";
                        SaveCancelControl.ButtonText = "Deactivate";
                        user.iTypeId = (int)UserTypes.Operator;
                        dtOperators = user.GetUserListByType();
                        ViewState["Operators"] = dtOperators;
                        user.iTypeId = (int)UserTypes.Technician;
                        dtTechnicians = user.GetUserListByType();
                        ViewState["Technicians"] = dtTechnicians;
                        equip = new clsEquipment();
                        equip.iOrgId = OrgId;
                        equip.iUserId = UserId;
                        DataTable dtEquipOrders = equip.GetEquipListByOperatorActivate();
                        if(dtEquipOrders.Rows.Count > 0)
                        {
                            repOperatorEquipments.DataSource = new DataView(dtEquipOrders);
                            repOperatorEquipments.DataBind();
                        }
                        else
                        {
                            tblMain.Rows[8].Visible = false;
                            tblMain.Rows[9].Visible = false;
                            tblMain.Rows[10].Visible = false;
                        }
                        DataTable dtTechOrders = equip.GetOrderListByTechnicianActivate();
                        if(dtTechOrders.Rows.Count > 0)
                        {
                            repWorkOrders.DataSource = new DataView(dtTechOrders);
                            repWorkOrders.DataBind();
                        }
                        else
                        {
                            tblMain.Rows[11].Visible = false;
                            tblMain.Rows[12].Visible = false;
                            tblMain.Rows[13].Visible = false;
                        }
                    }
                    else
                    {
                        ViewState["Active"] = true;
                        lblUserActivateStatus.Text = "Deactivated";
                        SaveCancelControl.ButtonText = "Activate";
                        tblMain.Rows[8].Visible = false;
                        tblMain.Rows[9].Visible = false;
                        tblMain.Rows[10].Visible = false;
                        tblMain.Rows[11].Visible = false;
                        tblMain.Rows[12].Visible = false;
                        tblMain.Rows[13].Visible = false;
                    }
                }
            }
            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();
                if(equip != null)
                    equip.Dispose();
            }
        }
Ejemplo n.º 12
0
 protected void CheckLinks(System.Web.UI.Page _page)
 {
     System.Web.UI.WebControls.HyperLink hlItem;
     string pageName;
     DataView dvPages = null;
     clsUsers user = null;
     try
     {
         foreach(System.Web.UI.Control _MainControl in _page.Controls)
         {
             if(_MainControl.GetType().FullName == "System.Web.UI.HtmlControls.HtmlForm")
             {
                 foreach(System.Web.UI.Control _control in _MainControl.Controls)
                 {
                     if(_control.GetType().FullName == "System.Web.UI.WebControls.HyperLink")
                     {
                         hlItem = (System.Web.UI.WebControls.HyperLink)_control;
                         hlItem.Visible = false;
                         pageName = _functions.GetFileNameFromURL(hlItem.NavigateUrl);
                         if((pageName.ToLower() != "default.aspx") && (pageName.ToLower() != "error.aspx") && (pageName.ToLower() != "accessdenied.aspx"))
                         {
                             dvPages = (DataView)Context.Cache["userPages"];
                             if(dvPages == null)
                             {
                                 user = new clsUsers();
                                 user.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                                 dvPages = new DataView(user.GetPagesList());
                                 Context.Cache.Insert("userPages", dvPages, null, DateTime.Now.AddHours(12), TimeSpan.Zero);
                             }
                             dvPages.RowFilter = "vchPageName = '" + pageName + "'";
                             if(dvPages.Count > 0)
                             {
                                 foreach(string role in dvPages[0]["vchGroupList"].ToString().Split(new char[] {';'}))
                                 {
                                     if(Context.User.IsInRole(role))
                                     {
                                         hlItem.Visible = true;
                                     }
                                 }
                             }
                             else
                                 if(Context.User.IsInRole("Administrators"))
                                 hlItem.Visible = true;
                         }
                         else
                         {
                             hlItem.Visible = true;
                         }
                     }
                 }
                 return;
             }
         }
     }
     catch(Exception ex)
     {
         _functions.Log("Application error: \n" + ex.ToString());
     }
     finally
     {
         if(user != null)
         {
             user.Dispose();
         }
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                Session["PathToViewOrder"] = "EquipWOReport";

                if(!IsPostBack)
                {
                    dtCurrentDate = DateTime.Now;
                    adtEndDate.Date = dtCurrentDate;
                    adtStartDate.Date = dtCurrentDate.AddDays(-365);

                    order = new clsWorkOrders();
                    order.iOrgId = OrgId;

                    dsRepairItemsCats = order.GetRepairItemsAndCats();

                    ddlRepairCats.DataSource = dsRepairItemsCats;
                    ddlRepairCats.DataBind();
                    ddlRepairCats.Items[0].Text = "All";

                    ddlWOTypes.DataSource = order.GetTypesList();
                    ddlWOTypes.DataBind();
                    ddlWOTypes.Items.Insert(0, new ListItem("All","0"));

                    user = new clsUsers();
                    user.iOrgId = OrgId;
                    user.iTypeId = (int)UserTypes.Technician;
                    ddlTech.DataSource = new DataView(user.GetUserListByType());
                    ddlTech.DataBind();
                    ddlTech.Items[0].Text = "All";

                    user.iTypeId = (int)UserTypes.Operator;
                    ddlOperators.DataSource = new DataView(user.GetUserListByType());
                    ddlOperators.DataBind();
                    ddlOperators.Items[0].Text = "All";

                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "main.aspx";
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
                if(order != null)
                    order.Dispose();
            }
        }
Ejemplo n.º 14
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();
                }
            }
        }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 16
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     try
     {
         OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
         if(!IsPostBack)
         {
             user = new clsUsers();
             user.iOrgId = OrgId;
             DataTable dtGroups = user.GetGroupsList();
             DataRow _row = dtGroups.NewRow();
             _row["Id"] = 0;
             _row["vchDesc"] = "All";
             _row["CanDelete"] = false;
             dtGroups.Rows.Add(_row);
             DataView dwGroups = new DataView(dtGroups);
             dwGroups.Sort = "Id asc";
             ddlGroups.DataSource = dwGroups;
             ddlGroups.DataBind();
             if(Session["UserFilter"] != null)
             {
                 uFilter = (UserFilter)Session["UserFilter"];
                 user.sFirstName = uFilter.sFirstName;
                 user.sLastName = uFilter.sLastName;
                 user.sEmail = uFilter.sEmail;
                 user.iTypeId = uFilter.iTypeId;
                 user.iActiveStatus = uFilter.iActiveStatus;
                 user.iGroupId = uFilter.iGroupId;
                 dgUserList.DataSource = new DataView(user.GetUserList_Filter());
                 dgUserList.DataBind();
                 tbFirstName.Text = uFilter.sFirstName;
                 tbLastName.Text = uFilter.sLastName;
                 tbEmail.Text = uFilter.sEmail;
                 ddlUserTypes.SelectedValue = uFilter.iTypeId.ToString();
                 ddlActiveStatus.SelectedValue = uFilter.iActiveStatus.ToString();
                 ddlGroups.SelectedValue = uFilter.iGroupId.ToString();
             }
         }
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin.aspx";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(user!=null)
             user.Dispose();
     }
 }
Ejemplo n.º 17
0
 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();
     }
 }
Ejemplo n.º 18
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string sBackPage;
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "admin_users.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    UserId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "admin_users.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                lblBack.Text = "<input type=button value=\" Back \" onclick=\"document.location='admin_users.aspx'\">";
                if(!IsPostBack)
                {
                    hlUserEdit.NavigateUrl = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                    user = new clsUsers();
                    user.cAction = "S";
                    user.iOrgId = OrgId;
                    user.iId = UserId;
                    if(user.UserDetails() == -1)
                    {
                        Session["lastpage"] = "admin_user_detail.aspx?id=" + UserId.ToString();
                        Session["error"] = _functions.ErrorMessage(134);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblFirstName.Text = user.sFirstName.Value;
                    lblLastName.Text = user.sLastName.Value;
                    lblType.Text = user.sTypeName.Value;
                    lblEmail.Text = user.sEmail.Value;
                    lblHourlyRate.Text = user.dmHourlyRate.Value.ToString("C");
                    lblCreatedDate.Text = user.daCreated.Value.ToLongDateString() + " " + user.daCreated.Value.ToLongTimeString();
                    if(user.bActiveStatus.Value)
                    {
                        lblUserActivateStatus.Text = "Activated";
                    }
                    else
                    {
                        lblUserActivateStatus.Text = "Deactivated";
                    }
                    dgGroups.DataSource = new DataView(user.GetUserGroupsList());
                    dgGroups.DataBind();
                    equip = new clsEquipment();
                    equip.iOrgId = OrgId;
                    equip.iUserId = UserId;
                    dgEquipments.DataSource = new DataView(equip.GetEquipListByUser());
                    dgEquipments.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(equip != null)
                    equip.Dispose();
                if(user != null)
                    user.Dispose();
            }
        }
Ejemplo n.º 19
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                    OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                if(Request.QueryString["repairid"] != null)
                    RepairId = Convert.ToInt32(Request.QueryString["repairid"]);
                else
                    RepairId = 0;

                html_btnBack.Attributes.Add("onclick", "document.location='wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#TimeLog';");
                if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null)
                    Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value;
                Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString());
                dtNow = DateTime.Now;
                if(!IsPostBack)
                {
                    rdiStartTime.SelectedDate = dtNow;
                    rdiStopTime.SelectedDate = dtNow;
                    order = new clsWorkOrders();
                    user = new clsUsers();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    user.iOrgId = OrgId;
                    user.iOrderId = OrderId;
                    user.iTypeId = (int)UserTypes.Technician;

                    DataTable dtTechList = user.GetUserListByType();
                    dtTechList.Rows[0].Delete();
                    ddlTechnicians.DataSource = new DataView(dtTechList);
                    ddlTechnicians.DataBind();

                    DataTable dtRepairList = order.GetRepairsShortList();
                    dtRepairList.Rows[0].Delete();
                    ddlRepairs.DataSource = new DataView(dtRepairList);
                    ddlRepairs.DataBind();

                    if(order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = this.ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    if(!user.IsTechnician(_functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true)))
                    {
                        Session["lastpage"] = this.ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(131);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    lblEquipId.Text = order.sEquipId.Value;
                    lblOperator.Text = order.sOperatorName.Value;
                    lblTech.Text = order.sTechName.Value;
                    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_trTotalCosts.Visible = true;
                        html_tblMain.Rows[12].Visible = true;
                        tbHourlyRate.Text = "0.0";
                        ViewState["HourlyRate"] = null;
                    }
                    if(ddlTechnicians.Items.FindByValue(order.iTechId.Value.ToString()) != null)
                    {
                        ddlTechnicians.SelectedValue = order.iTechId.Value.ToString();
                    }
                    else
                    {
                        ddlTechnicians.SelectedIndex = 0;
                    }
                    if(ddlRepairs.Items.FindByValue(RepairId.ToString()) != null)
                    {
                        ddlRepairs.SelectedValue = RepairId.ToString();
                    }
                    else
                    {
                        ddlRepairs.SelectedIndex = 0;
                    }
                    order.iTechId = 0;
                    dtTimeLog = order.GetTimeLogList();
                    if(dtTimeLog.Rows.Count > 0)
                    {
                        repTimeLog.DataSource = new DataView(dtTimeLog);
                        repTimeLog.DataBind();
                        html_tblNoneTimeLog.Visible = false;
                        lblTotalHours.Text = order.sReportDesc.Value;
                        lblTotalCosts.Text = order.sDecs.Value;
                    }
                    else
                    {
                        html_tblNoneTimeLog.Visible = true;
                        repTimeLog.Visible = false;
                        html_trTotalHours.Visible = false;
                        html_trTotalCosts.Visible = false;
                    }
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = this.ParentPageURL;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
                if(order != null)
                    order.Dispose();
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// DataBinding te RepairList and PartsList
        /// </summary>
        private void ShowRepairList()
        {
            try
            {
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.iTechId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);

                dtRepairs = order.GetRepairsList();
                if(dtRepairs.Rows.Count > 0)
                    html_tblNoneRepairs.Visible = false;
                else
                    html_tblNoneRepairs.Visible = true;

                repRepairs.DataSource = new DataView(dtRepairs);
                repRepairs.DataBind();

                dtPartsUsed = order.GetPartsUsedListForOrder();
                if(dtPartsUsed.Rows.Count > 0)
                    html_tblNoneParts.Visible = false;
                else
                    html_tblNoneParts.Visible = true;

                repPartsUsed.DataSource = new DataView(dtPartsUsed);
                repPartsUsed.DataBind();

                if(order.GetCompleteAbleOrder() == 1)
                    hlCloseOrder.Enabled = true;
                else
                    hlCloseOrder.Enabled = false;

                if(order.GetDeleteAbleOrder() == 1)
                    hlDeleteOrder.Enabled = true;
                else
                    hlDeleteOrder.Enabled = false;

                order.iId = OrderId;
                order.iTechId = 0;
                DataTable dtTimeLog = order.GetTimeLogList();
                if(dtTimeLog.Rows.Count > 0)
                {
                    repTimeLog.DataSource = new DataView(dtTimeLog);
                    repTimeLog.DataBind();
                    html_tblNoneTimeLog.Visible = false;
                    lblTotalHours.Text = order.sReportDesc.Value;
                    lblTotalCosts.Text = order.sDecs.Value;
                    user = new clsUsers();
                    user.iOrgId = OrgId;
                    user.iOrderId = OrderId;
                    if(user.GetTechnicianInfo() != -1)
                        if(!user.bTechCanViewHourlyRate.Value)
                            html_trTotalCosts.Visible = false;
                        else
                            html_trTotalCosts.Visible = true;
                }
                else
                {
                    repTimeLog.Visible = false;
                    html_tblNoneTimeLog.Visible = true;
                    html_trTotalHours.Visible = false;
                    html_trTotalCosts.Visible = false;
                }

            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Ejemplo n.º 21
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            int UserId;
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if(!IsPostBack)
                {
                    equip = new clsEquipment();
                    loc = new clsLocations();
                    dep = new clsDepartments();
                    user = new clsUsers();

                    equip.iOrgId = OrgId;

                    ddlEquipTypes.DataSource = new DataView(equip.GetEquipTypesList());
                    ddlEquipTypes.DataBind();
                    ddlEquipTypes.Items.Insert(0, new ListItem("All","0"));

                    dep.iOrgId = OrgId;
                    ddlDepartments.DataSource = new DataView(dep.GetDepartmentsList());
                    ddlDepartments.DataBind();
                    ddlDepartments.Items.Insert(0, new ListItem("All","0"));

                    loc.iOrgId = OrgId;
                    ddlLocations.DataSource = new DataView(loc.GetLocationsList());
                    ddlLocations.DataBind();
                    ddlLocations.Items.Insert(0, new ListItem("All","0"));

                    user.iOrgId = OrgId;
                    user.iTypeId = (int)UserTypes.Operator;
                    ddlDrivers.DataSource = new DataView(user.GetUserListByType());
                    ddlDrivers.DataBind();
                    ddlDrivers.Items[0].Text = "All";

                    if(Session["EquipFilter"] == null)
                    {
                        UserId = _functions.GetUserOrgId(Context.User.Identity.Name, true);
            //						if(ddlDrivers.Items.FindByValue(UserId.ToString()) != null)
            //							ddlDrivers.SelectedValue = UserId.ToString();

                        equip.iTypeId = Convert.ToInt32(ddlEquipTypes.SelectedValue);
                        equip.iDeptId = Convert.ToInt32(ddlDepartments.SelectedValue);
                        equip.iLocId = Convert.ToInt32(ddlLocations.SelectedValue);
                        equip.iUserId = Convert.ToInt32(ddlDrivers.SelectedValue);
                        equip.iIsSpare = Convert.ToInt32(ddlSpare.SelectedValue);
                        equip.sEquipId_Filter = _functions.ConvertToSQLFilter(tbEquipId.Text);

                        eFilter = new EquipFilter();
                        eFilter.iTypeId = equip.iTypeId.Value;
                        eFilter.iDeptId = equip.iDeptId.Value;
                        eFilter.iLocId = equip.iLocId.Value;
                        eFilter.iIsSpare = equip.iIsSpare.Value;
                        eFilter.iOperatorId = equip.iUserId.Value;
                        eFilter.sEquipId = equip.sEquipId_Filter.Value;
                        Session["EquipFilter"] = eFilter;
                    }
                    else
                    {
                        eFilter = (EquipFilter)Session["EquipFilter"];
                        ddlEquipTypes.Items.FindByValue(eFilter.iTypeId.ToString()).Selected = true;
                        ddlSpare.Items.FindByValue(eFilter.iIsSpare.ToString()).Selected = true;
                        ddlDepartments.Items.FindByValue(eFilter.iDeptId.ToString()).Selected = true;
                        ddlLocations.Items.FindByValue(eFilter.iLocId.ToString()).Selected = true;
                        ddlDrivers.Items.FindByValue(eFilter.iOperatorId.ToString()).Selected = true;
                        tbEquipId.Text = _functions.ConvertFromSQLFilter(eFilter.sEquipId);

                        equip.iTypeId = eFilter.iTypeId;
                        equip.iDeptId = eFilter.iDeptId;
                        equip.iLocId = eFilter.iLocId;
                        equip.iIsSpare = eFilter.iIsSpare;
                        equip.iUserId = eFilter.iOperatorId;
                        equip.sEquipId_Filter = eFilter.sEquipId;
                    }

                    ShowList();

                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = ParentPageURL;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(equip != null)
                    equip.Dispose();
                if(loc != null)
                    loc.Dispose();
                if(dep != null)
                    dep.Dispose();
                if(user != null)
                    user.Dispose();
            }
        }
Ejemplo n.º 22
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();
            }
        }
        /// <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();
            }
        }
Ejemplo n.º 24
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if((Request.QueryString["equipid"] == null) || (Request.QueryString["orderid"] == null))
                {
                    Session["lastpage"] = "wo_default.aspx?select=AddRoadside";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    EquipId = Convert.ToInt32(Request.QueryString["equipid"]);
                    OrderId = Convert.ToInt32(Request.QueryString["orderid"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "wo_default.aspx?select=AddRoadside";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                NextBackControl.BackPage = this.ParentPageURL;
                NextBackControl.BackVisible = true;
                NextBackControl.CausesValidation = true;

                if(!IsPostBack)
                {
                    pnlVerifyOperator.Visible = true;

                    user = new clsUsers();
                    user.iOrgId = OrgId;
                    user.iTypeId = (int)UserTypes.Technician;

                    ddlTech.DataSource = new DataView(user.GetUserListByType());
                    ddlTech.DataBind();

                    EquipmentDetails();
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_default.aspx?select=AddRoadside";
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
            }
        }
Ejemplo n.º 25
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string sTypeName;
            string sDomenName;
            string sReportPath;
            try{
                int l_iCount;

                #region Header Section
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                if((string)Session["PathToViewOrder"] != "Monthly-Daily")
                    l_iCount = 2;
                else
                    l_iCount = 3;

                Header.AddJavaScriptFile("/OpenWindows.js");

                Header.AddBreadCrumb("Home", "/main.aspx");

                switch((string)Session["PathToViewOrder"])
                {
                    case "Monthly-Daily":
                        Header.AddBreadCrumb("Monthly Work Orders View", "/wo_showOrdersForMonthly.aspx");
                        Header.AddBreadCrumb("Daily Work Orders View", "/wo_showOrdersForDaily.aspx");
                        m_sLastPage = "wo_showOrdersForDaily.aspx";
                        break;
                    case "Monthly":
                        Header.AddBreadCrumb("Monthly Work Orders View", "/wo_showOrdersForMonthly.aspx");
                        m_sLastPage = "wo_showOrdersForMonthly.aspx";
                        break;
                    case "Daily":
                        Header.AddBreadCrumb("Daily Work Orders View", "/wo_showOrdersForDaily.aspx");
                        m_sLastPage = "wo_showOrdersForDaily.aspx";
                        break;
                    case "Today":
                        Header.AddBreadCrumb("Work Orders Overview", "/wo_showOrdersForToday.aspx");
                        m_sLastPage = "wo_showOrdersForToday.aspx";
                        break;
                    case "Weekly":
                        Header.AddBreadCrumb("Weekly Work Orders View", "/wo_showOrdersForWeekly.aspx");
                        m_sLastPage = "wo_showOrdersForWeekly.aspx";
                        break;
                    case "Scheduled":
                        Header.AddBreadCrumb("The Scheduled Orders", "/wo_showUnassignedOrders.aspx");
                        m_sLastPage = "wo_showUnassignedOrders.aspx";
                        break;
                    case "Completed":
                        Header.AddBreadCrumb("Completed Work Orders", "/wo_showCompletedOrders.aspx");
                        m_sLastPage = "wo_showCompletedOrders.aspx";
                        break;
                    case "EquipWOReport":
                        Header.AddBreadCrumb("Equipment Work Order Report", "/wo_viewEquipWorkOrderReport.aspx");
                        m_sLastPage = "wo_viewEquipWorkOrderReport.aspx";
                        break;
                    default:
                        Header.AddBreadCrumb("Work Orders Overview", "/wo_showOrdersForToday.aspx");
                        m_sLastPage = "wo_showOrdersForToday.aspx";
                        break;
                }
                Response.Cookies["bfp_navigate"].Value = Header.BrdCrumbsSerialization;
                Response.Cookies["bfp_navigate"].Path = "/";
                Response.Cookies["bfp_navigate"].Expires = DateTime.Now.AddYears(1);
                //Session["BrdCrumbs"] = arrBrdCrumbs;
                #endregion

                if(!IsPostBack)
                {
                    dtCustomFields = new DataTable();
                    dtCustomFields.Columns.Add("ValueName");
                    dtCustomFields.Columns.Add("Value");

                    order = new clsWorkOrders();
                    user = new clsUsers();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    if(order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = m_sLastPage;
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    #region Processing of the Operation Area

                    hlMainEdit.NavigateUrl = "wo_editWorkOrder.aspx?id=" + OrderId.ToString();
                    hlCloseOrder.NavigateUrl = "wo_closeWorkOrder.aspx?id=" + OrderId.ToString();
                    hlOpenOrder.NavigateUrl = "wo_openWorkOrder.aspx?id=" + OrderId.ToString();
                    hlDeleteOrder.NavigateUrl = "wo_deleteWorkOrder.aspx?id=" + OrderId.ToString();

                    hlCheckIn.NavigateUrl = "wo_viewCheckIn.aspx?id=" + OrderId.ToString();
                    hlCheckOut.NavigateUrl = "wo_viewCheckOut.aspx?id=" + OrderId.ToString();
                    hlTimeLog.NavigateUrl = "wo_updateTimeLog.aspx?id=" + OrderId.ToString();

                    hlReportedIssues.NavigateUrl = "wo_addRepairs.aspx?id=" + OrderId.ToString() + "&back=view";
                    hlPMItems.NavigateUrl  = "wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString() + "&back=view";
                    hlInspections.NavigateUrl = "wo_addInspections.aspx?id=" + OrderId.ToString() + "&back=view";

                    sReportPath = _functions.GetValueFromConfig("SQLRS.Folder");
                    hlPrintPartUsed.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fPartsList&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString();
                    hlPrintOrderRequest.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fWorkOrderRequest&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString();
                    hlPrintCompletedOrder.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fCompletedOrder&OrderId=" + OrderId.ToString()+ "&OrgId=" + OrgId.ToString();

                    hlAddRepair.NavigateUrl = "wo_updateRepair.aspx?mode=Edit&repairid=0&inspectid=0&type=FREE&op=Repair&id=" + OrderId.ToString() + "&itemid=0";

                    status = (WorkOrderStatus)order.iStatusId.Value;
                    opstatus = order.iOperatorStatusId.IsNull?WorkOrderOperatorStatus.Null:(WorkOrderOperatorStatus)order.iOperatorStatusId.Value;

                    ViewState["status"] = status;
                    ViewState["opstatus"] = opstatus;
                    switch(status)
                    {
                        case WorkOrderStatus.Scheduled: // Scheduled status
                            hlMainEdit.Enabled = true;
                            hlMainEdit.Text = "[Change the Scheduled Date]";
                            hlReportedIssues.Enabled = true;
                            hlPMItems.Enabled = true;
                            hlInspections.Enabled = true;
                            hlCloseOrder.Enabled = false;
                            hlDeleteOrder.Enabled = true;
                            hlTimeLog.Enabled = false;
                            if(opstatus == WorkOrderOperatorStatus.Checked_In)
                            {
                                // check-in status
                                hlOpenOrder.Enabled = true;
                            }
                            else
                            {
                                // not check-in status
                                hlCheckIn.Enabled = true;
                            }
                            break;
                        case WorkOrderStatus.Open: // Opened status
                            hlMainEdit.Enabled = true;
                            hlReportedIssues.Enabled = true;
                            hlPMItems.Enabled = true;
                            hlInspections.Enabled = true;
                            hlPrintOrderRequest.Enabled = true;
                            hlPrintPartUsed.Enabled = true;
                            hlAddRepair.Enabled = true;
                            lbSaveNotes.Enabled = true;
                            hlTimeLog.Enabled = true;
                            break;
                        case WorkOrderStatus.ReOpened: // ReOpened status
                            hlMainEdit.Enabled = true;
                            hlReportedIssues.Enabled = true;
                            hlPMItems.Enabled = true;
                            hlInspections.Enabled = true;
                            hlPrintOrderRequest.Enabled = true;
                            hlPrintPartUsed.Enabled = true;
                            hlAddRepair.Enabled = true;
                            lbSaveNotes.Enabled = true;
                            hlTimeLog.Enabled = true;
                            break;
                        case WorkOrderStatus.Closed: // Closed Status
                            hlMainEdit.Enabled = true;
                            hlMainEdit.Text = "[Change the Order Dates]";
                            hlPrintCompletedOrder.Enabled = true;
                            hlPrintPartUsed.Enabled = true;
                            hlTimeLog.Enabled = true;
                            if(opstatus == WorkOrderOperatorStatus.Checked_In)
                            {
                                // check-in status
                                hlCheckOut.Enabled = true;
                            }
                            break;
                    }
                    #endregion

                    #region Processing of the Information Area
                    if(status == WorkOrderStatus.Closed)
                        Session["CurrentDay"] = order.daClosed.Value;
                    else
                        Session["CurrentDay"] = order.daScheduled.Value;
                    lblWorkOrderN.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    lblWOType.Text = order.sType.Value;
                    lblStatus.Text = order.sStatusId.Value;
                    lblOperatorStatus.Text = order.sOperatorStatus.Value;
                    lblStaying.Text = order.bStaying.IsNull?"not defined":(order.bStaying.Value?"Yes":"No");
                    lblSpare.Text = order.sSpareEquipId.Value;
                    lblTech.Text = order.sTechName.Value;
                    lblOperator.Text = order.sOperatorName.Value;
                    lblDroppedOffBy.Text = order.sDropedOffBy.Value;
                    lblReleasedTo.Text = order.sReleasedTo.Value;
                    lblCleanliness.Text = order.sCleanliness.Value;

                    hlServiceDates.Attributes.Add("onclick", "window.open('wo_viewDates.aspx?id=" + OrderId.ToString() + "', 'popupcal', 'width=350,height=200,left=' + event.screenX + ',top=' + event.screenY + ',scrollbars=no');");

                    // showing equipment info
                    hlEquipId.Text = order.sEquipId.Value;
                    hlEquipId.NavigateUrl = "e_view.aspx?id=" + order.iEquipId.Value.ToString();
                    lblType.Text = order.sEquipTypeName.Value;
                    lblMakeModel.Text = order.sEquipMakeModel.Value;
                    lblYear.Text = (order.sEquipYear.Value == "0")?"unknown":order.sEquipYear.Value;
                    lblSerial.Text = order.sEquipVinSerial.Value;
                    lblUnits.Text = Convert.ToDouble(order.dmMileage.Value).ToString();
                    #endregion

                    #region Processing of the Issues Area
                    order.iTechId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                    dtPMItems = order.GetWorkOrderPMItems();
                    if(dtPMItems.Rows.Count > 0)
                        html_tblNonePMItems.Visible = false;
                    else
                        html_tblNonePMItems.Visible = true;
                    repPMItems.DataSource = new DataView(dtPMItems);
                    repPMItems.DataBind();

                    dtIssues = order.GetWorkOrderReportedIssues();
                    if(dtIssues.Rows.Count > 0)
                        html_tblNoneIssues.Visible = false;
                    else
                        html_tblNoneIssues.Visible = true;

                    repIssues.DataSource = new DataView(dtIssues);
                    repIssues.DataBind();

                    dtInspections = order.GetWorkOrderInspections();
                    if(dtInspections.Rows.Count > 0)
                        html_tblNoneInspections.Visible = false;
                    else
                        html_tblNoneInspections.Visible = true;
                    repInspections.DataSource = new DataView(dtInspections);
                    repInspections.DataBind();
                    #endregion

                    #region Processing of the Serviced Repairs Area and the Time Log Area
                    ShowRepairList();
                    #endregion

                    #region Processing of the Notes Area
                    order.iItemId = OrderId;
                    order.iNoteTypeId = (int)NoteTypes.CreationNote;
                    repCreationNotes.DataSource = new DataView(order.GetNotesList());
                    repCreationNotes.DataBind();

                    order.iNoteTypeId = (int)NoteTypes.OperatorNote;
                    repOperatorNotes.DataSource = new DataView(order.GetNotesList());
                    repOperatorNotes.DataBind();

                    order.iNoteTypeId = (int)NoteTypes.TechnicianNote;
                    repTechNotes.DataSource = new DataView(order.GetNotesList());
                    repTechNotes.DataBind();
                    #endregion

                    #region Processing of the Signatures Area
                    order.iDocumentId = OrderId;
                    order.iDocumentTypeId = (int)DocumentTypes.WorkOrderCheckedIn;
                    if(order.GetSignedDocument() != -1)
                    {
                        lblSignCheckInBy.Text = order.sUserName.Value;
                        lblSignCheckInByUnder.Text = order.sUserName.Value;
                        lblSignDateCheckInBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                    }
                    else
                    {
                        lblSignCheckInBy.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    }
                    order.iDocumentTypeId = (int)DocumentTypes.WorkOrderReOpened;
                    if(order.GetSignedDocument() != -1)
                    {
                        lblSignOpenedBy.Text = order.sUserName.Value;
                        lblSignOpenedByUnder.Text = order.sUserName.Value;
                        lblSignDateOpenedBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                    }
                    else
                    {
                        order.iDocumentTypeId = (int)DocumentTypes.WorkOrderOpen;
                        if(order.GetSignedDocument() != -1)
                        {
                            lblSignOpenedBy.Text = order.sUserName.Value;
                            lblSignOpenedByUnder.Text = order.sUserName.Value;
                            lblSignDateOpenedBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                        }
                        else
                        {
                            lblSignOpenedBy.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        }
                    }
                    if(status == WorkOrderStatus.Closed)
                    {
                        order.iDocumentTypeId = (int)DocumentTypes.WorkOrderClosed;
                        if(order.GetSignedDocument() != -1)
                        {
                            lblSignClosedBy.Text = order.sUserName.Value;
                            lblSignClosedByUnder.Text = order.sUserName.Value;
                            lblSignDateClosedBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                        }
                    }
                    if(opstatus == WorkOrderOperatorStatus.Checked_Out)
                    {
                        order.iDocumentTypeId = (int)DocumentTypes.WorkOrderCheckedOut;
                        if(order.GetSignedDocument() != -1)
                        {
                            lblSignCheckOutBy.Text = order.sUserName.Value;
                            lblSignCheckOutByUnder.Text = order.sUserName.Value;
                            lblSignDateCheckOutBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                        }
                    }
                    #endregion

                    #region Processing of the Custom Fields
                    dtCustomFieldsFromDB = order.WorkOrderDetail_CustomFields(null);

                    if(dtCustomFieldsFromDB.Rows.Count > 0)
                    {
                        arrCFD = _functions.GetCustomFields(CFDataType.WorkOrder, 0, HttpContext.Current.User.Identity.Name);
                        if(arrCFD.Count > 0)
                        {
                            // fill custom fields
                            for(int j = 0; j < arrCFD.Count; j++)
                            {
                                cfd = (clsCustomFieldsDef)arrCFD[j];
                                sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString();

                                switch(cfd.FieldTypeId)
                                {
                                    case DBFieldType._lookup:
                                        switch(cfd.NameLookupTable)
                                        {
                                            case "EquipModels":
                                                if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                                {
                                                    dtCustomFields.Rows.Add(new object []{"Make/Model", ""});
                                                }
                                                else
                                                {
                                                    mm = new clsMakesModels();
                                                    mm.iOrgId = OrgId;
                                                    mm.iModelId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]);
                                                    mm.GetModelMakes();
                                                    dtCustomFields.Rows.Add(new object []{"Make/Model", mm.sMakeName + "/" + mm.sModelName});
                                                    if(mm != null)
                                                        mm.Dispose();
                                                }
                                                break;
                                            case "Departments":
                                                if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                                {
                                                    dtCustomFields.Rows.Add(new object []{cfd.NameText, ""});
                                                }
                                                else
                                                {
                                                    dep =  new clsDepartments();
                                                    dep.cAction = "S";
                                                    dep.iOrgId = OrgId;
                                                    dep.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]);
                                                    if(dep.DepartmentDetail() == 0)
                                                    {
                                                        dtCustomFields.Rows.Add(new object []{cfd.NameText, dep.sName.Value});
                                                    }
                                                    else
                                                    {
                                                        dtCustomFields.Rows.Add(new object []{cfd.NameText, ""});
                                                    }
                                                    if(dep != null)
                                                        dep.Dispose();
                                                }
                                                break;
                                            case "Locations":
                                                if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                                {
                                                    dtCustomFields.Rows.Add(new object []{cfd.NameText, ""});
                                                }
                                                else
                                                {
                                                    loc = new clsLocations();
                                                    loc.cAction = "S";
                                                    loc.iOrgId = OrgId;
                                                    loc.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]);
                                                    if(loc.LocationDetail() == 0)
                                                    {
                                                        dtCustomFields.Rows.Add(new object []{cfd.NameText, loc.sName.Value});
                                                    }
                                                    else
                                                    {
                                                        dtCustomFields.Rows.Add(new object []{cfd.NameText, ""});
                                                    }
                                                    if(loc != null)
                                                        loc.Dispose();
                                                }
                                                break;
                                            default:
                                                break;
                                        }
                                        break;
                                    case DBFieldType._datetime:
                                        if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                        {
                                            dtCustomFields.Rows.Add(new object []{cfd.NameText, ""});
                                        }
                                        else
                                        {
                                            dtCustomFields.Rows.Add(new object []{cfd.NameText, ((DateTime)dtCustomFieldsFromDB.Rows[0][sTypeName]).ToShortDateString()});
                                        }
                                        break;
                                    case DBFieldType._bit:
                                        if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                        {
                                            dtCustomFields.Rows.Add(new object []{cfd.NameText, ""});
                                        }
                                        else
                                        {
                                            if(((bool)dtCustomFieldsFromDB.Rows[0][sTypeName]) == true)
                                                dtCustomFields.Rows.Add(new object []{cfd.NameText, "Yes"});
                                            else
                                                dtCustomFields.Rows.Add(new object []{cfd.NameText, "No"});
                                        }
                                        break;
                                    default:
                                        if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                        {
                                            dtCustomFields.Rows.Add(new object []{cfd.NameText, ""});
                                        }
                                        else
                                        {
                                            dtCustomFields.Rows.Add(new object []{cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName]});
                                        }
                                        break;
                                }
                                cfd = null;
                            }

                            // showing a Equipment's data from custom fields
                            repCustomFields.DataSource = new DataView(dtCustomFields);
                            repCustomFields.DataBind();
                        }
                    }
                    #endregion
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = m_sLastPage;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
                if(order != null)
                    order.Dispose();
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = this.ParentPageURL;
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    GroupId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = this.ParentPageURL;
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                lblBack.Text = "<input type=button value=\" Back \" onclick=\"document.location='admin_groups.aspx'\">";
                if(!IsPostBack)
                {
                    ViewState["GroupId"] = GroupId;

                    perm = new clsPermissions();
                    user = new clsUsers();
                    perm.iGroupId = GroupId;
                    perm.iOrgId = OrgId;
                    user.cAction = "S";
                    user.iGroupId = GroupId;
                    user.iOrgId = OrgId;
                    if(user.GroupDetails() == -1)
                    {
                        Session["lastpage"] = ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(117);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblGroupName.Text = user.sGroupName.Value;

                    dsPerm = perm.GetPermissionListFromGroup();
                    dgPermissions.DataSource = new DataView(dsPerm.Tables["Table"]);
                    dgPermissions.DataBind();
                    if(dsPerm.Tables["Table1"].Rows.Count > 0)
                    {
                        ddlNewPerm.DataTextField = "vchName";
                        ddlNewPerm.DataValueField = "Id";
                        ddlNewPerm.DataSource = new DataView(dsPerm.Tables["Table1"]);
                        ddlNewPerm.DataBind();
                    }
                    else
                    {
                        ddlNewPerm.Items.Add( new ListItem("<none>", "0"));
                        btnAddPerm.Enabled = false;
                    }
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = this.ParentPageURL;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
                if(perm != null)
                    perm.Dispose();
            }
        }
Ejemplo n.º 27
0
 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();
     }
 }
Ejemplo n.º 28
0
        private void Global_AuthorizeRequest(object sender, System.EventArgs e)
        {
            string sMode;
            try
            {
                // Is user authenticated?
                if(Request.IsAuthenticated)
                {
                    // getting the current page from the Request Object
                    string pageName = Request.FilePath.Remove(0, Request.FilePath.LastIndexOf("/") + 1);
                    // if page is avaible then skip it
                    if((pageName.ToLower() == "default.aspx") ||
                        (pageName == "error.aspx") ||
                        (pageName.ToLower() == "accessdenied.aspx"))
                        return;

                    if (!pageName.Contains(".aspx"))
                        return;

                    // getting a mode from cookies
                    if(Request.Cookies["bfp_mode"] == null)
                        sMode = "";
                    else
                        sMode = Request.Cookies["bfp_mode"].Value;

                    switch(sMode)
                    {
                        case "OperatorKiosk":
                            if(pageName.Substring(0, 3) == "ok_" || pageName == "ReportViewer.aspx" || pageName == "selectMode.aspx")
                                break;
                            else
                            {
                                Context.RewritePath("accessdenied.aspx");
                                return;
                            }
                        case "TechnicianMode":
                            if(pageName.Substring(0, 5) == "admin_" || pageName.Substring(0, 6) == "error_")
                            {
                                Context.RewritePath("accessdenied.aspx");
                                return;
                            }
                            break;
                        default:
                            if(pageName == "ok_mainMenu.aspx")
                                break;
                            else if(pageName.Substring(0, 3) != "ok_")
                                break;
                            else
                            {
                                Context.RewritePath("accessdenied.aspx");
                                return;
                            }
                    }

                    if(Request.Cookies["bfp_operator"] == null)
                    {
                        if(pageName.Substring(0, 3) == "ok_" && pageName != "ok_mainMenu.aspx" && pageName != "ok_authCredentials.aspx")
                        {
                            Context.RewritePath("accessdenied.aspx");
                            return;
                        }
                    }

                    // getting the pages and groups for them from cache
                    DataView dvPages = (DataView)Context.Cache["userPages"];
                    // if pages isn't existing then we create a new
                    if(dvPages == null)
                    {
                        // getting the pages from database
                        user = new clsUsers();
                        user.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                        dvPages = new DataView(user.GetPagesList());
                        // insert pages to cache
                        Context.Cache.Insert("userPages", dvPages, null, DateTime.Now.AddHours(12), TimeSpan.Zero);
                    }
                    // filter pages for current page
                    dvPages.RowFilter = "vchPageName = '" + pageName + "'";
                    // if the page is there in pages list
                    if(dvPages.Count > 0)
                    {
                        // to see roles for current groups of this page
                        foreach(string role in dvPages[0]["vchGroupList"].ToString().Split(new char[] {';'}))
                        {
                            // if the current user have current role then we give an access for current page
                            if(Context.User.IsInRole(role))
                            {
                                return;
                            }
                        }
                    }
                    else // if current user is administrator then we give all access for every page
                        if(Context.User.IsInRole("Administrators"))
                            return;

                    // if we come here then current user hasn't access to current page
                    Context.RewritePath("accessdenied.aspx");
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, "Global.asax.cs");
            }
            finally
            {
                if(user != null)
                {
                    user.Dispose();
                }
            }
        }
Ejemplo n.º 29
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                // getting the Bread Crumbs from Cookie and add last item
                if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null)
                    Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value;
                Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#Main");

                SaveCancelControl.ParentPageURL = this.ParentPageURL;

                if(!IsPostBack)
                {
                    order = new clsWorkOrders();
                    user = new clsUsers();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    user.iOrgId = OrgId;
                    user.iTypeId = (int)UserTypes.Technician;

                    rblWOTypes.DataSource = order.GetTypesList();
                    rblWOTypes.DataBind();

                    ddlTech.DataSource = new DataView(user.GetUserListByType());
                    ddlTech.DataBind();

                    if(order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    status = (WorkOrderStatus)order.iStatusId.Value;
                    opstatus = order.iOperatorStatusId.IsNull?WorkOrderOperatorStatus.Null:(WorkOrderOperatorStatus)order.iOperatorStatusId.Value;

                    ViewState["StatusId"] = status;

                    lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    rblWOTypes.SelectedValue = order.iTypeId.Value.ToString();
                    hlEquipId.Text = order.sEquipId.Value;
                    hlEquipId.NavigateUrl = "e_view.aspx?id=" + order.iEquipId.Value.ToString();
                    hlSpareEquipId.Text = order.sSpareEquipId.Value;
                    hlChangeSpare.NavigateUrl = "wo_selectSpareEquip.aspx?id=" + OrderId.ToString() + "&back=edit";
                    if(order.iSpareEquipId.Value > 0)
                        hlSpareEquipId.NavigateUrl = "e_view.aspx?id=" + order.iSpareEquipId.Value.ToString();
                    if(order.iTechId.Value != 0)
                    {
                        ddlTech.Items.Remove(ddlTech.Items[0]);
                        if(ddlTech.Items.FindByValue(order.iTechId.Value.ToString()) != null)
                            ddlTech.SelectedValue = order.iTechId.Value.ToString();
                        else
                            Header.ErrorMessage = "Cannot find the assigned technician in the technician list";
                    }
                    lblOperator.Text = order.sOperatorName.Value;

                    if(order.bStaying.Value)
                        rblStaying.SelectedValue = "True";
                    else
                        rblStaying.SelectedValue = "False";
                    tbDroppedOffBy.Text = order.sDropedOffBy.Value;
                    tbReleasedTo.Text = order.sReleasedTo.Value;
                    tbCleanliness.Text = order.sCleanliness.Value;
                    adtScheduled.Date = order.daScheduled.Value;
                    lblCreatedDate.Text = order.daCreated.Value.ToLongDateString();
                    switch(status)
                    {
                        case WorkOrderStatus.Scheduled: // Scheduled status
                            hlChangeSpare.Enabled = false;
                            ddlTech.Enabled = false;
                            rblStaying.Enabled = false;
                            tbDroppedOffBy.Enabled = false;
                            tbCleanliness.Enabled = false;
                            tbReleasedTo.Enabled = false;
                            adtScheduled.Enabled = true;
                            html_ScheduledDate.Visible = true;
                            SaveCancelControl.EnableSave = true;
                            if(opstatus == WorkOrderOperatorStatus.Checked_In)
                            {
                                hlChangeSpare.Enabled = true;
                                trCheckInDate.Visible = true;
                                adtCheckIn.Date = order.daArrival.Value;
                            }
                            else
                                trCheckInDate.Visible = false;
                            trCheckOutDate.Visible = false;
                            trClosedDate.Visible = false;
                            trOpenedDate.Visible = false;
                            break;
                        case WorkOrderStatus.Open: // Opened status
                            ViewState["ScheduledDate"] = order.daScheduled.Value;
                            adtScheduled.Enabled = false;
                            html_ScheduledDate.Visible = false;
                            SaveCancelControl.EnableSave = true;
                            trCheckInDate.Visible = true;
                            adtCheckIn.Date = order.daArrival.Value;
                            trOpenedDate.Visible = true;
                            adtOpened.Date = order.daOpened.Value;
                            trCheckOutDate.Visible = false;
                            trClosedDate.Visible = false;
                            break;
                        case WorkOrderStatus.ReOpened: // Opened status
                            ViewState["ScheduledDate"] = order.daScheduled.Value;
                            adtScheduled.Enabled = false;
                            html_ScheduledDate.Visible = false;
                            SaveCancelControl.EnableSave = true;
                            trCheckInDate.Visible = true;
                            adtCheckIn.Date = order.daArrival.Value;
                            trOpenedDate.Visible = true;
                            adtOpened.Date = order.daOpened.Value;
                            trCheckOutDate.Visible = false;
                            trClosedDate.Visible = false;
                            break;
                        case WorkOrderStatus.Closed: // Closed Status
                            ViewState["ScheduledDate"] = order.daScheduled.Value;
                            hlChangeSpare.Enabled = false;
                            ddlTech.Enabled = false;
                            rblStaying.Enabled = false;
                            tbDroppedOffBy.Enabled = true;
                            adtScheduled.Enabled = false;
                            html_ScheduledDate.Visible = false;
                            tbCleanliness.Enabled = true;
                            tbReleasedTo.Enabled = true;
                            SaveCancelControl.EnableSave = true;
                            trCheckInDate.Visible = true;
                            adtCheckIn.Date = order.daArrival.Value;
                            trOpenedDate.Visible = true;
                            adtOpened.Date = order.daOpened.Value;
                            trClosedDate.Visible = true;
                            adtClosed.Date = order.daClosed.Value;
                            if(opstatus  == WorkOrderOperatorStatus.Checked_Out)
                            {
                                trCheckOutDate.Visible = true;
                                adtCheckOut.Date = order.daDeparture.Value;
                            }
                            else
                                trCheckOutDate.Visible = false;
                            break;

                    }
                    if(order.iOperatorId.Value == 6)
                        hlChangeSpare.Enabled = false;

                    ShowCustomFields();

                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = this.ParentPageURL;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
                if(order != null)
                    order.Dispose();
            }
        }
Ejemplo n.º 30
0
        protected void Application_AuthenticateRequest(Object sender, EventArgs e)
        {
            try
            {
                // Is user authenticated?
                if(Request.IsAuthenticated)
                {
                    string[] roles;
                    // `if roles in cookies isn't existing then to create a new else getting roles from cookies
                    if ((Request.Cookies["bfp_roles"] == null) || (Request.Cookies["bfp_roles"].Value == ""))
                    {
                        // geting the user's groups for current user from database
                        user = new clsUsers();
                        user.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                        user.iId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                        DataTable dtGroups = user.GetUserGroupsList();

                        // creating the roles's string for user from groups list
                        string roleStr = "";
                        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,
                            HttpContext.Current.User.Identity.Name,
                            DateTime.Now,
                            DateTime.Now.AddYears(1),
                            false,
                            roleStr
                            );
                        // convert roles to string array
                        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);
                    }
                    else
                    {
                        // getting and decrypt the ticket from cookies
                        FormsAuthenticationTicket ticket =
                            FormsAuthentication.Decrypt(Context.Request.Cookies["bfp_roles"].Value);
                        // getting and convert roles to string array
                        ArrayList userRoles = new ArrayList();
                        foreach (String role in ticket.UserData.Split( new char[] {';'} ))
                        {
                            userRoles.Add(role);
                        }
                        roles = (String[]) userRoles.ToArray(typeof(String));
                    }
                    // set the roles to current user
                    HttpContext.Current.User = new GenericPrincipal(Context.User.Identity, roles);
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, "Global.asax.cs");
            }
            finally
            {
                if(user != null)
                {
                    user.Dispose();
                }
            }
        }