/// <summary> /// 在门岗名称上更改SelectedValueChanged的值时引发事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbxPositionName_SelectedValueChanged(object sender, EventArgs e) { if (cbxDrivewayName.Items.Count > 0) { this.cbxDrivewayName.Items.Clear(); } if (cbxPositionName.Text == "") { return; } string PositionName = this.cbxPositionName.Text; var name = DrivewayDAL.GetViewDrivewayName(String.Format("select * from View_DrivewayPosition where Position_Name='{0}' and Driveway_State='启动'", PositionName)); if (name != null) { foreach (var item in name) { if (item.Driveway_Name != null) { if (item.Driveway_Type != null) { cbxDrivewayName.Items.Add(item.Driveway_Name + item.Driveway_Type); cbxDrivewayName.SelectedIndex = 0; } } } } }
// 定义一个全局变量: 通道编号 /// <summary> /// Load 加载 事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FVNForm_Load(object sender, EventArgs e) { try { userContext(); btnUpdate.Enabled = false; btnSelect_Click(btnSelect, null); mf = new MainForm(); LoadData(); // 调用显示DatagridView的方法 BindMenGang(); // 调用绑定门岗的方法 BindFVN(); BindSearchFVN(); BindFVNType(); BindSearchFVNType(); BindMenGang1(); DrivewayName(); if (iFvnID > 0) { // 若通道管理界面中有选择“通道”再跳转的,则显示如下 Expression <Func <View_DrivewayPosition, bool> > funviewinto = n => n.Driveway_ID == iFvnID; foreach (var n in DrivewayDAL.Query(funviewinto)) { if (n.Position_Name != null && n.Driveway_Name != null) { this.cbxPositionName.Text = n.Position_Name; this.cbxDrivewayName.Text = n.Driveway_Name + n.Driveway_Type; //string PName = n.Position_Name; //获取数据库读取到的门岗名称 //string DName = n.Driveway_Name; //var name = DrivewayDAL.GetViewDrivewayName(String.Format("select * from View_DrivewayPosition where Position_Name='{0}' and Driveway_Name='{1}'", PName, DName)); //if (name != null) //{ // foreach (var item in name) // { // if (item.Driveway_Name != null) // { // if (item.Driveway_Type != null) // { // this.cbxDrivewayName.Text = item.Driveway_Name + item.Driveway_Type; // cbxDrivewayName.SelectedIndex = 0; // } // } // } //} } } } } catch { MessageBox.Show("加载地感信息有误,请查看与地感相关的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
/// <summary> /// 删除 选中行数据的方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tbtnDelPosition() { try { int j = 0; if (dgvDrivewayList.SelectedRows.Count > 0)//选中删除 { if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { //选中数量 int count = dgvDrivewayList.SelectedRows.Count; string id = ""; //遍历 for (int i = 0; i < count; i++) { //----------------------------------------------------------------------------------------- int drid = int.Parse(this.dgvDrivewayList.SelectedRows[i].Cells["Driveway_ID"].Value.ToString()); Expression <Func <Driveway, bool> > funuserinfo = n => n.Driveway_ID == drid; string strContent = LinQBaseDao.Query("Select (Position_Name+Driveway_Name) as DrivewayPosition from View_DrivewayPosition where Driveway_ID=" + drid).Tables[0].Rows[0][0].ToString(); if (DrivewayDAL.DeleteToMany(funuserinfo)) { j++; CommonalityEntity.WriteLogData("删除", "删除通道名称为:" + strContent + " 的信息", common.USERNAME);//添加日志 } } if (j == count) { MessageBox.Show("成功删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //重新绑定通道值 tongdaoZ(); } else { MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } else//没有选中 { MessageBox.Show("请选择要删除的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { CommonalityEntity.WriteTextLog("通道管理 tbtnDelPosition()+"); } finally { LogInfoLoad(""); } }
/// <summary> /// 修改查重 /// </summary> /// <returns></returns> private bool btnCheckupdate() { bool rbool = true; try { //定义字段用以保存门岗名称和通道值,读卡器编号 string Position_Name = this.cbxDriveway_PositionName.Text; //门岗名称 string Driveway_Value = this.txtDriveway_Value.Text.Trim(); //通道值 string Driveway_Name = this.txtDriveway_Name.Text.Trim(); string Driveway_ReadCardPort = this.txtDriveway_ReadCardPort.Text.Trim(); //通道读卡器地址码 //判断名称是否已存在 Expression <Func <View_DrivewayPosition, bool> > funviewPosition = n => n.Position_Name == Position_Name && n.Driveway_Value == Driveway_Value && n.Driveway_Value != this.dgvDrivewayList.SelectedRows[0].Cells["Driveway_Value"].Value.ToString(); if (DrivewayDAL.Query(funviewPosition).Count() > 0) { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "该通道值已存在", txtDriveway_Value, this); txtDriveway_Value.Focus(); rbool = false;; } Expression <Func <View_DrivewayPosition, bool> > funviewPosition2 = n => n.Position_Name == Position_Name && n.Driveway_Name == Driveway_Name && n.Driveway_Value != this.dgvDrivewayList.SelectedRows[0].Cells["Driveway_Value"].Value.ToString(); if (DrivewayDAL.Query(funviewPosition2).Count() > 0) { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "该通道名称已存在", txtDriveway_Value, this); txtDriveway_Value.Focus(); rbool = false;; } Expression <Func <View_DrivewayPosition, bool> > funviewPosition1 = n => n.Position_Name == Position_Name && n.Driveway_ReadCardPort == Driveway_ReadCardPort && n.Driveway_ReadCardPort != this.dgvDrivewayList.SelectedRows[0].Cells["Driveway_ReadCardPort"].Value.ToString(); if (DrivewayDAL.Query(funviewPosition1).Count() > 0) { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "该通道读卡器地址码已存在", txtDriveway_ReadCardPort, this); txtDriveway_ReadCardPort.Focus(); rbool = false;; } return(rbool); } catch { CommonalityEntity.WriteTextLog("通道管理 btnCheck()"); rbool = false; } return(rbool); }
/// <summary> /// Load 加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CameraForm_Load(object sender, EventArgs e) { try { userContext(); btnUpdate.Enabled = false; btnSelect_Click(btnSelect, null); BindCamera(); BindSearchCamera(); BindCameraLoca(); BindCameraLocaSearch(); BindMenGang(); // 调用绑定门岗的方法 BindMenGang1(); DrivewayName(); cmbDVI.SelectedIndex = 0; mf = new MainForm(); LoadData(); // 调用显示DatagridView的方法 if (iCameraID > 0) { // 若通道管理界面中有选择“通道”再跳转的,则显示如下 Expression <Func <View_DrivewayPosition, bool> > funviewinto = n => n.Driveway_ID == iCameraID; foreach (var n in DrivewayDAL.Query(funviewinto)) { if (n.Position_Name != null) { this.cbxPositionName.Text = n.Position_Name; this.cbxDrivewayName.Text = n.Driveway_Name + n.Driveway_Type; string PName = n.Position_Name; //获取数据库读取到的门岗名称 } } } } catch { MessageBox.Show("加载摄像头管理信息有误,请查看相关信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
/// <summary> /// “修改” 按钮的单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { try { if (this.txtCamera_Name.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "摄像头名称不能为空!", txtCamera_Name, this); return; } if (this.txtCamera_CardAdd.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "摄像头地址码不能为空!", txtCamera_CardAdd, this); return; } string PositionName = this.cbxPositionName.Text.ToString(); int lenth = cbxDrivewayName.Text.Trim().Length; string DrivewayName = cbxDrivewayName.Text.Trim().Substring(0, 4); string DrivewayType = cbxDrivewayName.Text.Trim().Substring(lenth - 1, 1); int DrivewayID = 0; var p = DrivewayDAL.GetViewDrivewayName(String.Format("select Driveway_ID from View_DrivewayPosition where Position_Name='{0}' and Driveway_Name= '{1}' and Driveway_Type= '{2}'", PositionName, DrivewayName, DrivewayType)); if (p != null) { foreach (var n in p) { if (n.Driveway_ID > 0) { DrivewayID = n.Driveway_ID; } break; } } if (this.dgvCamera.SelectedRows.Count > 0)//选中行 { if (dgvCamera.SelectedRows.Count > 1) { MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (!btnCheckupdate()) { return; // 去重复 } Expression <Func <Camera, bool> > pc = n => n.Camera_ID == int.Parse(this.dgvCamera.SelectedRows[0].Cells["Camera_ID"].Value.ToString()); string id = ""; string strfront = ""; string strcontent = ""; Action <Camera> ap = s => { strfront = s.Camera_Driveway_ID + "," + s.Camera_Name + "," + s.Camera_AddCard + "," + s.Camera_State + "," + s.Camera_Location + "," + s.Camera_Remark; s.Camera_Driveway_ID = DrivewayID; s.Camera_Name = this.txtCamera_Name.Text.Trim(); s.Camera_AddCard = this.txtCamera_CardAdd.Text.Trim(); s.Camera_State = this.cbxCamera_State.Text; s.Camera_Location = this.cbxCamera_Location.Text; s.Camera_Remark = this.txtCamera_Remark.Text.Trim(); s.Camera_DVIName = cmbDVI.Text; strcontent = s.Camera_Driveway_ID + "," + s.Camera_Name + "," + s.Camera_AddCard + "," + s.Camera_State + "," + s.Camera_Location + "," + s.Camera_Remark; id = s.Camera_ID.ToString(); }; if (CameraDAL.Update(pc, ap)) { MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); CommonalityEntity.WriteLogData("修改", "更新编号为:" + id + "的摄像头信息;修改前:" + strfront + ";修改后:" + strcontent, CommonalityEntity.USERNAME);//添加操作日志 } else { MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } catch { CommonalityEntity.WriteTextLog("摄像头管理 btnUpdate_Click()"); } finally { LogInfoLoad(""); this.btnUpdate.Enabled = false; this.btnSave.Enabled = true; } }
/// <summary> /// “保存” 按钮的单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { if (this.txtCamera_Name.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "摄像头名称不能为空!", txtCamera_Name, this); return; } if (this.txtCamera_CardAdd.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "摄像头地址码不能为空!", txtCamera_CardAdd, this); return; } string PositionName = this.cbxPositionName.Text.ToString(); int lenth = cbxDrivewayName.Text.Trim().Length; string DrivewayName = cbxDrivewayName.Text.Trim().Substring(0, 4); string DrivewayType = cbxDrivewayName.Text.Trim().Substring(lenth - 1, 1); int DrivewayID = 0; var p = DrivewayDAL.GetViewDrivewayName(String.Format("select Driveway_ID from View_DrivewayPosition where Position_Name='{0}' and Driveway_Name= '{1}' and Driveway_Type= '{2}'", PositionName, DrivewayName, DrivewayType)); if (p != null) { foreach (var n in p) { if (n.Driveway_ID > 0) { DrivewayID = n.Driveway_ID; } break; } } if (!btnCheck()) { return; // 去重复 } var Cameraadd = new Camera { Camera_Driveway_ID = DrivewayID, Camera_Name = this.txtCamera_Name.Text.Trim(), Camera_AddCard = this.txtCamera_CardAdd.Text.Trim(), Camera_State = this.cbxCamera_State.Text, Camera_Location = this.cbxCamera_Location.Text, Camera_Remark = this.txtCamera_Remark.Text.Trim(), Camera_DVIName = cmbDVI.Text }; if (CameraDAL.InsertOneCamera(Cameraadd)) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); CommonalityEntity.WriteLogData("新增", "新增摄像头名称为:" + txtCamera_Name.Text.Trim() + "的信息", CommonalityEntity.USERNAME);//添加操作日志 } else { MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { CommonalityEntity.WriteTextLog("摄像头管理 btnSave_Click()"); } finally { LogInfoLoad(""); } }
/// <summary> /// 双击组件时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvDrivewayList_DoubleClick(object sender, EventArgs e) { boo = false; this.btnUpdate.Enabled = true; this.btnSave.Enabled = false; if (this.dgvDrivewayList.SelectedRows.Count > 0)//选中行 { if (dgvDrivewayList.SelectedRows.Count > 1) { MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //修改的值 int ID = int.Parse(this.dgvDrivewayList.SelectedRows[0].Cells["Driveway_ID"].Value.ToString()); Expression <Func <View_DrivewayPosition, bool> > funviewinto = n => n.Driveway_ID == ID; foreach (var n in DrivewayDAL.Query(funviewinto)) { if (n.Driveway_Name != null) { //通道名称 this.txtDriveway_Name.Text = n.Driveway_Name; } if (n.Driveway_Value != null) { // 通道值 this.txtDriveway_Value.Text = n.Driveway_Value; } if (n.Driveway_State != null) { // 通道状态 this.cbxDriveway_State.Text = n.Driveway_State; } if (n.Driveway_Type != null) { // 通道类型 this.cbxDriveway_Type.Text = n.Driveway_Type; } if (n.Driveway_WarrantyState != null) { // 通道报修状态 this.comboxDriveway_WarrantyState.Text = n.Driveway_WarrantyState; bdwayState = n.Driveway_WarrantyState; } if (n.Driveway_Remark_Driveway_ID != null) { // 通道备用管理编号 this.cobReserve.SelectedValue = n.Driveway_Remark_Driveway_ID.ToString(); } if (n.Position_Name != null) { // 门岗名称 this.cbxDriveway_PositionName.Text = n.Position_Name; } //if (n.Driveway_UserId != null) //{ // // 通道创建人 // this.txtDriveway_UserId.Text = n.Driveway_UserId; //} //if (n.Driveway_CreatTime != null) //{ // // 通道创建时间 // this.txtDriveway_Remark.Text = n.Driveway_CreatTime.ToString(); //} if (n.Driveway_Address != null) { // 通道地址名称 this.cbodizhima.Text = n.Driveway_Address; } if (n.Driveway_ReadCardPort != null) { // 通道读卡器地址码 this.txtDriveway_ReadCardPort.Text = n.Driveway_ReadCardPort; } if (n.Driveway_CloseAddress != null) { cbmcloseAdd.Text = n.Driveway_CloseAddress; } if (n.Driveway_Remark != null) { // 通道备注 this.txtDriveway_Remark.Text = n.Driveway_Remark; } break; } } } else { MessageBox.Show("请选择要修改的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } boo = true; }
/// <summary> /// “修改” 按钮的单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { try { if (this.txtDriveway_Name.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "通道名称不能为空!", txtDriveway_Name, this); return; } if (this.txtDriveway_ReadCardPort.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "通道读卡器地址码不能为空!", txtDriveway_ReadCardPort, this); return; } if (this.dgvDrivewayList.SelectedRows.Count > 0)//选中行 { if (dgvDrivewayList.SelectedRows.Count > 1) { MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (!btnCheckupdate()) { return; // 去重复 } int driveway_id = int.Parse(this.dgvDrivewayList.SelectedRows[0].Cells["Driveway_ID"].Value.ToString()); Expression <Func <Driveway, bool> > p = n => n.Driveway_ID == driveway_id; string id = ""; string strfront = ""; string strContent = ""; Action <Driveway> ap = s => { strfront = s.Driveway_Name + "," + s.Driveway_Value + "," + s.Driveway_State + "," + s.Driveway_Type + "," + s.Driveway_WarrantyState + "," + s.Driveway_Remark_Driveway_ID + "," + s.Driveway_Position_ID + "," + s.Driveway_UserId + "," + s.Driveway_CreatTime + "," + s.Driveway_Add + "," + s.Driveway_ReadCardPort + "," + s.Driveway_Remark; s.Driveway_Name = this.txtDriveway_Name.Text.Trim(); s.Driveway_Value = this.txtDriveway_Value.Text.Trim(); s.Driveway_State = this.cbxDriveway_State.Text; s.Driveway_Type = this.cbxDriveway_Type.Text; s.Driveway_WarrantyState = this.comboxDriveway_WarrantyState.Text; if (cobReserve.SelectedIndex != 0 && cobReserve.SelectedIndex != -1) { s.Driveway_Remark_Driveway_ID = Convert.ToInt32(cobReserve.SelectedValue.ToString()); } s.Driveway_Position_ID = int.Parse(this.cbxDriveway_PositionName.SelectedValue.ToString()); s.Driveway_UserId = int.Parse(common.USERID); s.Driveway_CreatTime = Convert.ToDateTime(CommonalityEntity.GetServersTime().ToString()); s.Driveway_Address = this.cbodizhima.Text.Trim(); s.Driveway_ReadCardPort = this.txtDriveway_ReadCardPort.Text.Trim(); s.Driveway_Remark = this.txtDriveway_Remark.Text.Trim(); s.Driveway_CloseAddress = cbmcloseAdd.Text.Trim(); strContent = s.Driveway_Name + "," + s.Driveway_Value + "," + s.Driveway_State + "," + s.Driveway_Type + "," + s.Driveway_WarrantyState + "," + s.Driveway_Remark_Driveway_ID + "," + s.Driveway_Position_ID + "," + s.Driveway_UserId + "," + s.Driveway_CreatTime + "," + s.Driveway_Add + "," + s.Driveway_ReadCardPort + "," + s.Driveway_Remark; id = s.Driveway_ID.ToString(); }; if (DrivewayDAL.Update(p, ap)) { #region 当通道报修时启用备用通道,修改通行策略 //if (comboxDriveway_WarrantyState.Text == "报修") //{ // if (cobReserve.SelectedIndex > 0) // { // string drisid = ""; int bstate = 0; // if (bdwayState == "报修") // { // bstate = 1; // } // else // { // bstate = 0; // } // DataTable dtdris = LinQBaseDao.Query("select DrivewayStrategy_ID from DrivewayStrategy where DrivewayStrategy_Driveway_ID=" + id).Tables[0]; // if (dtdris.Rows.Count > 0) // { // # region 通道报修,记录要通行该通道的车辆通行策略,并修改ID关联 // for (int i = 0; i < dtdris.Rows.Count; i++) // { // drisid += dtdris.Rows[i][0].ToString() + ","; // } // drisid = drisid.TrimEnd(','); // DateTime dtime = CommonalityEntity.GetServersTime(); // LinQBaseDao.Query("insert into DrivewayRecord (DrivewayRecord_Driveway_ID,DrivewayRecord_Content,DrivewayRecord_State,DrivewayRecord_Time,DrivewayRecord_Person ) values(" + id + ",'" + drisid + "'," + bstate + ",'" + dtime + "','" + CommonalityEntity.USERNAME + "')"); // LinQBaseDao.Query("update DrivewayStrategy set DrivewayStrategy_Driveway_ID=" + cobReserve.SelectedValue.ToString() + " where DrivewayStrategy_ID in (" + drisid + ")"); // #endregion // } // else // { // #region 通道已是报修状态修改备用通道 // if (bstate == 1) // { // if (cobReserve.SelectedIndex > -1) // { // DataTable dtdrisrd = LinQBaseDao.Query("select DrivewayRecord_Content from DrivewayRecord where DrivewayRecord_Driveway_ID=" + id + " order by DrivewayRecord_ID desc").Tables[0]; // if (dtdrisrd.Rows.Count > 0) // { // string dcont = dtdrisrd.Rows[0][0].ToString(); // LinQBaseDao.Query("update DrivewayStrategy set DrivewayStrategy_Driveway_ID=" + cobReserve.SelectedValue.ToString() + " where DrivewayStrategy_ID in(" + dcont + ")"); // } // } // } // #endregion // } // } //} //else //{ // #region 通道由报修状态修改为正常状态 修改通行策略里的关联ID // if (bdwayState != "正常") // { // DataTable dtdris = LinQBaseDao.Query("select DrivewayRecord_Content from DrivewayRecord where DrivewayRecord_State=0 and DrivewayRecord_Driveway_ID=" + id + " order by DrivewayRecord_ID desc").Tables[0]; // if (dtdris.Rows.Count > 0) // { // string dcont = dtdris.Rows[0][0].ToString(); // LinQBaseDao.Query("update DrivewayStrategy set DrivewayStrategy_Driveway_ID=" + id + " where DrivewayStrategy_ID in(" + dcont + ")"); // } // } // #endregion //} #endregion MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); CommonalityEntity.WriteLogData("修改", "更新编号为:" + id + "的通道信息;修改前:" + strfront + ";修改后:" + strContent, common.USERNAME);//添加日志 } else { MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } catch { CommonalityEntity.WriteTextLog("通道管理 btnUpdate_Click()"); } finally { LogInfoLoad(""); this.btnUpdate.Enabled = false; this.btnSave.Enabled = true; } }
/// <summary> /// “保存” 按钮的单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { if (this.txtDriveway_Name.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "通道名称不能为空!", txtDriveway_Name, this); return; } if (this.txtDriveway_ReadCardPort.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "通道读卡器地址码不能为空!", txtDriveway_ReadCardPort, this); return; } //DataTable tables = LinQBaseDao.Query("select * from Driveway where Driveway_Value='" + txtDriveway_Value.Text.Trim() + "'").Tables[0]; //if (tables.Rows.Count > 0) //{ // PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "通道值重复!", txtDriveway_Name, this); // return; //} //DataTable table = LinQBaseDao.Query("select * from Driveway where Driveway_Name='" + txtDriveway_Name.Text.Trim() + "' and Driveway_Position_ID=" + cbxDriveway_PositionName.SelectedValue).Tables[0]; //if (table.Rows.Count > 0) //{ // PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "通道名称重复!", txtDriveway_Name, this); // return; //} if (!btnCheck()) { return; // 去重复 } var Drivewayadd = new Driveway(); Drivewayadd.Driveway_Name = this.txtDriveway_Name.Text.Trim(); Drivewayadd.Driveway_Value = this.txtDriveway_Value.Text.Trim(); Drivewayadd.Driveway_State = this.cbxDriveway_State.Text; Drivewayadd.Driveway_Type = this.cbxDriveway_Type.Text; Drivewayadd.Driveway_WarrantyState = this.comboxDriveway_WarrantyState.Text; if (cobReserve.SelectedIndex != 0 && cobReserve.SelectedIndex != -1) { Drivewayadd.Driveway_Remark_Driveway_ID = Convert.ToInt32((cobReserve.SelectedValue.ToString())); } Drivewayadd.Driveway_Position_ID = int.Parse(this.cbxDriveway_PositionName.SelectedValue.ToString()); Drivewayadd.Driveway_UserId = int.Parse(common.USERID); Drivewayadd.Driveway_CreatTime = Convert.ToDateTime(CommonalityEntity.GetServersTime().ToString()); Drivewayadd.Driveway_Address = this.cbodizhima.Text.Trim(); Drivewayadd.Driveway_ReadCardPort = this.txtDriveway_ReadCardPort.Text.Trim(); Drivewayadd.Driveway_Remark = this.txtDriveway_Remark.Text.Trim(); Drivewayadd.Driveway_CloseAddress = cbmcloseAdd.Text.Trim(); if (DrivewayDAL.InsertOneQCRecord(Drivewayadd)) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); string strContent1 = "通道名称为:" + this.cbxDriveway_PositionName.SelectedText + this.txtDriveway_Name.Text.Trim(); CommonalityEntity.WriteLogData("新增", "新增 " + strContent1 + " 的信息", common.USERNAME);//添加日志 //重新绑定通道值 tongdaoZ(); } else { MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { CommonalityEntity.WriteTextLog("通道管理 btnSave_Click()"); } finally { LogInfoLoad(""); } }
/// <summary> /// “修改” 按钮的单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { try { if (this.txtFVN_Name.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "地感名称不能为空!", txtFVN_Name, this); return; } if (this.txtFVN_Value.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "地感PLC值不能为空!", txtFVN_Value, this); return; } string PositionName = this.cbxPositionName.Text.ToString(); int lenth = cbxDrivewayName.Text.Trim().Length; string DrivewayName = cbxDrivewayName.Text.Trim(); string DrivewayType = cbxFVN_Type.Text.Trim(); int DrivewayID = 0; var p = DrivewayDAL.GetViewDrivewayName(String.Format("select Driveway_ID from View_DrivewayPosition where Position_Name='{0}' and Driveway_Name= '{1}'", PositionName, DrivewayName)); if (p != null) { foreach (var n in p) { if (n.Driveway_ID > 0) { DrivewayID = n.Driveway_ID; } break; } } if (this.dgvFVN.SelectedRows.Count > 0)//选中行 { if (dgvFVN.SelectedRows.Count > 1) { MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (!btnCheckupdate()) { return; // 去重复 } #region 修改 string id = ""; string strfront = ""; string strcontent = ""; Expression <Func <FVNInfo, bool> > pf = n => n.FVN_ID == int.Parse(this.dgvFVN.SelectedRows[0].Cells["FVN_ID"].Value.ToString()); Action <FVNInfo> ap = s => { strfront = s.FVN_Driveway_ID + "," + s.FVN_Value + "," + s.FVN_Name + "," + s.FVN_State + "," + s.FVN_Remark + "," + s.FVN_Type; s.FVN_Driveway_ID = DrivewayID; s.FVN_Value = int.Parse(this.txtFVN_Value.Text); s.FVN_Name = this.txtFVN_Name.Text.Trim(); s.FVN_State = this.cbxFVN_State.Text; s.FVN_Remark = this.txtFVN_Remark.Text.Trim(); s.FVN_Type = this.cbxFVN_Type.Text; strcontent = s.FVN_Driveway_ID + "," + s.FVN_Value + "," + s.FVN_Name + "," + s.FVN_State + "," + s.FVN_Remark + "," + s.FVN_Type; id = s.FVN_ID.ToString(); }; if (FVNDAL.Update(pf, ap)) { MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); CommonalityEntity.WriteLogData("修改", "更新编号为:" + id + "的地感信息;修改前:" + strfront + ";修改后:" + strcontent, CommonalityEntity.USERNAME);//添加日志 } else { MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } #endregion } } } catch { CommonalityEntity.WriteTextLog("地感管理 btnUpdate_Click()"); } finally { LogInfoLoad(""); this.btnUpdate.Enabled = false; this.btnSave.Enabled = true; } }
/// <summary> /// “保存” 按钮的单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { if (this.txtFVN_Name.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "地感名称不能为空!", txtFVN_Name, this); return; } if (this.txtFVN_Value.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "地感PLC值不能为空!", txtFVN_Value, this); return; } string PositionName = this.cbxPositionName.Text.ToString(); int lenth = cbxDrivewayName.Text.Trim().Length; string DrivewayName = cbxDrivewayName.Text.Trim().Substring(0, 4); string DrivewayType = cbxDrivewayName.Text.Trim().Substring(lenth - 1, 1); int DrivewayID = 0; var p = DrivewayDAL.GetViewDrivewayName(String.Format("select Driveway_ID from View_DrivewayPosition where Position_Name='{0}' and Driveway_Name= '{1}' and Driveway_Type= '{2}'", PositionName, DrivewayName, DrivewayType)); if (p != null) { foreach (var n in p) { if (n.Driveway_ID > 0) { DrivewayID = n.Driveway_ID; } break; } } if (!btnCheck()) { return; // 去重复 } var FVNadd = new FVNInfo { FVN_Driveway_ID = DrivewayID, FVN_Value = int.Parse(this.txtFVN_Value.Text), FVN_Name = this.txtFVN_Name.Text.Trim(), FVN_State = this.cbxFVN_State.Text, FVN_Remark = this.txtFVN_Remark.Text.Trim(), FVN_Type = this.cbxFVN_Type.Text }; if (FVNDAL.InsertOneQCRecord(FVNadd)) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); string strContent1 = "地感名称为:" + this.txtFVN_Name.Text.Trim(); CommonalityEntity.WriteLogData("新增", "新增 " + strContent1 + " 的信息", common.NAME);//添加日志 } else { MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { CommonalityEntity.WriteTextLog("地感管理 btnSave_Click()"); } finally { LogInfoLoad(""); } }