/// <summary> /// 获取首行数据用于初始显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// private void GetFirstData() { var model2 = gridView1.GetRow(1) as SRDevice.DeviceParameter; model = new SRDevice.DeviceParameter() { DevCode = model2.DevCode, DevpCode = model2.DevpCode, DevpName = model2.DevpName, MaxValue = model2.MaxValue, MinValue = model2.MinValue, StandardValue = model2.StandardValue, Remark = model2.Remark }; deviceParameterBindingSource.DataSource = model; }
private void gridControl1_DoubleClick(object sender, EventArgs e) { var model1 = gridView1.GetRow(gridView1.FocusedRowHandle) as SRDevice.DeviceParameter; model = new SRDevice.DeviceParameter() { DevCode = model1.DevCode, DevpCode = model1.DevpCode, DevpName = model1.DevpName, MaxValue = model1.MaxValue, MinValue = model1.MinValue, StandardValue = model1.StandardValue, Remark = model1.Remark, SerialPort = model1.SerialPort, BaudRate = model1.BaudRate, CheckBit = model1.CheckBit, DataBit = model1.DataBit, StopBit = model1.StopBit, }; deviceParameterBindingSource.DataSource = model; DevpCodeTextEdit.Properties.ReadOnly = true; }
private void bmTool_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { if (BgwWait.IsBusy == false) { switch (e.Item.Name) { case "bbtnseach": BgwWait.RunWorkerAsync("SearchData"); break; case "bbtniAdd": DevpCodeTextEdit.Properties.ReadOnly = false; model = new SRDevice.DeviceParameter() { DevCode = strDevCode }; deviceParameterBindingSource.DataSource = model; // DevpCodeTextEdit.Properties.ReadOnly = true; bbtniSave.Enabled = true; bbtniUpdate.Enabled = false; bbtniDel.Enabled = false; // ClsMsg.ShowWarningMsg("开启设备编辑模式!"); break; case "bbtniSave": // deviceParameterBindingSource.DataSource = model; // model = new SRDevice.DeviceClass(); deviceParameterBindingSource.EndEdit(); // if (this.DeviCodeTextEdit.Text != "" && this.DeviNameTextEdit.Text != "" && this.DevpCodeTextEdit.Text != "" && this.DataTypeTextEdit.Text != "" && this.DevpAddressTextEdit.Text != "" && this.SendFormatTextEdit.Text != "") if (model == null || this.DevCodeTextEdit.Text == "" || this.DevpCodeTextEdit.Text == "" || this.DevpNameTextEdit.Text == "" || this.StandardValueTextEdit.Text == "" || this.MaxValueTextEdit.Text == "" || this.MinValueTextEdit.Text == "") { ClsMsg.ShowWarningMsg("请输入完整数据!"); } else if (ClsMsg.ShowQuestionMsg("是否要保存当前数据呢?") == DialogResult.Yes) { BgwWait.RunWorkerAsync("SaveData"); } break; case "bbtniDel": deviceParameterBindingSource.EndEdit(); if (model != null && ClsMsg.ShowQuestionMsg("是否要删除当前数据呢?") == DialogResult.Yes) { BgwWait.RunWorkerAsync("DelData"); } break; case "bbtniUpdate": deviceParameterBindingSource.EndEdit(); if (model != null && ClsMsg.ShowQuestionMsg("是否要更新当前数据呢?") == DialogResult.Yes) { BgwWait.RunWorkerAsync("UpdData"); } break; case "bbtnExit": this.Close(); break; case "barButtonItem2": if (BgwWait.IsBusy == false) { gridControl1.RefreshDataSource(); BgwWait.RunWorkerAsync("SearchData"); } break; default: break; } } } catch (Exception ex) { ClsMsg.ShowErrMsg(ex.ToString()); } }