コード例 #1
0
        private void btnFind_Click(object sender, System.EventArgs e)
        {
            int      EquipId, OrderId;
            DataView dwOrders;

            try
            {
                equip          = new clsEquipment();
                equip.iOrgId   = OrgId;
                equip.sEquipId = tbEquipmentId.Text;
                if (equip.SearchEquipId() == 0)
                {
                    Header.ErrorMessage = "<span style='FONT-SIZE:12pt;'>The specified equipment could not be located</span>";
                    tbEquipmentId.Text  = "";
                }
                else
                {
                    EquipId             = equip.iId.Value;
                    order               = new clsWorkOrders();
                    order.iOrgId        = OrgId;
                    order.daCurrentDate = DateTime.Now;
                    dwOrders            = new DataView(order.GetActivityWorkOrder());
                    dwOrders.RowFilter  = "EquipId = " + EquipId.ToString();
                    if (dwOrders.Count > 0)
                    {
                        dwOrders.Sort = "StatusColor desc, OperatorStatusName asc";
                        OrderId       = Convert.ToInt32(dwOrders[0]["Id"].ToString());
                        Response.Redirect("ok_mainDetails.aspx?id=" + OrderId.ToString() + "&back=mainmenu2", false);
                    }
                    else
                    {
                        Response.Redirect("ok_selectEquipment.aspx?orderid=0&equipid=" + EquipId.ToString() + "&back=mainmenu2", false);
                    }
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = "ok_mainMenu2.aspx";
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (equip != null)
                {
                    equip.Dispose();
                }
                if (order != null)
                {
                    order.Dispose();
                }
            }
        }