/// <summary> /// 增加PathDetail信息 /// </summary> /// <param name="pathDetail">线路具体信息类对象</param> /// <returns>此次操作影响的行数</returns> public int InsertPathDetail(PathDetailModel pathDetail) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@PathNo", SqlDbType.VarChar, 50), new SqlParameter("@StationAddress", SqlDbType.Int), new SqlParameter("@StationHeadAddress", SqlDbType.Int), new SqlParameter("@PathInterval", SqlDbType.Int) }; para[0].Value = pathDetail.PathNo; para[1].Value = pathDetail.StationAddress; para[2].Value = pathDetail.StationHeadAddress; para[3].Value = pathDetail.PathInterval; try { int result = help.RunProcedureByInt("insert_Path_Detail", para, out outStr); return(result); } catch (Exception ex) { return(0); } }
/// <summary> /// 设置listbox读卡分站 /// </summary> /// <param name="strPathNo"></param> private void SetListStation(string strPathNo) { alPathDetail.Clear(); listStation.Items.Clear(); DataTable dt = new DataTable(); dt = pathinfoBll.getStationHeadTable(strPathNo); int i = 0; if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { string strStationHeadID = dr["ID"].ToString(); string strStationHeadPlace = dr["StationHeadPlace"].ToString(); listStation.Items.Add(strStationHeadID + " " + strStationHeadPlace); string[] strAddress = strStationHeadID.Split('.'); PathDetailModel pModel = new PathDetailModel(); pModel.PathNo = txtPathID.Text; pModel.PathID = i; pModel.StationAddress = int.Parse(strAddress[0]); pModel.StationHeadAddress = int.Parse(strAddress[1]); alPathDetail.Add(pModel); alPathDetailAdd.Add(pModel); i++; } } }
/// <summary> /// 修改PathDetail信息 /// </summary> /// <param name="pathDetail">线路具体信息类对象</param> /// <returns>此次操作影响的行数</returns> public int UpdatePathDetail(PathDetailModel pathDetail) { if (pathDetailDal == null) { pathDetailDal = new PathDetailDal(); } int result = pathDetailDal.UpdatePathDetail(pathDetail); return(result); }
/// <summary> /// 增加PathDetail信息 /// </summary> /// <param name="pathDetail">线路具体信息类对象</param> /// <returns>此次操作影响的行数</returns> public int InsertPathDetail(PathDetailModel pathDetail) { if (pathDetailDal == null) { pathDetailDal = new PathDetailDal(); } int result = pathDetailDal.InsertPathDetail(pathDetail); return(result); }
/// <summary> /// 修改PathDetail信息 /// </summary> /// <param name="pathDetail">线路具体信息类对象</param> /// <returns>此次操作影响的行数</returns> public int UpdatePathDetail(PathDetailModel pathDetail) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@Id", SqlDbType.Int), new SqlParameter("@PathNo", SqlDbType.VarChar), new SqlParameter("@StationAddress", SqlDbType.Int), new SqlParameter("@StationHeadAddress", SqlDbType.Int) }; para[0].Value = pathDetail.Id; para[1].Value = pathDetail.PathNo; para[2].Value = pathDetail.StationAddress; para[3].Value = pathDetail.StationHeadAddress; int result = help.RunProcedureByInt("update_Path_Detail", para, out outStr); return(result); }
/// <summary> /// 修改PathDetail信息 /// </summary> /// <returns>返回操作结果 1表示成功</returns> private int UpdatePathDetailInfo() { try { //Serial_Path_Detail serialPathDetail = new Serial_Path_Detail(); //serialPathDetail.Operate = 2; //serialPathDetail.TableName = "Path_Detail"; //serialPathDetail.Id = Convert.ToInt32(dbgvMain.CurrentRow.Cells["Id"].Value.ToString()); //serialPathDetail.PathNo = dbgvMain.CurrentRow.Cells["PathNo"].Value.ToString(); //serialPathDetail.StationAddress = Convert.ToInt32(this.cbstation.SelectedValue); //serialPathDetail.StationHeadAddress = Convert.ToInt32(this.cbPiont.SelectedValue); //bool flag = KJ128Nsad.DataReceived(KJ128Nsad.SerialOperate(serialPathDetail)); PathDetailModel model = new PathDetailModel(); model.Id = Convert.ToInt32(dgvMain.CurrentRow.Cells["Id"].Value.ToString()); model.PathNo = this.tbPathNum.Text; model.StationAddress = Convert.ToInt32(this.cbstation.SelectedValue); model.StationHeadAddress = Convert.ToInt32(this.cbPiont.SelectedValue); //存入日志 LogSave.Messages("[FrmPathDetail]", LogIDType.UserLogID, "修改路径详细信息,路线编号:" + model.PathNo + ",分站安装位置:" + this.cbstation.SelectedText + ",接收器位置:" + this.cbPiont.SelectedText + "。"); int count = pathDetailBll.UpdatePathDetail(model); bool flag = (count == 1 ? true : false); if (flag) { return(1); } else { return(0); } } catch { return(0); } }
private void btnLeft_Click(object sender, EventArgs e) { if (listStation.SelectedIndex < 0) { SetShowInfo("请选择要删除的读卡分站", Color.Blue); return; } labMessage.Visible = false; string strTemp = listStation.Items[listStation.SelectedIndex].ToString(); string strAddressTemp = strTemp.Substring(0, strTemp.IndexOf(" ")); string[] strAddress = strAddressTemp.Split('.'); string strPlace = strTemp.Substring(strTemp.IndexOf(" ") + 1); TreeNode item = new TreeNode(); item.Name = strAddressTemp; item.Text = strPlace; //增加到删除列表中 PathDetailModel pathDetailModel = new PathDetailModel(); pathDetailModel.PathNo = txtPathID.Text; pathDetailModel.PathID = listStation.SelectedIndex; pathDetailModel.StationAddress = int.Parse(strAddress[0]); pathDetailModel.StationHeadAddress = int.Parse(strAddress[1]); for (int i = 0; i < alPathDetailAdd.Count; i++) { PathDetailModel pModel = (PathDetailModel)alPathDetailAdd[i]; if (pModel.PathNo.Equals(pathDetailModel.PathNo) && pModel.StationAddress == pathDetailModel.StationAddress && pModel.StationHeadAddress == pathDetailModel.StationHeadAddress && pModel.PathID == pathDetailModel.PathID) { alPathDetailAdd.Remove(pModel); break; } } for (int i = pathDetailModel.PathID; i < alPathDetailAdd.Count; i++) { PathDetailModel pModel = (PathDetailModel)alPathDetailAdd[i]; pModel.PathID = i; } //bool flag = false; //switch (m_type) //{ // case 1: // try // { // for (int i = 0; i < alPathDetailAdd.Count; i++) // { // PathDetailModel pModel = (PathDetailModel)alPathDetailAdd[i]; // if (pModel.PathNo.Equals(pathDetailModel.PathNo) && pModel.StationAddress == pathDetailModel.StationAddress && pModel.StationHeadAddress == pathDetailModel.StationHeadAddress && pModel.PathID == pathDetailModel.PathID) // { // alPathDetailAdd.Remove(pModel); // break; // } // } // } // catch { } // break; // case 2: // for (int i = 0; i < alPathDetail.Count; i++) // { // PathDetailModel pathDetail = (PathDetailModel)alPathDetail[i]; // if (pathDetail.StationAddress == pathDetailModel.StationAddress && pathDetail.StationHeadAddress == pathDetailModel.StationHeadAddress && pathDetail.PathID == pathDetailModel.PathID) // { // flag = true; // try // { // alPathDetailDelete.Add(pathDetailModel); // } // catch { } // break; // } // } // if (!flag) // { // try // { // for (int i = 0; i < alPathDetailAdd.Count; i++) // { // PathDetailModel pModel = (PathDetailModel)alPathDetailAdd[i]; // if (pModel.PathNo.Equals(pathDetailModel.PathNo) && pModel.StationAddress == pathDetailModel.StationAddress && pModel.StationHeadAddress == pathDetailModel.StationHeadAddress) // { // alPathDetailAdd.Remove(pModel); // break; // } // } // } // catch { } // } // break; //} //从列表框中删除 listStation.Items.RemoveAt(listStation.SelectedIndex); }
private void btnRight_Click(object sender, EventArgs e) { if (treeViewStation.SelectedNode == null || treeViewStation.SelectedNode.Level == 0) { SetShowInfo("请选择要增加的读卡分站", Color.Blue); return; } labMessage.Visible = false; if (txtPathID.Text.Trim().Equals("")) { SetShowInfo("请输入路径编号", Color.Blue); return; } //增加到列表框中 TreeNode node = treeViewStation.SelectedNode; string[] strAddress = node.Name.Trim().Split('.'); //增加到临时增加列表中 PathDetailModel pathDetailModel = new PathDetailModel(); pathDetailModel.PathNo = txtPathID.Text; pathDetailModel.StationAddress = int.Parse(strAddress[0]); pathDetailModel.StationHeadAddress = int.Parse(strAddress[1]); if (listStation.Items.Count > 0) { if (listStation.SelectedIndex > 0) { listStation.Items.Insert(listStation.SelectedIndex + 1, node.Name + " " + node.Text); pathDetailModel.PathID = listStation.SelectedIndex + 1; try { alPathDetailAdd.Insert(listStation.SelectedIndex + 1, pathDetailModel); } catch { } for (int i = pathDetailModel.PathID; i < alPathDetailAdd.Count; i++) { PathDetailModel pathDetailaddTemp = (PathDetailModel)alPathDetailAdd[i]; pathDetailaddTemp.PathID = i; } } else { pathDetailModel.PathID = listStation.Items.Count; listStation.Items.Add(node.Name + " " + node.Text); try { alPathDetailAdd.Add(pathDetailModel); } catch { } } } else { pathDetailModel.PathID = listStation.Items.Count; listStation.Items.Add(node.Name + " " + node.Text); try { alPathDetailAdd.Add(pathDetailModel); } catch { } } }
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); } } }