コード例 #1
0
ファイル: dlgdeviceitem.cs プロジェクト: jpheary/Argix08
        private void OnPriorComponentTypeChanged(object sender, System.EventArgs e)
        {
            //Event handler for change in prior comonent type
            try {
                //Create filtered subset for the selected component type
                //Add a blank entry since a selection is not required
                //Add the current entry to keep current selection
                this.mPriorDevices.Clear();
                DeviceItem di = new DeviceItem();
                di.DeviceID = "";
                di.ItemID   = "";
                this.mPriorDevices.Add(di);
                if ((this.cboPriorComponentType.SelectedValue.ToString() == this.mItem.TypeID) && this.mItem.PriorItemID != null)
                {
                    di          = new DeviceItem();
                    di.ItemID   = this.mItem.PriorItemID;
                    di.DeviceID = this.mItem.PriorDeviceID;
                    this.mPriorDevices.Add(di);
                }

                string typeID = this.cboPriorComponentType.SelectedValue != null?this.cboPriorComponentType.SelectedValue.ToString() : "";

                DeviceItems priorDeviceItems = MobileDevicesProxy.GetPriorDeviceItems();
                for (int i = 0; i < priorDeviceItems.Count; i++)
                {
                    if (typeID.Length == 0 || priorDeviceItems[i].TypeID == typeID)
                    {
                        this.mPriorDevices.Add(priorDeviceItems[i]);
                    }
                }

                //Sort and select
                this.mPriorDevices.Sort = "DeviceID";
                if (this.mItem.PriorItemID != null)
                {
                    this.cboPriorDeviceID.SelectedValue = this.mItem.PriorItemID;
                }
                else
                {
                    this.cboPriorDeviceID.SelectedIndex = 0;
                }
                this.cboPriorDeviceID.Enabled = (this.mItem.ItemID != "");
            }
            catch (Exception ex) { App.ReportError(ex, false, Argix.Terminals.LogLevel.Warning); }
            finally { this.OnValidateForm(null, null); }
        }