/// <summary> /// 修改信息 /// </summary> /// <returns></returns> private int UpdatePathInfoModel() { try { //Serial_Path_Info serialPathInfo = new Serial_Path_Info(); //serialPathInfo.Operate = 2; //serialPathInfo.TableName = "Path_Info"; //serialPathInfo.Id = Convert.ToInt32(this.tbPathId.Text.Trim()); //serialPathInfo.PathNo = this.tbPathNo.Text; //serialPathInfo.PathName = this.tbPathName.Text; //serialPathInfo.Remark = this.tbRemark.Text; //bool flag = KJ128Nsad.DataReceived(KJ128Nsad.SerialOperate(serialPathInfo)); //存入日志 LogSave.Messages("[FrmPathInfo]", LogIDType.UserLogID, "修改路径基本信息,路线编号:" + this.tbPathNo.Text + ",路线名:" + this.tbPathName.Text + "。"); KJ128NModel.PathInfoModel model = new PathInfoModel(); model.Id = Convert.ToInt32(this.tbPathId.Text.Trim()); model.PathNo = this.tbPathNo.Text; model.PathName = this.tbPathName.Text; model.Remark = this.tbRemark.Text; string strMessage = ""; int count = infoBll.UpdatePathInfo(model, out strMessage); bool flag = (count == 1 ? true : false); if (flag) { return(1); } else { return(0); } } catch { return(0); } }
private void btnSave_Click(object sender, EventArgs e) { if (Check()) { PathInfoModel pathInfoModel = new PathInfoModel(); pathInfoModel.PathNo = txtPathID.Text; pathInfoModel.PathName = txtPathName.Text; pathInfoModel.Remark = ""; string strMessage = ""; int rowCount = 0; switch (m_type) { case 1: rowCount = pathinfoBll.InsertPathInfo(pathInfoModel, out strMessage); break; case 2: pathInfoModel.Id = int.Parse(txtID.Text); rowCount = pathinfoBll.UpdatePathInfo(pathInfoModel, out strMessage); break; } if (strMessage.Equals("Succeeds")) { if (rowCount > 0) { try { for (int i = 0; i < alPathDetail.Count; i++) { PathDetailModel pathDetail = (PathDetailModel)alPathDetail[i]; pathDetail.PathNo = txtPathID.Text; pathinfoBll.DeletePathDetail(pathDetail.PathNo, pathDetail.StationAddress, pathDetail.StationHeadAddress); } for (int i = 0; i < alPathDetailAdd.Count; i++) { PathDetailModel pathDetail1 = (PathDetailModel)alPathDetailAdd[i]; pathDetail1.PathNo = txtPathID.Text; pathDetail1.PathInterval = i + 1; pathinfoBll.InsertPathDetail(pathDetail1); } SetShowInfo("保存成功", Color.Black); if (!New_DBAcess.IsDouble) //单机版,直接刷新 { m_frmPathManage.SetTreeViewPath(); m_frmPathManage.BindData(""); } else //热备版,启用定时器 { m_frmPathManage.HostBackRefresh(true); } //this.Close(); } catch { SetShowInfo("保存失败", Color.Black); } } else { SetShowInfo("路径添加重复", Color.Red); } } else { SetShowInfo("保存路径失败", Color.Black); } } }