private void btnDelete_Click(object sender, EventArgs e) { try { if (dgv.CurrentRow == null || dgv.CurrentRow.Index < 0) { FrmTips.ShowTipsError(AppHelper.MainForm, "未选中任何行!", ContentAlignment.MiddleCenter, 1000); return; } ConstantType entity = CGridHelper.GetCurrentData <ConstantType>(dgv); ConstantApi constantApi = new ConstantApi(); var resp = constantApi.DeleteConstantType(entity.ID); //string sql = "DELETE ConstantType WHERE ID = @ID"; //Hashtable hashtable = new Hashtable(); //hashtable.Add("ID", entity.ID); //if (_mssqlHelper.ExcuteNonQuery(sql, hashtable) > 0) //{ if (resp.Code == 1) { FrmTips.ShowTipsSuccess(AppHelper.MainForm, "删除成功!", ContentAlignment.MiddleCenter, 1000); CGridHelper.DeleteRow(dgv); } else { FrmTips.ShowTipsError(AppHelper.MainForm, "删除失败!" + resp.Message, ContentAlignment.MiddleCenter, 1000); } } catch (Exception ex) { FrmTips.ShowTipsError(AppHelper.MainForm, "删除异常!" + ex.Message, ContentAlignment.MiddleCenter, 3000); } }
private void btnSave_Click(object sender, EventArgs e) { ChargeRecord chargeRecord = new ChargeRecord(); chargeFiller.FillEntity(chargeRecord); chargeRecord.DateOfCharge = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); chargeRecord.ChagreUser = AppHelper.UserName; List <ChargeDetail> details = GetChargeDetails(chargeRecord.PlateNo, chargeRecord.TestNo, out string testItem); chargeRecord.TestItem = testItem; ChargeApi chargeApi = new ChargeApi(); chargeApi.SaveChargeDetails(details); var resp = chargeApi.SaveChargeRecord(chargeRecord); if (resp.Code == 1) { FrmTips.ShowTipsSuccess(AppHelper.MainForm, "保存成功", ContentAlignment.MiddleCenter); } else { FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败" + resp?.Message, ContentAlignment.MiddleCenter); } }
private void ucBtnExt2_BtnClick(object sender, EventArgs e) { if (StringView.SelectedItems.Count == 0) { FrmTips.ShowTipsError(this, "请选择至少一项"); } else { string buf = ""; foreach (ListViewItem cell in StringView.SelectedItems) { buf += "序号:" + cell.Text + " 说明:" + cell.SubItems[4].Text + "\r\n"; } if (FrmDialog.ShowDialog(this, "当前选择了" + StringView.SelectedItems.Count + "条转换条目:\r\n\r\n" + buf + "\r\n是否确定切换激活状态", "切换激活状态", true) == DialogResult.OK) { string status = ""; foreach (ListViewItem item in StringView.SelectedItems) { if (item.SubItems[5].Text == "激活") { status = "cancel"; } if (item.SubItems[5].Text == "未激活") { status = "active"; } AcceseDatabase.ToggleActive(item.Text, status); } refreshlist(); } } }
private void ucBtnExt1_BtnClick(object sender, EventArgs e) { try { Properties.Settings.Default.MachineName = MachineName.Text; Properties.Settings.Default.ProgramName = ProgramName.Text; Properties.Settings.Default.ShortcutName = ShortcutName.Text; Properties.Settings.Default.CleaningTimer = (CleaningTimer.Value * 60000).ToString(); Properties.Settings.Default.ApplyTimer = (ApplyTimer.Value * 1000).ToString(); Properties.Settings.Default.SendBuff = SendBuff.SelectedItem.ToString(); Properties.Settings.Default.LogsReserve = LogsReserve.Value.ToString(); Properties.Settings.Default.LISport = LISport.Text; Properties.Settings.Default.TerminalPort = textBox2.Text; Properties.Settings.Default.MainPage = comboBox6.SelectedIndex.ToString(); Properties.Settings.Default.TerminalPassword = textBox1.Text; Properties.Settings.Default.Save(); FrmTips.ShowTipsSuccess(this, "设置已保存"); //MessageBox.Show("保存成功"); } catch (Exception ex) { FrmTips.ShowTipsError(this, "设置保存失败:" + ex.Message); //MessageBox.Show("保存失败:" + ex.Message); } }
private void ucBtnExt3_BtnClick(object sender, EventArgs e) { string direc = ""; string from = ""; string to = ""; if (direction.BtnText == "仪器>>LIS") { direc = "MTL"; from = "仪器"; to = "LIS"; } if (direction.BtnText == "仪器<<LIS") { direc = "LTM"; from = "LIS"; to = "仪器"; } if (direction.BtnText == "仪器==LIS") { direc = "=="; from = "仪器/LIS"; to = "LIS/仪器"; } if (oldstring.TextLength > 0 && newstring.TextLength > 0 && direc.Length > 0 && Info.TextLength > 0) { if (FrmDialog.ShowDialog(this, "将新增一条条目:\r\n\r\n转换条目说明:[" + Info.Text + "]\r\n从[" + from + "]发送至[" + to + "]的数据[" + oldstring.Text + "]转换成[" + newstring.Text + "]\r\n\r\n确定吗?", "新增条目", true) == DialogResult.OK) { AcceseDatabase.InsertItem(oldstring.Text, direc, newstring.Text, Info.Text); refreshlist(); } } else { FrmTips.ShowTipsError(this, "请检查输入内容"); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (dgv.CurrentRow == null || dgv.CurrentRow.Index < 0) { FrmTips.ShowTipsError(AppHelper.MainForm, "未选中任何行!", ContentAlignment.MiddleCenter, 1000); return; } Menus entity = CGridHelper.GetCurrentData <Menus>(dgv); MenuApi constantApi = new MenuApi(); var resp = constantApi.DeleteMenu(entity.Id); if (resp.Code == 1) { FrmTips.ShowTipsSuccess(AppHelper.MainForm, "删除成功!", ContentAlignment.MiddleCenter, 1000); CGridHelper.DeleteRow(dgv); } else { FrmTips.ShowTipsError(AppHelper.MainForm, "删除失败!" + resp.Message, ContentAlignment.MiddleCenter, 1000); } } catch (Exception ex) { FrmTips.ShowTipsError(AppHelper.MainForm, "删除异常!" + ex.Message, ContentAlignment.MiddleCenter, 3000); } }
private void button4_Click(object sender, EventArgs e) { FrmTips.ShowTipsError(this, "Error提示信息"); FrmTips.ShowTipsInfo(this, "Info提示信息"); FrmTips.ShowTipsSuccess(this, "Success提示信息"); FrmTips.ShowTipsWarning(this, "Warning提示信息"); }
private void btnSave_BtnClick(object sender, EventArgs e) { try { if (!validator1.Validate()) { return; } entityFiller.FillEntity(m_chargeDefine); m_chargeDefine.ItemName = combDefine.Text; m_chargeDefine.ItemCode = combDefine.SelectedValue.ToString(); ConstantApi constantApi = new ConstantApi(); var responseModel = constantApi.SaveChargeDefine(m_chargeDefine); //bool succ = _mssqlHelper.InsertOrUpdate(m_netTypeDefine, null, new string[] { "ID" }, null); if (responseModel.Code.Equals(1)) { FrmTips.ShowTipsSuccess(AppHelper.MainForm, "保存成功!", ContentAlignment.MiddleCenter, 1000); bIsUpdate = true; this.DialogResult = DialogResult.OK; this.Close(); } else { FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + responseModel.Message, ContentAlignment.MiddleCenter, 1000); } } catch (Exception ex) { FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + ex.Message, ContentAlignment.MiddleCenter, 1000); } }
private void btnSave_BtnClick(object sender, EventArgs e) { try { if (!validator1.Validate()) { return; } entityFiller.FillEntity(m_user); RbacApi rbac = new RbacApi(); ResponseModel response = new ResponseModel(); if (IsModify) { response = rbac.ModifyUser(m_user); } else { response = rbac.AddUser(m_user); } if (response.Code == 1) { User user = JsonConvert.DeserializeObject <User>(response.Data.ToString()); //保存角色信息 List <int> roleIds = new List <int>(); List <UserRoleMap> userRoleMaps = new List <UserRoleMap>(); GetCheckedMenuIds(tvMenus.Nodes, roleIds); foreach (var item in roleIds) { userRoleMaps.Add(new UserRoleMap() { UserId = user.Id, RoleId = item }); } rbac.SaveUserRole(userRoleMaps.ToArray()); FrmTips.ShowTipsSuccess(AppHelper.MainForm, "保存成功!", ContentAlignment.MiddleCenter, 1000); bIsUpdate = true; this.DialogResult = DialogResult.OK; this.Close(); } else { FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + response.Message, ContentAlignment.MiddleCenter, 1000); } } catch (Exception ex) { FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + ex.Message, ContentAlignment.MiddleCenter, 1000); } }
/// <summary> /// 登录按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text)) { return; } string msg; string id = textBox1.Text.Trim(); string pwd = textBox2.Text.Trim(); if (ucSwitch1.Checked) { TeacherBLL bll = new TeacherBLL(); Boolean b = bll.GetTeacherInfo(id, pwd, out msg); if (b) { //FrmTips.ShowTipsSuccess(this, msg); //fea.Obj = bll.GetTeacher(id); //FrmTeacherMain frmTeacher = new FrmTeacherMain(); //this.evtFt += new EventHandler(frmTeacher.SetTxt); //if (this.evtFt!=null) //{ // this.evtFt(this, fea); // frmTeacher.ShowDialog(); //} FrmTips.ShowTipsSuccess(this, msg); this.Tag = bll.GetTeacher(id); this.DialogResult = DialogResult.OK; } else { FrmTips.ShowTipsError(this, msg); } } else { StudentBLL bll = new StudentBLL(); Student stu = new Student(); bool b = bll.getStudentInfoBySid(id, pwd, out msg, out stu); if (b) { this.Tag = stu; this.DialogResult = DialogResult.Yes; } else { FrmTips.ShowTipsError(this, msg); } } }
//添加学生 private void ucBtnSave_BtnClick(object sender, EventArgs e) { bool b; if (!Check.isStudentID(txtSID.Text)) { FrmTips.ShowTipsWarning(this, "学号格式不正确"); return; } try { Student stu = new Student(); stu.SID = txtSID.Text; stu.SName = txtSname.Text; stu.PassWord = MD5Encode.GetMd5("123456"); //学生默认密码123456 stu.SGender = cmbGender.SelectedIndex % 2 == 0 ? "男" : "女"; stu.Class = cmbClass.SelectedValue.ToString(); stu.Departments = cmbCollege.SelectedValue.ToString(); stu.Birthday = Convert.ToDateTime(dtpBir.Value.ToString("yyy/MM/dd")); stu.AdmissionTime = Convert.ToDateTime(dtpAdm.Value.ToString("yyy/MM/dd")); stu.Image = null; StudentBLL bll = new StudentBLL(); b = bll.AddStudentInfo(stu); } catch (Exception) { b = false; } if (b) { FrmTips.ShowTipsSuccess(this, "添加成功"); txtSID.Clear(); txtSname.Clear(); txtSID.Focus(); } else { FrmTips.ShowTipsError(this, "添加失败"); } //MessageBox.Show(cmbGender.SelectedValue.ToString()); //MessageBox.Show(cmbClass.SelectedValue.ToString()); }
private void btnModify_Click(object sender, EventArgs e) { try { if (dgv.CurrentRow == null || dgv.CurrentRow.Index < 0) { FrmTips.ShowTipsError(AppHelper.MainForm, "未选中任何行!", ContentAlignment.MiddleCenter, 1000); return; } Menus entity = CGridHelper.GetCurrentData <Menus>(dgv); MenuOptForm form = new MenuOptForm(entity); form.ShowDialog(); } catch (Exception ex) { FrmTips.ShowTipsError(AppHelper.MainForm, "修改异常!" + ex.Message, ContentAlignment.MiddleCenter, 3000); } }
private void btnSave_BtnClick(object sender, EventArgs e) { try { if (!validator1.Validate()) { return; } entityFiller.FillEntity(m_menus); m_menus.ParentId = Convert.ToInt32(combMenus.SelectedValue); if (m_menus.ParentId != 0) { m_menus.ParentName = combMenus.Text; } MenuApi menuApi = new MenuApi(); ResponseModel responseModel = new ResponseModel(); if (!IsModify) { responseModel = menuApi.AddMenu(m_menus); } else { responseModel = menuApi.ModifyMenu(m_menus); } if (responseModel.Code == 1) { FrmTips.ShowTipsSuccess(AppHelper.MainForm, "保存成功!", ContentAlignment.MiddleCenter, 1000); m_menus = JsonConvert.DeserializeObject <Menus>(responseModel.Data.ToString()); bIsUpdate = true; this.DialogResult = DialogResult.OK; this.Close(); } else { FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + responseModel.Message, ContentAlignment.MiddleCenter, 1000); } } catch (Exception ex) { FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + ex.Message, ContentAlignment.MiddleCenter, 1000); } }
private void btnOK_BtnClick(object sender, EventArgs e) { labWarn.Text = ""; string user = txtUser.InputText.Trim(); string pwd = txtPwd.InputText.Trim(); if (string.IsNullOrWhiteSpace(user) || string.IsNullOrWhiteSpace(pwd)) { labWarn.Text = "用户名、密码不能为空!"; return; } //pwd = Live0xUtils.Encryption.EncryptionMD5.GetMD5Hash(user+pwd); ControlHelper.ThreadRunExt(this, () => { try { RbacApi api = new RbacApi(); var response = api.UserLogin(user, pwd); ControlHelper.ThreadInvokerControl(this, () => { if (response.Code == 1) { User user1 = JsonConvert.DeserializeObject <User>(response.Data.ToString()); AppHelper.UserId = user1.Id; AppHelper.UserName = user1.UserName; this.DialogResult = DialogResult.OK; } else { labWarn.Text = "*登录失败!" + response?.Message; } }); } catch (Exception ex) { ControlHelper.ThreadInvokerControl(this, () => { FrmTips.ShowTipsError(this, ex.Message); }); } }, null, this, true, "正在登录……", 200); }
private void SerialPort() { try { serialPort = new SerialPortDeal(Properties.Settings.Default.SerialPortNo, Properties.Settings.Default.SerialBaudRate, Properties.Settings.Default.SerialParityCheck, Properties.Settings.Default.SerialDataBit, Properties.Settings.Default.SerialStopBit, Properties.Settings.Default.SerialRTSEnable); serialPort.sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived); serialPort.open(); ucWave1.WaveColor = Color.FromArgb(0, 155, 144); MACIP.Text = serialportno; Properties.Settings.Default.MacStatus = serialportno; LogPrint("仪器串口连接成功", 1); } catch (Exception ex) { ucWave1.WaveColor = Color.FromArgb(255, 77, 59); LogPrint(ex.Message, 1); FrmTips.ShowTipsError(this, "串口设置出错:" + ex.Message); //MessageBox.Show(ex.Message); } }
private void ucBtnExt4_BtnClick(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { try { string path = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath; if (System.IO.File.Exists(saveFileDialog1.FileName)) { System.IO.File.Delete(saveFileDialog1.FileName); } System.IO.File.Copy(path, saveFileDialog1.FileName); FrmTips.ShowTipsSuccess(this, "设置已导出:" + saveFileDialog1.FileName); } catch (Exception ex) { FrmTips.ShowTipsError(this, "设置导出错误:" + saveFileDialog1.FileName); } } }
//保存按钮 private void ucBtnSave_BtnClick(object sender, EventArgs e) { bool b; if (!Check.isStudentID(txtEdSID.Text)) { b = false; FrmTips.ShowTipsWarning(this, "学号格式不正确"); return; } try { Student stu = new Student(); stu.SName = txtEdSname.Text; stu.SID = txtEdSID.Text; stu.SGender = cmbEdGender.Text; stu.Class = cmbEdClass.SelectedValue.ToString(); stu.Departments = cmbEdCollege.SelectedValue.ToString(); stu.Birthday = Convert.ToDateTime(dtpEdBir.Value.ToString("yyy/MM/dd")); stu.AdmissionTime = Convert.ToDateTime(dtpEdAdm.Value.ToString("yyy/MM/dd")); stu.Image = null; StudentBLL bll = new StudentBLL(); b = bll.UpdateStudentInfo(stu); } catch (Exception) { b = false; } if (b) { FrmTips.ShowTipsSuccess(this, "修改成功"); } else { FrmTips.ShowTipsError(this, "修改失败"); } }
private void ucBtnExt3_BtnClick(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { string path = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath; //Console.WriteLine(path); try { System.IO.File.Delete(path); System.IO.File.Copy(openFileDialog1.FileName, path); } catch (Exception ex) { FrmTips.ShowTipsError(this, "导入设置失败:" + ex.Message); //MessageBox.Show(ex.Message); } ((NotifyIcon)notifyicon).Visible = false; System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location); Environment.Exit(0); } }
private void btnModify_Click(object sender, EventArgs e) { try { if (dgv.CurrentRow == null || dgv.CurrentRow.Index < 0) { FrmTips.ShowTipsError(AppHelper.MainForm, "未选中任何行!", ContentAlignment.MiddleCenter, 1000); return; } ConstantType entity = CGridHelper.GetCurrentData <ConstantType>(dgv); DicTypeOptForm form = new DicTypeOptForm(entity); if (form.ShowDialog(this) == DialogResult.OK) { btnSearch_Click(null, null); } } catch (Exception ex) { FrmTips.ShowTipsError(AppHelper.MainForm, "修改异常!" + ex.Message, ContentAlignment.MiddleCenter, 3000); } }
private void ucBtnExt4_BtnClick(object sender, EventArgs e) { if (StringView.SelectedItems.Count == 0) { FrmTips.ShowTipsError(this, "请选择至少一项"); } else { string buf = ""; foreach (ListViewItem cell in StringView.SelectedItems) { buf += "序号:" + cell.Text + " 说明:" + cell.SubItems[4].Text + "\r\n"; } if (FrmDialog.ShowDialog(this, "当前选择了" + StringView.SelectedItems.Count + "条转换条目:\r\n\r\n" + buf + "\r\n是否确定删除", "删除条目", true) == DialogResult.OK) { foreach (ListViewItem item in StringView.SelectedItems) { AcceseDatabase.RemoveItem(item.Text); } refreshlist(); } } }
private void LogPathTimer_Tick(object sender, EventArgs e) { try { string tmppath = logpath; if (!Directory.Exists(Application.StartupPath + "\\logs\\")) { Directory.CreateDirectory(Application.StartupPath + "\\logs\\"); } logpath = Application.StartupPath + "\\logs\\" + System.DateTime.Now.ToString("yyyyMMdd") + ".log"; if (logpath != tmppath && tmppath != null) { fsw.Close(); fsw = new FileStream(logpath, FileMode.Append); MacLogBox.Clear(); LISLogBox.Clear(); } } catch (Exception ex) { FrmTips.ShowTipsError(this, "获取日志路径出错:" + ex.Message); } }
private void clientip_TextChanged(object sender, EventArgs e) { try { IPAddress ip = IPAddress.Parse(clientip.Text); if (Properties.Settings.Default.ClientIP != clientip.Text) { try { Properties.Settings.Default.ClientIP = clientip.Text; Properties.Settings.Default.Save(); FrmTips.ShowTipsSuccess(this, "设置已保存"); } catch (Exception ex) { FrmTips.ShowTipsError(this, "设置保存失败:" + ex.Message); } } } catch (Exception) { } }
public void LogPrint(string log, int flag) { if (flag == 0) { this.LISLogBox.AppendText("[" + System.DateTime.Now.ToString() + "]:" + log + "\r\n"); } if (flag == 1) { this.MacLogBox.AppendText("[" + System.DateTime.Now.ToString() + "]:" + log + "\r\n"); } if (flag == 2) { this.MacLogBox.AppendText("[" + System.DateTime.Now.ToString() + "]:" + log + "\r\n"); this.LISLogBox.AppendText("[" + System.DateTime.Now.ToString() + "]:" + log + "\r\n"); } try { byte[] writeBytes; if (Properties.Settings.Default.LogEncode == "Default") { writeBytes = Encoding.Default.GetBytes("[" + System.DateTime.Now.ToString() + "]:" + log + "\r\n"); } else { Encoding encode = Encoding.GetEncoding(Properties.Settings.Default.LogEncode); writeBytes = encode.GetBytes("[" + System.DateTime.Now.ToString() + "]:" + log + "\r\n"); } fsw.Position = fsw.Length; fsw.Write(writeBytes, 0, writeBytes.Length); } catch (Exception ex) { //MessageBox.Show(ex.Message); FrmTips.ShowTipsError(this, ex.Message); } }
private void 添加桌面快捷方式toolStripMenuItem1_Click(object sender, EventArgs e) { try { string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); FileInfo fileDesktop = new FileInfo(desktopPath + "\\" + desktopenter + ".lnk"); if (!fileDesktop.Exists) { WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" + desktopenter + ".lnk"); shortcut.TargetPath = typeof(Program).Assembly.Location; shortcut.WorkingDirectory = Application.StartupPath; shortcut.WindowStyle = 1; shortcut.Description = "iMedicalLIS"; shortcut.IconLocation = Application.ExecutablePath; shortcut.Save(); } } catch (Exception ex) { //MessageBox.Show(ex.Message, "创建快捷方式失败"); FrmTips.ShowTipsError(this, "创建快捷方式失败"); } }
private void DM_Load(object sender, EventArgs e) { Properties.Settings.Default.StartTime = DateTime.Now; label7.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.MaximizeBox = false; this.MinimumSize = new Size(280, 563); this.Size = new Size(280, 563); this.FormBorderStyle = FormBorderStyle.FixedSingle; splitContainer1.Panel1Collapsed = true; if (!System.IO.File.Exists(Application.StartupPath + "/Config.mdb")) { FrmTips.ShowTipsInfo(this, "检测不到中继数据库,正在生成,请稍候"); //MessageBox.Show("检测不到数据库,自动生成,请重启程序后使用", "数据传输中继"); byte[] config = Properties.Resources.Config; System.IO.File.WriteAllBytes(Application.StartupPath + "/Config.mdb", config); System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location); System.Environment.Exit(0); } try { string path = Application.ExecutablePath; RegistryKey rk = Registry.LocalMachine; RegistryKey rk2 = rk.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run"); string[] rest = rk2.GetValueNames(); foreach (string line in rest) { if (line == "JcShutdown") { 设为开机启动ToolStripMenuItem.Checked = true; } } } catch (Exception ex) { FrmTips.ShowTipsWarning(this, "请使用管理员模式运行"); //MessageBox.Show(ex.Message, "请使用管理员模式运行本程序"); } if (Properties.Settings.Default.LogsReserve != "0") { LogsCleaningTimer.Start(); } CleaningTimer.Start(); LogPathTimer.Start(); TransModuleRefresh.Start(); LogPathTimer_Tick(null, null); try { fsw = new FileStream(logpath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); } catch (Exception ex) { FrmDialog.ShowDialog(this, "写日志线程异常:" + ex.Message); } LogPrint("*************************************", 2); LogPrint("正在启动LIS系统网口仪器中继程序", 2); LogPrint("*************************************", 2); try { MachineName.Text = Properties.Settings.Default.MachineName; MenuMachineName.Text = "仪器:" + Properties.Settings.Default.MachineName; this.Text = Properties.Settings.Default.ProgramName; this.NotifyIcon.Text = Properties.Settings.Default.ProgramName; this.NotifyIcon.BalloonTipText = Properties.Settings.Default.ProgramName; desktopenter = Properties.Settings.Default.ShortcutName; CleaningTimer.Interval = int.Parse(Properties.Settings.Default.CleaningTimer); TransModuleRefresh.Interval = int.Parse(Properties.Settings.Default.ApplyTimer); lisport = Properties.Settings.Default.LISport.ToString(); ConnectWay = byte.Parse(Properties.Settings.Default.ConnectWay); serialportno = Properties.Settings.Default.SerialPortNo.ToString(); serialbaudrate = Properties.Settings.Default.SerialBaudRate; serialparitycheck = Properties.Settings.Default.SerialParityCheck; serialdatabit = Properties.Settings.Default.SerialDataBit; serialstopbit = Properties.Settings.Default.SerialStopBit; filenameextension = Properties.Settings.Default.FileNameExtension; filepath = Properties.Settings.Default.FilePath; filewritepath = Properties.Settings.Default.FileWritePath; filewriteextension = Properties.Settings.Default.FileWriteExtension; clientport = Properties.Settings.Default.ClientPort.ToString(); serverport = Properties.Settings.Default.ServerPort.ToString(); timesleep = int.Parse(Properties.Settings.Default.ClientTimer); FileTimer.Interval = int.Parse(Properties.Settings.Default.FileTimer); clientip = IPAddress.Parse(Properties.Settings.Default.ClientIP.Replace(" ", "")); } catch (Exception ex) { FrmTips.ShowTipsError(this, "服务启动错误:" + ex.Message); } LogPrint("LIS连接IP:" + ip.ToString(), 0); LogPrint("LIS连接端口:" + lisport, 0); ConfigConsole terminal = new ConfigConsole(fsw); threadlis = new Thread(WaitLIS); threadlis.Start(); terminal.start(); ClearMemoryInfo.FlushMemory(); switch (ConnectWay) { case 0: LogPrint("仪器连接方式:客户端连接", 1); LogPrint("仪器连接IP端口:" + ip + ":" + serverport, 1); threadmac = new Thread(WaitMac); threadmac.Start(); LogPrint("*************************************", 2); break; case 1: LogPrint("仪器连接方式:服务端监听", 1); LogPrint("仪器监听IP端口:" + clientip + ":" + clientport, 1); threadmac = new Thread(ConnMac); threadmac.Start(); LogPrint("*************************************", 2); break; case 2: LogPrint("仪器连接方式:串口连接", 1); LogPrint("仪器连接串口号:" + serialportno, 1); LogPrint("波特率:" + serialbaudrate, 1); LogPrint("校验:" + serialparitycheck, 1); LogPrint("数据位:" + serialdatabit, 1); LogPrint("停止位:" + serialstopbit, 1); LogPrint("RTS/CTS:" + Properties.Settings.Default.SerialRTSEnable, 1); threadmac = new Thread(SerialPort); threadmac.Start(); LogPrint("*************************************", 2); break; case 3: LogPrint("仪器连接方式:读文件", 1); LogPrint("仪器数据目录:" + filepath + "\\*." + filenameextension, 1); LogPrint("写入数据目录:" + filewritepath + "\\*." + filewriteextension, 1); FileTimer.Start(); ucWave1.WaveColor = Color.FromArgb(0, 155, 144); if (Properties.Settings.Default.FileConnectLIS) { LogPrint("链接Cache模式", 1); MACIP.Text = "读文件(链接Cache)模式"; Properties.Settings.Default.MacStatus = "读文件(链接Cache)模式"; string ret = operat.Login(Properties.Settings.Default.CacheHost, int.Parse(Properties.Settings.Default.CachePort), Properties.Settings.Default.CacheNamespace, Properties.Settings.Default.CacheUserID, Properties.Settings.Default.CachePassword); if (ret == "Login Cache OK") { LogPrint("登录LIS数据库成功", 1); } else { LogPrint("登录LIS数据库失败:" + ret.Split(':')[1], 1); FileTimer.Stop(); ucWave1.WaveColor = Color.FromArgb(255, 77, 59); } } else { LogPrint("转网络传输模式", 1); MACIP.Text = "读文件(转网络)模式"; Properties.Settings.Default.MacStatus = "读文件(转网络)模式"; } LogPrint("*************************************", 2); break; } }
private void tvMenu_AfterSelect(object sender, TreeViewEventArgs e) { panControl.Controls.Clear(); string strName = e.Node.Text.Trim(); this.Title = "HZHControls控件库DEMO--" + strName; switch (strName) { case "关于授权": AddControl(new UCShouQuan()); break; #region 窗体 English:forms case "提示窗体": if (FrmDialog.ShowDialog(this, "是否再显示一个没有取消按钮的提示框?", "模式窗体测试", true) == System.Windows.Forms.DialogResult.OK) { FrmDialog.ShowDialog(this, "这是一个没有取消按钮的提示框", "模式窗体测试"); } break; case "多输入窗体": FrmInputs frm = new FrmInputs("动态多输入窗体测试", new string[] { "姓名", "电话", "身份证号", "住址" }, new Dictionary <string, HZH_Controls.TextInputType>() { { "电话", HZH_Controls.TextInputType.Regex }, { "身份证号", HZH_Controls.TextInputType.Regex } }, new Dictionary <string, string>() { { "电话", "^1\\d{0,10}$" }, { "身份证号", "^\\d{0,18}$" } }, new Dictionary <string, KeyBoardType>() { { "电话", KeyBoardType.UCKeyBorderNum }, { "身份证号", KeyBoardType.UCKeyBorderNum } }, new List <string>() { "姓名", "电话", "身份证号" }); frm.ShowDialog(this); break; case "气泡提示窗体": FrmTips.ShowTipsError(this, "Error提示信息"); FrmTips.ShowTipsInfo(this, "Info提示信息"); FrmTips.ShowTipsSuccess(this, "Success提示信息"); FrmTips.ShowTipsWarning(this, "Warning提示信息"); FrmTips.ShowTips(this, "自定义提示信息", 2000, true, ContentAlignment.MiddleCenter, null, TipsSizeMode.Medium, new Size(300, 50), TipsState.Success); break; case "有返回的窗体": new FrmTestFrmBack().ShowDialog(this); break; case "等待窗体": ControlHelper.ThreadRunExt(this, () => { Thread.Sleep(5000); ControlHelper.ThreadInvokerControl(this, () => { FrmTips.ShowTipsSuccess(this, "FrmWaiting测试"); }); }, null, this); break; case "仅有标题的窗体": new FrmWithTitleTest().ShowDialog(this); break; case "确定取消窗体1": new FrmOKCancel1Test().ShowDialog(this); break; case "确定取消窗体2": new FrmOKCancel2Test().ShowDialog(this); break; case "资源加载窗体": FrmTestLoading frmLoading = new FrmTestLoading(); frmLoading.BackgroundWorkAction = delegate() { try { frmLoading.CurrentMsg = new KeyValuePair <int, string>(1, "正在初始化配置..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(10, "正在加载第一个资源..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(20, "正在加载第二个资源..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(30, "正在加载第三个资源..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(40, "正在加载第四个资源..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(50, "正在加载第五个资源..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(60, "正在加载第六个资源..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(70, "正在加载第七个资源..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(80, "正在加载第八个资源..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(90, "正在加载第九个资源..."); Thread.Sleep(1000); frmLoading.CurrentMsg = new KeyValuePair <int, string>(1000, "数据加载完成..."); Thread.Sleep(1000); } catch (Exception ex) { MessageBox.Show("加载资源时出现错误"); } }; frmLoading.ShowDialog(); break; #endregion #region 控件 English:control case "表单控件": AddControl(new UC.UCTestForms()); break; case "按钮": AddControl(new UC.UCTestBtns()); break; case "选项卡": AddControl(new UC.UCTestTab()); break; case "树": AddControl(new UC.UCTestTreeview() { Dock = DockStyle.Left }); break; case "列表": AddControl(new UC.UCTestList() { Dock = DockStyle.Left }); break; case "平铺列表": AddControl(new UC.UCTestListView() { Dock = DockStyle.Fill }); break; case "垂直导航": AddControl(new UC.UCTestMenu() { Dock = DockStyle.Left }); break; case "横向列表": AddControl(new UC.UCTestHorizontalList()); break; case "分页控件": AddControl(new UC.UCTestPage()); break; case "表格": AddControl(new UC.UCTestGridTable()); break; case "表格-自定义单元格": AddControl(new UC.UCTestGridTableCustom()); break; case "树表格": AddControl(new UC.UCTestTreeGridTable()); break; case "进度条": AddControl(new UC.UCTestProcess() { Dock = DockStyle.Fill }); break; case "步骤控件": AddControl(new UC.UCTestStep() { Dock = DockStyle.Fill }); break; case "面包屑导航": AddControl(new UC.UCTestNavigation() { Dock = DockStyle.Fill }); break; case "文字提示": AddControl(new UC.UCTestTips() { Dock = DockStyle.Fill }); break; case "滚动文字": AddControl(new UC.UCTestRollText() { Dock = DockStyle.Fill }); break; case "滑块": AddControl(new UC.UCTestTrackbar() { Dock = DockStyle.Fill }); break; case "水波": AddControl(new UC.UCTestWave() { Dock = DockStyle.Fill }); break; case "有标题的面板": AddControl(new UC.UCTestPanelTitle() { Dock = DockStyle.Left }); break; case "图标": AddControl(new UC.UCTestIcon() { Dock = DockStyle.Fill }); break; case "滚动条": AddControl(new UC.UCTestScrollbar() { Dock = DockStyle.Fill }); break; case "控件水印": AddControl(new UC.UCTestGraphicalOverlay()); break; case "表单验证": AddControl(new UC.UCTestVerification() { Dock = DockStyle.Fill }); break; case "图片采样控件": AddControl(new UC.UCTestSampling()); break; case "倒影": AddControl(new UC.UCTestShadow()); break; case "内置颜色": AddControl(new UC.UCTestColors()); break; case "导航菜单": AddControl(new UC.UCTestNavigationMenu()); break; case "扩展导航菜单": AddControl(new UC.UCTestNavigationMenuExt()); break; case "类Office导航菜单": AddControl(new UC.UCTestNavigationMenuOffice()); break; case "分割线标签": AddControl(new UC.UCTestSplitLabel()); break; case "时间轴": AddControl(new UC.UCTestTimeLine() { Dock = DockStyle.Fill }); break; case "穿梭框": AddControl(new UC.UCTestTransfer()); break; case "引用区块": AddControl(new UC.UCTestPanelQuote()); break; case "右键菜单": AddControl(new UC.UCTestContextMenu()); break; #endregion #region 图表 English:Chart case "组织结构图": AddControl(new UC.UCTestMindMapping() { Dock = DockStyle.Fill }); break; case "滚动图表": AddControl(new UC.UCTestWaveChart() { Dock = DockStyle.Fill }); break; case "雷达图": AddControl(new UC.UCTestRadarChart() { Dock = DockStyle.Fill }); break; case "金字塔图": AddControl(new UC.UCTestFunnelChart()); break; case "Live Charts": AddControl(new UC.UCTestLiveCharts()); break; #endregion #region 工业 English:Industry case "LED文字": AddControl(new UC.UCTestLED() { Dock = DockStyle.Fill }); break; case "仪表": AddControl(new UC.UCTestMeter()); break; case "管道": AddControl(new UC.UCTestConduit()); break; case "阀门": AddControl(new UC.UCTestValve()); break; case "鼓风机": AddControl(new UC.UCTestBlower()); break; case "传送带": AddControl(new UC.UCTestConveyor()); break; case "警示灯": AddControl(new UC.UCTestSignalLamp()); break; case "箭头": AddControl(new UC.UCTestArrow()); break; case "温度计": AddControl(new UC.UCTestThermometer()); break; case "转子": AddControl(new UC.UCTestRotor()); break; case "多通道转盘": AddControl(new UC.UCTestDialAisle()); break; case "转盘": AddControl(new UC.UCTestTurntable()); break; #endregion } }
private void tvMenu_AfterSelect(object sender, TreeViewEventArgs e) { panControl.Controls.Clear(); string strName = e.Node.Text.Trim(); switch (strName) { #region 窗体 English:forms case "提示窗体": if (FrmDialog.ShowDialog(this, "是否再显示一个没有取消按钮的提示框?", "模式窗体测试", true) == System.Windows.Forms.DialogResult.OK) { FrmDialog.ShowDialog(this, "这是一个没有取消按钮的提示框", "模式窗体测试"); } break; case "多输入窗体": FrmInputs frm = new FrmInputs("动态多输入窗体测试", new string[] { "姓名", "电话", "身份证号", "住址" }, new Dictionary <string, HZH_Controls.TextInputType>() { { "电话", HZH_Controls.TextInputType.Regex }, { "身份证号", HZH_Controls.TextInputType.Regex } }, new Dictionary <string, string>() { { "电话", "^1\\d{0,10}$" }, { "身份证号", "^\\d{0,18}$" } }, new Dictionary <string, KeyBoardType>() { { "电话", KeyBoardType.UCKeyBorderNum }, { "身份证号", KeyBoardType.UCKeyBorderNum } }, new List <string>() { "姓名", "电话", "身份证号" }); frm.ShowDialog(this); break; case "气泡提示窗体": FrmTips.ShowTipsError(this, "Error提示信息"); FrmTips.ShowTipsInfo(this, "Info提示信息"); FrmTips.ShowTipsSuccess(this, "Success提示信息"); FrmTips.ShowTipsWarning(this, "Warning提示信息"); FrmTips.ShowTips(this, "自定义提示信息", 2000, true, ContentAlignment.MiddleCenter, null, TipsSizeMode.Medium, new Size(300, 50), TipsState.Success); break; case "有返回的窗体": new FrmTestFrmBack().ShowDialog(this); break; case "等待窗体": ControlHelper.ThreadRunExt(this, () => { Thread.Sleep(5000); ControlHelper.ThreadInvokerControl(this, () => { FrmTips.ShowTipsSuccess(this, "FrmWaiting测试"); }); }, null, this); break; case "仅有标题的窗体": new FrmWithTitleTest().ShowDialog(this); break; case "确定取消窗体1": new FrmOKCancel1Test().ShowDialog(this); break; case "确定取消窗体2": new FrmOKCancel2Test().ShowDialog(this); break; #endregion #region 控件 English:control case "表单控件": AddControl(new UC.UCTestForms()); break; case "按钮": AddControl(new UC.UCTestBtns()); break; case "选项卡": AddControl(new UC.UCTestTab()); break; case "树": AddControl(new UC.UCTestTreeview() { Dock = DockStyle.Left }); break; case "列表": AddControl(new UC.UCTestList() { Dock = DockStyle.Left }); break; case "平铺列表": AddControl(new UC.UCTestListView() { Dock = DockStyle.Fill }); break; case "垂直导航": AddControl(new UC.UCTestMenu() { Dock = DockStyle.Left }); break; case "横向列表": AddControl(new UC.UCTestHorizontalList()); break; case "分页控件": AddControl(new UC.UCTestPage()); break; case "表格": AddControl(new UC.UCTestGridTable() { Dock = DockStyle.Fill }); break; case "树表格": AddControl(new UC.UCTestTreeGridTable() { Dock = DockStyle.Fill }); break; case "进度条": AddControl(new UC.UCTestProcess() { Dock = DockStyle.Fill }); break; case "步骤控件": AddControl(new UC.UCTestStep() { Dock = DockStyle.Fill }); break; case "面包屑导航": AddControl(new UC.UCTestNavigation() { Dock = DockStyle.Fill }); break; case "文字提示": AddControl(new UC.UCTestTips() { Dock = DockStyle.Fill }); break; case "滚动文字": AddControl(new UC.UCTestRollText() { Dock = DockStyle.Fill }); break; case "滑块": AddControl(new UC.UCTestTrackbar() { Dock = DockStyle.Fill }); break; case "水波": AddControl(new UC.UCTestWave() { Dock = DockStyle.Fill }); break; case "有标题的面板": AddControl(new UC.UCTestPanelTitle() { Dock = DockStyle.Left }); break; case "图标": AddControl(new UC.UCTestIcon() { Dock = DockStyle.Fill }); break; #endregion #region 图表 English:Chart case "组织结构图": AddControl(new UC.UCTestMindMapping() { Dock = DockStyle.Fill }); break; case "柱状图": AddControl(new UC.UCTestBarcharts()); break; case "滚动图表": AddControl(new UC.UCTestWaveChart() { Dock = DockStyle.Fill }); break; #endregion #region 工业 English:Industry case "LED文字": AddControl(new UC.UCTestLED() { Dock = DockStyle.Fill }); break; case "仪表": AddControl(new UC.UCTestMeter()); break; case "管道": AddControl(new UC.UCTestConduit()); break; case "阀门": AddControl(new UC.UCTestValve()); break; case "鼓风机": AddControl(new UC.UCTestBlower()); break; case "传送带": AddControl(new UC.UCTestConveyor()); break; case "警示灯": AddControl(new UC.UCTestSignalLamp()); break; case "箭头": AddControl(new UC.UCTestArrow()); break; case "温度计": AddControl(new UC.UCTestThermometer()); break; #endregion } }