private void importdev_st_FinishClick(object sender, CancelEventArgs e) { // MessageBox.Show("恭喜您设定完毕"); //MessageBox.Show(string.Format("您的机器id是 {0}", global.MachineID)); //MessageBox.Show(string.Format("您的设备昵称是 {0}", textBoxX2.Text)); string gz_name = textBoxX2.Text; // MessageBox.Show(string.Format("当前选择的串口是 == {0} == ", cur_work_portname)); Maticsoft.BLL.port tempport_bll = new Maticsoft.BLL.port(); string cur_macnum = global.MachineID; List <Maticsoft.Model.port> port_objs = tempport_bll.GetModelList(string.Format(" mac = '{0}' and portname= '{1}' ", cur_macnum, cur_work_portname)); // 先找是不是有 if (port_objs.Count > 0) { // 覆盖掉 Maticsoft.Model.port temp_port = port_objs[0]; temp_port.manufacturer = gz_name; temp_port.workid = textBoxX3.Text; temp_port.devicetype = type; tempport_bll.Update(temp_port); //// 如果存在的话 就先提醒一下。 用户点确认之后 覆盖以前的com //DialogResult ret = MessageBox.Show("发现已经存在com的记录", "是否使用这个名字", MessageBoxButtons.OKCancel); //if (ret == DialogResult.OK) //{ // // MessageBox.Show("以更新,工具已经可以使用"); //} } else { // 不存在就直接添加 Maticsoft.Model.port tmp_portobj = new Maticsoft.Model.port() { mac = cur_macnum, manufacturer = gz_name, portname = cur_work_portname, devicetype = type, workid = textBoxX3.Text }; tempport_bll.Add(tmp_portobj); } this.Close(); }
/// <summary> /// 界面load事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TestBZFrom_Load(object sender, EventArgs e) { // 获得工具信息 并放进combox #region 获得所有测量工具信息 //Maticsoft.BLL.testdevice td = new Maticsoft.BLL.testdevice(); //td_lists = td.GetModelList(""); //List<string> device_lists = td_lists.ConvertAll<string>(a => a.devicename); Maticsoft.BLL.port port_bll = new Maticsoft.BLL.port(); port_list = port_bll.GetModelList(string.Format(" mac = '{0}' ", global.MachineID)); List <string> device_lists = port_list.ConvertAll <string>(a => a.manufacturer); //绑定推荐的数据源 comboBox_devs.Items.AddRange(device_lists.ToArray()); #endregion // textbox_ljh.Text = Program.gdvid; textbox_ljh.Text = LjHao; label_ljh.Text = "零件类型:" + LjHao; initdgv(); this.timer_shine.Enabled = true; this.timer_ref.Enabled = true; dgv.ClearSelection(); }