예제 #1
0
        private void ChooseAddressViewLoad(object sender, EventArgs e)
        {
            try
            {
                _plant = RFGlobals.GetInstance().Plant;

                using (var racksDT = new RackListTableAdapter().GetRackList(_plant))
                {
                    RackSelection.DataSource    = racksDT;
                    RackSelection.DisplayMember = "Rack";
                }
                using (var shelvesDT = new ShelfListTableAdapter().GetShelfList(_plant))
                {
                    ShelfSelection.DataSource    = shelvesDT;
                    ShelfSelection.DisplayMember = "Shelf";
                }
                using (var positionsDT = new PositionListTableAdapter().GetPositionList(_plant))
                {
                    PositionSelection.DataSource    = positionsDT;
                    PositionSelection.DisplayMember = "Position";
                }
            }
            catch (SqlException ex)
            {
                foreach (SqlError sqlErr in ex.Errors)
                {
                    MessageBox.Show(sqlErr.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        public static RFGlobals GetInstance()
        {
            RFGlobals thisGlobals;

            try
            {
                VerifyFileCanOpen();
                using (var fs = new FileStream(GLOBALS_FILE, FileMode.Open))
                {
                    var xs = new XmlSerializer(typeof(RFGlobals));
                    thisGlobals = (RFGlobals)xs.Deserialize(fs);
                }
            }
            catch (Exception ex)
            {
                thisGlobals = new RFGlobals();
                thisGlobals.PersistState();

                using (var wtr = new StreamWriter(@"My Device\Temp\debugFXMES.txt", true))
                {
                    wtr.WriteLine("{0} - {1}", DateTime.Now, ex.Message);
                }
            }
            thisGlobals.PersistState();
            return(thisGlobals);
        }