Beispiel #1
0
        private void repCustomFields_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            DataTable dtListItems = null;

            try
            {
                if(e.Item.ItemType == ListItemType.Item ||
                    e.Item.ItemType == ListItemType.AlternatingItem ||
                    e.Item.ItemType == ListItemType.SelectedItem)
                {
                    switch(((System.Data.DataRowView)e.Item.DataItem).Row.ItemArray[1].ToString())
                    {
                        case "Make/Model":
                            ((BWA.BFP.Web.Controls.User.MakesModels)e.Item.FindControl("mmValue")).IsComponent = true;
                            ((BWA.BFP.Web.Controls.User.MakesModels)e.Item.FindControl("mmValue")).iTypeId = (int)ViewState["ComponentTypeId"];
                            ((BWA.BFP.Web.Controls.User.MakesModels)e.Item.FindControl("mmValue")).ModelId = Convert.ToInt32(((System.Data.DataRowView)e.Item.DataItem).Row.ItemArray[4]);
                            ((BWA.BFP.Web.Controls.User.MakesModels)e.Item.FindControl("mmValue")).DataBind();
                            break;
                        case "Department":
                            dep = new clsDepartments();
                            dep.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                            dtListItems = dep.GetDepartmentsList();
                            ((DropDownList)e.Item.FindControl("ddlValue")).DataTextField = "vchName";
                            ((DropDownList)e.Item.FindControl("ddlValue")).DataValueField = "Id";
                            ((DropDownList)e.Item.FindControl("ddlValue")).DataSource = new DataView(dtListItems);
                            ((DropDownList)e.Item.FindControl("ddlValue")).DataBind();
                            ((DropDownList)e.Item.FindControl("ddlValue")).SelectedValue = Convert.ToString(((System.Data.DataRowView)e.Item.DataItem).Row.ItemArray[2]);
                            break;
                        case "Location":
                            loc = new clsLocations();
                            loc.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                            dtListItems = loc.GetLocationsList();
                            ((DropDownList)e.Item.FindControl("ddlValue")).DataTextField = "vchName";
                            ((DropDownList)e.Item.FindControl("ddlValue")).DataValueField = "Id";
                            ((DropDownList)e.Item.FindControl("ddlValue")).DataSource = new DataView(dtListItems);
                            ((DropDownList)e.Item.FindControl("ddlValue")).DataBind();
                            ((DropDownList)e.Item.FindControl("ddlValue")).SelectedValue = Convert.ToString(((System.Data.DataRowView)e.Item.DataItem).Row.ItemArray[2]);
                            break;
                        default:
                            break;
                    }
                }
            }
            catch(Exception ex)
            {
                _functions.Log("Application error: \n" + ex.ToString());
                Session["lastpage"] = "view.aspx?id=" + Session["EquipId"].ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(mm != null)
                {
                    mm.Dispose();
                }
                if(loc != null)
                {
                    loc.Dispose();
                }
                if(dep != null)
                {
                    dep.Dispose();
                }
            }
        }
Beispiel #2
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     try
     {
         string [,] arrBrdCrumbs = new string [2,2];
         arrBrdCrumbs[0,0]="main.aspx";
         arrBrdCrumbs[0,1]="Home";
         arrBrdCrumbs[1,0]="list.aspx";
         arrBrdCrumbs[1,1]="Equipment List";
         PageTitle = "Add Equipment";
         Header.BrdCrumbs=ParseBreadCrumbs(arrBrdCrumbs,PageTitle);
         Header.PageTitle=PageTitle;
         SaveCancelControl.ParentPageURL=ParentPageURL;
         SourcePageName = "addEquip.aspx.cs";
         if(!IsPostBack)
         {
             loc = new clsLocations();
             dep = new clsDepartments();
             equip = new clsEquipment();
             equip.iOrgId = _functions.GetUserOrgId(Context.User.Identity.Name, false);
             ddlTypes.DataValueField = "Id";
             ddlTypes.DataTextField = "vchName";
             ddlTypes.DataSource = new DataView(equip.GetEquipTypesList());
             ddlTypes.DataBind();
             dep.iOrgId = _functions.GetUserOrgId(Context.User.Identity.Name, false);
             ddlDepts.DataValueField = "Id";
             ddlDepts.DataTextField = "vchName";
             ddlDepts.DataSource = new DataView(dep.GetDepartmentsList());
             ddlDepts.DataBind();
             loc.iOrgId = _functions.GetUserOrgId(Context.User.Identity.Name, false);
             ddlLocs.DataValueField = "Id";
             ddlLocs.DataTextField = "vchName";
             ddlLocs.DataSource = new DataView(loc.GetLocationsList());
             ddlLocs.DataBind();
             mmValue.IsComponent = false;
             mmValue.TypeId = Convert.ToInt32(ddlTypes.SelectedValue);
             mmValue.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(loc != null)
         {
             loc.Dispose();
         }
         if(dep != null)
         {
             dep.Dispose();
         }
         if(equip != null)
         {
             equip.Dispose();
         }
     }
 }
Beispiel #3
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();
            }
        }
Beispiel #4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "e_list.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                    EquipId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "e_list.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                Header.AddBreadCrumb("Home", "/main.aspx");
                Header.AddBreadCrumb("Equipment List", "/e_list.aspx");
                Header.AddBreadCrumb("Equipment Detail", "/e_view.aspx?id="+EquipId.ToString());
                Header.LeftBarHtml = "Edit Main Information of Equipment";

                SaveCancelControl.ParentPageURL = this.ParentPageURL;

                if(!IsPostBack)
                {
                    equip = new clsEquipment();
                    loc = new clsLocations();
                    dep = new clsDepartments();
                    equip.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                    equip.iOrgId = OrgId;
                    equip.iId = EquipId;
                    equip.cAction = "S";

                    dep.iOrgId = OrgId;
                    ddlDepts.DataValueField = "Id";
                    ddlDepts.DataTextField = "vchName";
                    ddlDepts.DataSource = new DataView(dep.GetDepartmentsList());
                    ddlDepts.DataBind();

                    loc.iOrgId = OrgId;
                    ddlLocs.DataValueField = "Id";
                    ddlLocs.DataTextField = "vchName";
                    ddlLocs.DataSource = new DataView(loc.GetLocationsList());
                    ddlLocs.DataBind();

                    // showing a Equipment's main data from fixed fields
                    if(equip.EquipmentDetail() == -1)
                    {
                        Session["lastpage"] = this.ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    ViewState["EquipType"] = equip.iTypeId.Value;

                    lblEquipOperator.Text = equip.sEquipOperator.Value;
                    lblTempOperator.Text = equip.sTempOperator.Value;

                    if(equip.sEquipId.IsNull)
                        tbEquipId.Text = "";
                    else
                        tbEquipId.Text = equip.sEquipId.Value;
                    if(equip.iYear.IsNull)
                        tbYear.Text = "";
                    else
                        tbYear.Text = equip.iYear.Value.ToString();
                    if(equip.sVinSerial.IsNull)
                        tbVinSerial.Text = "";
                    else
                        tbVinSerial.Text = equip.sVinSerial.Value;
                    if(equip.sFuelCode.IsNull)
                        tbFuelCode.Text = "";
                    else
                        tbFuelCode.Text = equip.sFuelCode.Value;
                    if(equip.sPlateNumber.IsNull)
                        tbPlateNumber.Text = "";
                    else
                        tbPlateNumber.Text = equip.sPlateNumber.Value;
                    if(equip.bSpare.IsNull)
                        chSpare.Checked = false;
                    else
                        chSpare.Checked = equip.bSpare.Value;

                    if(equip.iModelId.IsNull)
                    {
                        mmValue.IsComponent = false;
                        mmValue.TypeId = equip.iTypeId.Value;
                        mmValue.DataBind();
                    }
                    else
                    {
                        mmValue.IsComponent = false;
                        mmValue.TypeId = equip.iTypeId.Value;
                        mmValue.ModelId = equip.iModelId.Value;
                        mmValue.DataBind();
                    }
                    if(!equip.iDeptId.IsNull)
                        ddlDepts.SelectedValue = equip.iDeptId.Value.ToString();
                    if(!equip.iLocId.IsNull)
                        ddlLocs.SelectedValue = equip.iLocId.Value.ToString();
                }
            }
            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(loc != null)
                {
                    loc.Dispose();
                }
                if(dep != null)
                {
                    dep.Dispose();
                }
                if(equip != null)
                {
                    equip.Dispose();
                }
            }
        }
Beispiel #5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                SaveCancelControl.ParentPageURL = this.ParentPageURL;
                if(!IsPostBack)
                {
                    loc = new clsLocations();
                    dep = new clsDepartments();
                    equip = new clsEquipment();
                    pm = new clsPMSchedService();
                    inspec = new clsInspections();
                    equip.iOrgId = OrgId;
                    ddlTypes.DataValueField = "Id";
                    ddlTypes.DataTextField = "vchName";
                    ddlTypes.DataSource = new DataView(equip.GetEquipTypesList());
                    ddlTypes.DataBind();
                    dep.iOrgId = OrgId;
                    ddlDepts.DataValueField = "Id";
                    ddlDepts.DataTextField = "vchName";
                    ddlDepts.DataSource = new DataView(dep.GetDepartmentsList());
                    ddlDepts.DataBind();
                    loc.iOrgId = OrgId;
                    ddlLocs.DataValueField = "Id";
                    ddlLocs.DataTextField = "vchName";
                    ddlLocs.DataSource = new DataView(loc.GetLocationsList());
                    ddlLocs.DataBind();
                    mmValue.IsComponent = false;
                    mmValue.TypeId = Convert.ToInt32(ddlTypes.SelectedValue);
                    mmValue.DataBind();

                    pm.iOrgId = OrgId;
                    inspec.iOrgId = OrgId;

                    ddPMScheduleId.DataTextField = "vchName";
                    ddPMScheduleId.DataValueField = "Id";
                    ddPMScheduleId.DataSource =  new DataView(pm.GetPMSchedulesList());
                    ddPMScheduleId.DataBind();
                    ddPMScheduleId.Items.Insert(0, new ListItem("", ""));

                    ddInspectionId.DataTextField = "vchName";
                    ddInspectionId.DataValueField = "Id";
                    ddInspectionId.DataSource = new DataView(inspec.GetInspectSchedulesList());
                    ddInspectionId.DataBind();
                    ddInspectionId.Items.Insert(0, new ListItem("", ""));

                }
            }
            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(pm != null)
                    pm.Dispose();
                if(inspec != null)
                    inspec.Dispose();
                if(loc != null)
                    loc.Dispose();
                if(dep != null)
                    dep.Dispose();
                if(equip != null)
                    equip.Dispose();
            }
        }
Beispiel #6
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "list.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    EquipId=Convert.ToInt32(Request.QueryString["id"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "list.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                string [,] arrBrdCrumbs = new string [3,2];
                arrBrdCrumbs[0,0]="main.aspx";
                arrBrdCrumbs[0,1]="Home";
                arrBrdCrumbs[1,0]="list.aspx";
                arrBrdCrumbs[1,1]="Equipment List";
                arrBrdCrumbs[2,0]="view.aspx?id="+EquipId+"";
                arrBrdCrumbs[2,1]="Equipment Detail";
                PageTitle = "Equipment-Edit Main";
                Header.BrdCrumbs=ParseBreadCrumbs(arrBrdCrumbs,PageTitle);
                Header.PageTitle=PageTitle;

                SaveCancelControl.ParentPageURL= ParentPageURL;

                SourcePageName = "edit.aspx.cs";
                if(!IsPostBack)
                {
                    equip = new clsEquipment();
                    loc = new clsLocations();
                    dep = new clsDepartments();
                    equip.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                    equip.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                    equip.iId = EquipId;
                    equip.cAction = "S";

                    dep.iOrgId = _functions.GetUserOrgId(Context.User.Identity.Name, false);
                    ddlDepts.DataValueField = "Id";
                    ddlDepts.DataTextField = "vchName";
                    ddlDepts.DataSource = new DataView(dep.GetDepartmentsList());
                    ddlDepts.DataBind();

                    loc.iOrgId = _functions.GetUserOrgId(Context.User.Identity.Name, false);
                    ddlLocs.DataValueField = "Id";
                    ddlLocs.DataTextField = "vchName";
                    ddlLocs.DataSource = new DataView(loc.GetLocationsList());
                    ddlLocs.DataBind();

                    // showing a Equipment's main data from fixed fields
                    if(equip.EquipmentDetail() == -1)
                    {
                        Session["lastpage"] = ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    ViewState["EquipType"] = equip.iTypeId.Value;
                    if(equip.sAssignedTo.IsNull)
                        lblAssignedTo.Text = "";
                    else
                        lblAssignedTo.Text = equip.sAssignedTo.Value;

                    if(equip.sEquipId.IsNull)
                        tbEquipId.Text = "";
                    else
                        tbEquipId.Text = equip.sEquipId.Value;
                    if(equip.iYear.IsNull)
                        tbYear.Text = "";
                    else
                        tbYear.Text = equip.iYear.Value.ToString();
                    if(equip.sVinSerial.IsNull)
                        tbVinSerial.Text = "";
                    else
                        tbVinSerial.Text = equip.sVinSerial.Value;
                    if(equip.sFuelCode.IsNull)
                        tbFuelCode.Text = "";
                    else
                        tbFuelCode.Text = equip.sFuelCode.Value;
                    if(equip.sPlateNumber.IsNull)
                        tbPlateNumber.Text = "";
                    else
                        tbPlateNumber.Text = equip.sPlateNumber.Value;
                    if(equip.bShare.IsNull)
                        chShare.Checked = false;
                    else
                        chShare.Checked = equip.bShare.Value;

                    if(equip.iModelId.IsNull)
                    {
                        mmValue.IsComponent = false;
                        mmValue.TypeId = equip.iTypeId.Value;
                        mmValue.DataBind();
                    }
                    else
                    {
                        mmValue.IsComponent = false;
                        mmValue.TypeId = equip.iTypeId.Value;
                        mmValue.ModelId = equip.iModelId.Value;
                        mmValue.DataBind();
                    }
                    if(!equip.iDeptId.IsNull)
                        ddlDepts.SelectedValue = equip.iDeptId.Value.ToString();
                    if(!equip.iLocId.IsNull)
                        ddlLocs.SelectedValue = equip.iLocId.Value.ToString();
                }
            }
            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(loc != null)
                {
                    loc.Dispose();
                }
                if(dep != null)
                {
                    dep.Dispose();
                }
                if(equip != null)
                {
                    equip.Dispose();
                }
            }
        }
Beispiel #7
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();
            }
        }
        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;
                }

                if(Request.QueryString["equipid"] != null)
                    EquipId = Convert.ToInt32(Request.QueryString["equipid"]);
                else
                    EquipId = 0;

                if(Request.QueryString["back"] == null)
                {
                    tblMain.Rows[0].Visible = false;
                    tblMain.Rows[1].Visible = false;
                    sBack = "";
                    this.PageTitle = "Select Spare Equipment";
                    //Header.PageTitle = PageTitle;

                    if(Request.QueryString["select"] == null)
                    {
                        NextBackControl.BackPage = "wo_editAddInfo.aspx?id=" + OrderId.ToString() + "&equipid=0";
                        NextBackControl.BackVisible = true;
                        NextBackControl.CausesValidation = false;
                        m_sLastPage = "wo_editAddInfo.aspx?id=" + OrderId.ToString() + "&equipid=0";
                    }
                    else
                    {
                        ViewState["Operation"] = "AddRoadside";
                        NextBackControl.BackPage = "wo_selectOperator.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
                        NextBackControl.BackVisible = true;
                        NextBackControl.CausesValidation = false;
                        NextBackControl.NextText = "<< Finish >>";
                        m_sLastPage = "wo_selectOperator.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
                    }
                }
                else
                {
                    sBack = Request.QueryString["back"];
                    if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null)
                        Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value;
                    switch (sBack)
                    {
                        case "open":
                            // getting the Bread Crumbs from Cookie and add last item
                            Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString());
                            Header.AddBreadCrumb("Work Order Opening", "/wo_openWorkOrder.aspx?id=" + OrderId.ToString());
                            m_sLastPage = "wo_openWorkOrder.aspx?id=" + OrderId.ToString();
                            break;
                        case "checkin":
                            Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString());
                            Header.AddBreadCrumb("Check-In Equipment", "/wo_viewCheckIn.aspx?id=" + OrderId.ToString());
                            m_sLastPage = "wo_viewCheckIn.aspx?id=" + OrderId.ToString();
                            break;
                        case "edit":
                            Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString());
                            Header.AddBreadCrumb("Work Order Edit", "/wo_editWorkOrder.aspx?id=" + OrderId.ToString());
                            m_sLastPage = "wo_editWorkOrder.aspx?id=" + OrderId.ToString();
                            break;
                        default:
                            Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString());
                            Header.AddBreadCrumb("Work Order Edit", "/wo_editWorkOrder.aspx?id=" + OrderId.ToString());
                            m_sLastPage = "wo_editWorkOrder.aspx?id=" + OrderId.ToString();
                            break;
                    }
                    this.PageTitle = "Select Spare Equipment";

                    NextBackControl.BackVisible = false;
                    NextBackControl.NextText = " Back ";
                    NextBackControl.CausesValidation = false;
                }

                if(!IsPostBack)
                {
                    equip = new clsEquipment();

                    // showing the spare equipment list
                    loc = new clsLocations();
                    dep = new clsDepartments();

                    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"));

                    equip.EnableDefaultFiltration = true;
                    equip.iTypeId = Convert.ToInt32(ddlEquipTypes.SelectedValue);
                    equip.iDeptId = Convert.ToInt32(ddlDepartments.SelectedValue);
                    equip.iLocId = Convert.ToInt32(ddlLocations.SelectedValue);
                    equip.iOrderId = OrderId;
                    equip.sEquipId_Filter = _functions.ConvertToSQLFilter(tbEquipId.Text);

                    dtMain = equip.GetEquipList_ForSpare();

                    ddlEquipTypes.SelectedValue = equip.iTypeId.Value.ToString();

                    ShowList();

                }
            }
            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(loc != null)
                    loc.Dispose();
                if(dep != null)
                    dep.Dispose();
                if(order != null)
                    order.Dispose();
                if(equip != null)
                    equip.Dispose();
            }
        }