public MainView() { InitializeComponent(); if (!mvvmContext1.IsDesignMode) { InitializeBindings(); } //读取系统参数 SysPara = OperatePara.LoadPara("Para.cfg"); DB_Operate = new DB_Operate(SysPara.UserDB, SysPara.UserTB, SysPara.UserPath); //指定用户数据库和表 DB_Work = new DB_Operate(SysPara.WorkDB, SysPara.WorkTB, SysPara.WorkPath); //指定工作数据库和表 //页面跳转 getUserList(); if (!getAuthority()) { this.TabControl.SelectedPage = this.TabControl.Pages[0];//跳转到登录页面 } FirstSign = true; //创建页面 if (TabControl.SelectedPage.Text == "用户") { //刷新列表 getUserList(); User_List.SelectedIndex = 0; } //DB_Work.DB_Table.RowChanged += new DataRowChangeEventHandler(refreshDB); //配置连接参数 ReadPLCValue = new ReadValue(SysPara.PlcIp, SysPara.PlcPort, SysPara.PlcSA1, SysPara.PlcDA1, SysPara.PlcDA2); plcStatus(); //配置流程参数 WorkProcess.equal1ClearEvent += new ValueChange.Change_Event(workProcessClear); //清空参数 WorkProcess.equal1Event += new ValueChange.Change_Event(workProcessGoing); //==1触发读取流程参数 //配置Log参数 Log = new LogNetDateTime("./Log", GenerateMode.ByEveryHour); //配置扫码枪参数 CodeDevice = new RS232(); CodeDevice.Receive_Event += new Receive_Delegate(CodeResolve); //刷新串口列表 Com_List.Items.AddRange(CodeDevice.PortName.ToArray()); Com_List.SelectedIndex = SysPara.PortNo; //连接扫码枪 OpenCodeDevice(); //判断OK/NG judgeEnable.Checked = SysPara.Judge; JudgeDisable.Checked = !SysPara.Judge; //User管理 userListEdit.DataSource = DB_Operate.DB_Table; //主页的信息显示 InitialData(); }
/// <summary> /// 窗口关闭 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainView_FormClosed(object sender, FormClosedEventArgs e) { OperatePara.SavePara("Para.cfg", SysPara); }