/// <summary> /// 修改Path_Info /// </summary> /// <param name="pathInfo">线路信息类对象</param> /// <returns>此次操作影响的行数</returns> public int UpdatePathInfo(PathInfoModel pathInfo, out string strMessage) { if (pathInfodal == null) { pathInfodal = new PathInfoDal(); } int result = pathInfodal.UpdatePathInfo(pathInfo, out strMessage); return(result); }
/// <summary> /// 增加PathInfo信息 /// </summary> /// <param name="pathInfo">线路信息类对象</param> /// <returns>此次操作影响的行数</returns> public int InsertPathInfo(PathInfoModel pathInfo, out string strMessage) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@PathNo", SqlDbType.VarChar, 50), new SqlParameter("@PathName", SqlDbType.VarChar, 100), new SqlParameter("@Remark", SqlDbType.VarChar, 200), }; para[0].Value = pathInfo.PathNo; para[1].Value = pathInfo.PathName; para[2].Value = pathInfo.Remark; int result = help.RunProcedureByInt("insert_Path_Info", para, out strMessage); return(result); }
/// <summary> /// 修改路线信息时,初始化修改信息状态 /// </summary> /// <param name="pachinfo"></param> private void InitializeToUpdate(PathInfoModel pathInfo) { if (pathInfo != null) { //this.lblPathId.Visible = true; //this.tbPathId.Visible = true; this.btnAddNew.Visible = false; this.tbPathId.Text = pathInfo.Id.ToString(); this.tbPathNo.Text = pathInfo.PathNo.ToString(); this.tbPathName.Text = pathInfo.PathName; this.tbRemark.Text = pathInfo.Remark; this.bcpAdd.CaptionTitle = "修改线路信息"; this.btnAdd.CaptionTitle = "修改"; this.vspnlAdd.Visible = true; } }
/// <summary> /// 修改PathInfo信息 /// </summary> /// <param name="pathInfo">线路信息类对象</param> /// <returns>此次操作影响的行数</returns> public int UpdatePathInfo(PathInfoModel pathInfo, out string strMessage) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@Id", SqlDbType.Int), new SqlParameter("@PathNo", SqlDbType.VarChar, 50), new SqlParameter("@PathName", SqlDbType.VarChar, 100), new SqlParameter("@Remark", SqlDbType.VarChar, 200), }; para[0].Value = pathInfo.Id; para[1].Value = pathInfo.PathNo; para[2].Value = pathInfo.PathName; para[3].Value = pathInfo.Remark; int result = Convert.ToInt32(help.RunProcedureByInt("update_Path_Info", para, out strMessage)); return(result); }
/// <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); } } }
/// <summary> /// 单击DataGridView的修改和删除操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dbgvMain_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { string operate = dgvMain.CurrentRow.Cells[e.ColumnIndex].Value.ToString(); if (operate == "修改") { PathInfoModel info = new PathInfoModel(); info.Id = Convert.ToInt32(dgvMain.CurrentRow.Cells["PathId"].Value.ToString()); info.PathNo = dgvMain.CurrentRow.Cells["PathNo"].Value.ToString(); info.PathName = dgvMain.CurrentRow.Cells["PathName"].Value.ToString(); info.Remark = dgvMain.CurrentRow.Cells["Remark"].Value.ToString(); InitializeToUpdate(info); } else if (operate == "删除") { operated = 2; try { this.vspnlAdd.Visible = false; DialogResult dr = MessageBox.Show("您是否确认删除?如果确认将会删除与其相关联的数据,无法恢复", "重要确认提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { //存入日志 LogSave.Messages("[FrmPathInfo]", LogIDType.UserLogID, "删除路径基本信息,路线编号:" + dgvMain.CurrentRow.Cells["PathNo"].Value.ToString() + ",路线名:" + dgvMain.CurrentRow.Cells["PathName"].Value.ToString() + "。"); ////Serial_Path_Info serialPathInfo = new Serial_Path_Info(); ////serialPathInfo.Operate = 3; ////serialPathInfo.TableName = "Path_Info"; ////serialPathInfo.Id = Convert.ToInt32(dbgvMain.CurrentRow.Cells["PathId"].Value.ToString()); ////bool flag = KJ128Nsad.DataReceived(KJ128Nsad.SerialOperate(serialPathInfo)); //(count == 1 ? true : false); int id = Convert.ToInt32(dgvMain.CurrentRow.Cells["PathId"].Value.ToString()); int count = infoBll.DeletePathInfo(id); bool flag = (count == 1 ? true : false); if (flag) { if (!New_DBAcess.IsDouble) { InitializeTreeView(""); InitializeGridView(""); } else { timer1.Start(); } } else { MessageBox.Show("删除操作失败", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("删除失败:" + ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }