using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.Tools; using DevComponents.DotNetBar.Controls; using DevComponents.Editors; using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace Casic.Birmm.RbFreqStandMeasure.info { public partial class AddDevDlg : Form { #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); public const int WM_SYSCOMMAND = 0x0112; public const int SC_MOVE = 0xF010; public const int HTCAPTION = 0x0002; private void panel1_MouseDown(object sender, MouseEventArgs e) { //拖动窗体 ReleaseCapture(); SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); } #endregion DictService dictService = new DictServiceImpl(); DetectionItemService detectionItemService = new DetectionItemServiceImpl(); public Action HideMaskAction { get; set; } public AddDevDlg() { InitializeComponent(); cbBox_devType.DataSource = dictService.getTypeListByCodeType("devType"); btnSave.Text = "添加仪器"; if (HomeCtrlForm.channelFreeList.Count > 0) { cbBox_channelFree.Items.Add(""); foreach (string item in HomeCtrlForm.channelFreeList) { cbBox_channelFree.Items.Add(item); } } else { text_channelNo.WatermarkText = "无空闲通道可选"; } } // 关闭对话框 private void btnAddDevCancel_Click(object sender, EventArgs e) { this.HideMaskAction(); } // 添加并开始检测 private void btnSave_Click(object sender, EventArgs e) { if (text_channelNo.Text.Trim() != "") { if (checkBox_stability.Checked && !checkBox_1s.Checked && !checkBox_10s.Checked && !checkBox_20s.Checked && !checkBox_100s.Checked) { MessageBox.Show("请选择频率稳定度!"); return; } if (!checkBox_accuracy.Checked && !checkBox_stability.Checked && !checkBox_ageRate.Checked && !checkBox_bootFeature.Checked && !checkBox_count.Checked) { MessageBox.Show("请选择检测项目!"); return; } } // 取得输入框的参数 string devName = ((TextBoxX) this.Controls.Find("inputDevName", true)[0]).Text; string devCode = ((TextBoxX) this.Controls.Find("inputDevCode", true)[0]).Text; string devModel = ((TextBoxX)this.Controls.Find("inputDevModel", true)[0]).Text; string devCustomComp = ((TextBoxX)this.Controls.Find("inputCustComp", true)[0]).Text; string devCustomName = ((TextBoxX)this.Controls.Find("inputCustName", true)[0]).Text; ComboBoxEx channels = (ComboBoxEx)this.Controls.Find("cbBox_channelFree", true)[0]; string channelNo = (string)((ComboItem)channels.SelectedItem).Value; // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); int id = devService.add(devName, devCode, "1", devModel, devCustomComp, devCustomName, channelNo); if (id >= 0) { if (btnSave.Text.Equals("添加并开始检测")) { //detectionItemService.add(deviceId, timePicker_startTime.Value, timePicker_endTime.Value, stability, accuracy, bootFeature, ageRate, interval); // 重新加载首页的通道状态 HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } // 添加成功,继续保存检测项目和开始时间 this.HideMaskAction(); } else { LogHelper.WriteErrorLog(this.GetType(), "添加设备[" + devName + "]失败"); } } private void btn_downChannelList_Click(object sender, EventArgs e) { cbBox_channelFree.DroppedDown = true; } private void groupBox4_Enter(object sender, EventArgs e) { cbBox_channelFree.DroppedDown = false; cbBox_devType.DroppedDown = false; } private void groupBox1_Enter(object sender, EventArgs e) { cbBox_channelFree.DroppedDown = false; cbBox_devType.DroppedDown = false; } private void btn_downTypeList_Click(object sender, EventArgs e) { cbBox_devType.DroppedDown = true; } private void checkBox_startNow_CheckedChanged(object sender, EventArgs e) { startTime.Value = DateTime.Now; } private void cbBox_devType_SelectedIndexChanged(object sender, EventArgs e) { text_devType.Text = cbBox_devType.SelectedItem.ToString(); } private void cbBox_channelFree_SelectedIndexChanged(object sender, EventArgs e) { text_channelNo.Text = cbBox_channelFree.SelectedItem.ToString(); if (text_channelNo.Text != "") { btnSave.Text = "添加并开始检测"; checkBox_startNow.Enabled = true; groupBox1.Enabled = true; } else { btnSave.Text = "添加仪器"; groupBox1.Enabled = false; checkBox_startNow.Enabled = false; } } private void checkBox13_CheckedChanged(object sender, EventArgs e) { } private void checkBox_stability_CheckedChanged(object sender, EventArgs e) { if (checkBox_stability.Checked) groupBox2.Enabled = true; else groupBox2.Enabled = false; } } }