private void gridViewPaging1_PagingChanged_1(object sender, MyPagingEventArgs e) { if (BgwWait.IsBusy == false) { gridControl1.RefreshDataSource(); BgwWait.RunWorkerAsync("SearchData"); } }
// private List<SRDevice.DeviceParameter> lstModel = null; public DevParamter(UserContext context, string strDevCode, string strDevName) : base(context) { InitializeComponent(); BgwWait.ProgressChanged += this.backgroundWorker_ProgressChanged; this.strDevCode = strDevCode; DevCodeTextEdit.Text = strDevCode; this.Text = string.Format("{0} -设备名称:{1}", Text, strDevName); gridViewPaging1.DataPaging.PageSize = 9; page = gridViewPaging1.DataPaging; bbtniSave.Enabled = false; BgwWait.RunWorkerAsync("SearchData"); // GetFirstData(); }
private void BgwWait_DoWork(object sender, DoWorkEventArgs e) { //BgwWait.ReportProgress(0); try { switch (e.Argument.ToString()) { case "SaveData": using (SRDevice.DeviceServiceClient client = new SRDevice.DeviceServiceClient()) { var ret = client.AddDevParameter(context.SessionID, model); if (ret.IsSuccess) { SearchData(e); BgwWait.ReportProgress(99, "保存成功!"); } break; } case "DelData": using (SRDevice.DeviceServiceClient client = new SRDevice.DeviceServiceClient()) { var ret = client.DelDevParameterByCode(context.SessionID, DevpCodeTextEdit.Text); if (ret.IsSuccess) { SearchData(e); BgwWait.ReportProgress(99, "删除成功!"); } break; } case "SearchData": //earchData(e);strDevCode int iTotalNum = 1; int iCurrPage = (int)page.CurrentPage; int iPageSize = (int)page.PageSize; // int iPageSize = 2; using (var client = new SRDevice.DeviceServiceClient()) { var ret = client.GetDevParByCodePaging(context.SessionID, iPageSize, iCurrPage, ref iTotalNum, strDevCode); if (ret.IsSuccess) { page.CurrentPage = iCurrPage; page.RowCount = iTotalNum; e.Result = ret.Data; } else { BgwWait.ReportProgress(101, ret.Message); } } break; case "UpdData": using (SRDevice.DeviceServiceClient client = new SRDevice.DeviceServiceClient()) { var ret = client.UpdatDevParameter(context.SessionID, model); if (ret.IsSuccess) { SearchData(e); BgwWait.ReportProgress(99, "修改成功!"); } break; } default: break; } } catch (Exception ex) { BgwWait.ReportProgress(101, ex.Message); } }
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()); } }
private void barManager1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { if (BgwWait.IsBusy == false) { switch (e.Item.Name) { case "bbtnseach": BgwWait.RunWorkerAsync("SearchData"); bbtniAdd.Enabled = true; bbtniSave.Enabled = false; bbtniUpdate.Enabled = true; bbtniDel.Enabled = true; break; case "bbtniAdd": InsterData(); bbtniAdd.Enabled = false; bbtniSave.Enabled = true; bbtniUpdate.Enabled = false; bbtniDel.Enabled = false; break; case "bbtniSave": iPRegistFormBindingSource.EndEdit(); if (IPTextEdit.Text == "") { ClsMsg.ShowWarningMsg("IP为必填项,请输入完整数据!"); } else if (ClsMsg.ShowQuestionMsg("是否要保存当前数据呢?") == DialogResult.Yes) { BgwWait.RunWorkerAsync("SaveData"); } bbtniAdd.Enabled = true; bbtniSave.Enabled = false; bbtniUpdate.Enabled = true; bbtniDel.Enabled = true; break; case "bbtniDel": iPRegistFormBindingSource.EndEdit(); if (model != null && ClsMsg.ShowQuestionMsg("是否要删除当前数据呢?") == DialogResult.Yes) { BgwWait.RunWorkerAsync("DelData"); } break; case "bbtniUpdate": iPRegistFormBindingSource.EndEdit(); if (model != null && ClsMsg.ShowQuestionMsg("是否要更新当前数据呢?") == DialogResult.Yes) { BgwWait.RunWorkerAsync("UpdData"); } break; case "bbtnExit": this.Close(); break; default: break; } } } catch (Exception ex) { ClsMsg.ShowErrMsg(ex.ToString()); } }
private void BgwWait_DoWork(object sender, DoWorkEventArgs e) { BgwWait.ReportProgress(PubConstant.WaitMessageStatus.START); try { switch (e.Argument.ToString()) { case "SearchData": using (SRCfPExecute.CfPExecuteServiceClient client = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = client.GetAllIPRegistForm(context.SessionID); e.Result = ret.Data; } break; case "SaveData": using (SRCfPExecute.CfPExecuteServiceClient client = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = client.InsterRegistForm(context.SessionID, model); if (ret.IsSuccess) { e.Result = client.GetAllIPRegistForm(context.SessionID).Data; BgwWait.ReportProgress(99, "保存成功!"); } break; } case "DelData": using (SRCfPExecute.CfPExecuteServiceClient client = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = client.DeleteRegistFormById(context.SessionID, model); if (ret.IsSuccess) { e.Result = client.GetAllIPRegistForm(context.SessionID).Data; BgwWait.ReportProgress(99, "删除成功!"); } break; } case "UpdData": using (SRCfPExecute.CfPExecuteServiceClient client = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = client.UpdateRegistForm(context.SessionID, model); if (ret.IsSuccess) { e.Result = client.GetAllIPRegistForm(context.SessionID).Data; BgwWait.ReportProgress(99, "修改成功!"); } break; } default: break; } } catch (Exception ex) { BgwWait.ReportProgress(101, ex.Message); } BgwWait.ReportProgress(PubConstant.WaitMessageStatus.END); }