/// <summary> /// 查重方法 /// </summary> /// <returns></returns> private bool btnCheck() { bool rbool = true; try { //定义字段用以保存门岗名称和门岗值 string PositionName = this.txtPosition_Name.Text.Trim(); string PositionValue = this.txtPosition_Value.Text.Trim(); //判断名称是否已存在 Expression <Func <Position, bool> > funviewPosition = n => n.Position_Name == PositionName && n.Position_Name != this.dgvPositionList.SelectedRows[0].Cells["Position_Name"].Value.ToString(); if (PositionDAL.Query(funviewPosition).Count() > 0) { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "该门岗名称已存在", txtPosition_Name, this); txtPosition_Name.Focus(); rbool = false;; } Expression <Func <Position, bool> > funviewPosition1 = n => n.Position_Value == PositionValue && n.Position_Value != this.dgvPositionList.SelectedRows[0].Cells["Position_Value"].Value.ToString(); if (PositionDAL.Query(funviewPosition1).Count() > 0) { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "该门岗值已存在", txtPosition_Value, this); txtPosition_Value.Focus(); rbool = false;; } return(rbool); } catch { CommonalityEntity.WriteTextLog("门岗管理 btnCheck()"); rbool = false; } return(rbool); }
/// <summary> /// 加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DrivewayFrom_Load(object sender, EventArgs e) { try { userContext(); cbodizhima.SelectedIndex = 0; cbmcloseAdd.SelectedIndex = 1; btnUpdate.Enabled = false; btnSelect_Click(btnSelect, null); mf = new MainForm(); tscbxPageSize.SelectedIndex = 1; // LoadData(); BindDriveway(); BindSearchDriveway(); BindPositionName(); BindSearchWarrantState(); // 绑定搜索的通道报修状态 BindPositionType(); BindDrivewayWarrantState(); BindRemarkDriveway(); Bindmengang(); if (iDrivewayPositionID > 0) { // 若门岗管理界面中有选择“门岗”再跳转的,则显示门岗如下 Expression <Func <Position, bool> > funviewinto = n => n.Position_ID == iDrivewayPositionID; foreach (var n in PositionDAL.Query(funviewinto)) { if (n.Position_Name != null) { //门岗名称 this.cbxDriveway_PositionName.Text = n.Position_Name; } } } } catch { MessageBox.Show("加载通道信息有误,请查看与通道相关的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
/// <summary> /// 用户双击组件时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPositionList_DoubleClick(object sender, EventArgs e) { this.btnUpdate.Enabled = true; this.btnSave.Enabled = false; if (this.dgvPositionList.SelectedRows.Count > 0)//选中行 { if (dgvPositionList.SelectedRows.Count > 1) { MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //修改的值 int ID = int.Parse(this.dgvPositionList.SelectedRows[0].Cells["Position_ID"].Value.ToString()); Expression <Func <Position, bool> > funviewinto = n => n.Position_ID == ID; foreach (var n in PositionDAL.Query(funviewinto)) { if (n.Position_Name != null) { //门岗名称 this.txtPosition_Name.Text = n.Position_Name; } if (n.Position_Value != null) { // 门岗值 this.txtPosition_Value.Text = n.Position_Value; } //if (n.UserInfo.UserName != null) //{ // // 门岗创建人 // this.txtPositionUserID.Text = n.UserInfo.UserName; //} if (n.Position_State != null) { // 门岗状态 this.cbxPosition_State.Text = n.Position_State; } if (n.Position_Add != null) { // 门岗地址 this.txtPosition_ADD.Text = n.Position_Add; } if (n.Position_Phone != null) { // 门岗电话 this.txtPosition_Phone.Text = n.Position_Phone; } if (n.Position_CameraValue != null) { // 登记拍照摄像头 this.txtPosition_CameraValue.Text = n.Position_CameraValue; } if (n.Position_Remark != null) { // 门岗备注 this.txtPosition_Remark.Text = n.Position_Remark; } break; } } } else { MessageBox.Show("请选择要修改的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }