Example #1
0
        public frmRemind()
        {
            InitializeComponent();

            //统一初始化
            if (MemoryTable.isInitialized == false)
            {
                MemoryTable.initializeTabes();
            }


            GraphPane myPane = this.zedGraphControl1.GraphPane;

            // Set the XAxis to Text type
            myPane.XAxis.Type = AxisType.Text;

            // Fill the Axis and Pane backgrounds
            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
            myPane.Fill       = new Fill(Color.FromArgb(250, 250, 255));

            myPane.Title.Text       = "库存预警商品信息";
            myPane.XAxis.Title.Text = "商品名称";
            myPane.YAxis.Title.Text = "商品数量";
            myPane.YAxis.MinSpace   = 1;

            appConfig ac = appConfig.getDefaultConfig();

            _timer.Interval = ac.interval;//5000;
            _timer.Tick    += new EventHandler(_timer_Tick);

            this.Shown       += new EventHandler(frmRemind_Shown);
            this.FormClosing += new FormClosingEventHandler(frmRemind_FormClosing);
        }
        void frmSysConfig_Load(object sender, EventArgs e)
        {
            appConfig ac = appConfig.getDefaultConfig();

            this.txtPort.Text     = ac.port.ToString();
            this.txtInterval.Text = ac.interval.ToString();
            int selectedIndex = 0;

            selectedIndex = this.cmbRfidDataFormat.Items.IndexOf(ac.dataFormat.ToString());
            SQLConnConfig sqlc = SQLConnConfig.getDefaultDBConfig(DBType.sqlserver);

            if (sqlc != null)
            {
                this.txtConnString.Text = sqlc.connectString;
            }
        }
        public static appConfig getDefaultConfig()
        {
            appConfig        config = new appConfig();
            IObjectContainer db     = Db4oFactory.OpenFile(appConfig.configFilePath);

            try
            {
                IList <appConfig> list = db.Query <appConfig>(typeof(appConfig));

                if (list.Count > 0)
                {
                    config = list[0];
                }
            }
            finally
            {
                db.Close();
            }
            return(config);
        }
        public static void saveConfig(appConfig config)
        {
            IObjectContainer db = Db4oFactory.OpenFile(appConfig.configFilePath);

            try
            {
                IList <appConfig> list = db.Query <appConfig>(typeof(appConfig));
                if (list.Count <= 0)
                {
                    db.Store(config);
                }
                else
                {
                    appConfig.copy(config, list[0]);
                    db.Store(list[0]);
                }
            }
            finally
            {
                db.Close();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.checkConnectValidation() == false)
            {
                //return;
            }
            else
            {
                SQLConnConfig sqlc = new SQLConnConfig(DBType.sqlserver, this.txtConnString.Text);
                SQLConnConfig.saveConfig(sqlc);
                staticClass.currentDBConnectString = this.txtConnString.Text;
            }
            appConfig ac = new appConfig();

            if (this.checkIntervalValidation() == false)
            {
                //return;
            }
            else
            {
                ac.interval = int.Parse(this.txtInterval.Text);
            }
            if (this.checkPortValidation() == false)
            {
                //return;
            }

            else
            {
                ac.port = int.Parse(this.txtPort.Text);
            }

            appConfig.saveConfig(ac);

            this.Close();
        }
 public static void copy(appConfig source, appConfig dest)
 {
     dest.port     = source.port;
     dest.interval = source.interval;
 }