/// <summary> /// 查重方法 /// </summary> /// <returns></returns> private bool btnCheck() { bool rbool = true; try { //IC卡类型值 string ValueName = this.txtICCardType_Value.Text.Trim(); string ICType = this.txtICCardType_Name.Text.Trim(); //判断名称是否已存在 Expression <Func <ICCardType, bool> > funviewICCard = n => n.ICCardType_Name == ICType && n.ICCardType_Name != this.dgvICCardType.SelectedRows[0].Cells["ICCardType_Name"].Value.ToString(); if (ICCardTypeDAL.Query(funviewICCard).Count() > 0) { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "该IC卡类型名称已存在", txtICCardType_Name, this); txtICCardType_Name.Focus(); rbool = false;; } //判断名称是否已存在 Expression <Func <ICCardType, bool> > funviewICCard1 = n => n.ICCardType_Value == ValueName && n.ICCardType_Value != this.dgvICCardType.SelectedRows[0].Cells["ICCardType_Value"].Value.ToString(); if (ICCardTypeDAL.Query(funviewICCard1).Count() > 0) { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "该IC卡类型值已存在", txtICCardType_Value, this); txtICCardType_Value.Focus(); rbool = false;; } return(rbool); } catch { CommonalityEntity.WriteTextLog("IC卡类型信息 btnCheck()"); rbool = false; } return(rbool); }
/// <summary> /// 用户双击组件时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvICCardType_DoubleClick(object sender, EventArgs e) { this.btnUpdate.Enabled = true; this.btnSave.Enabled = false; if (this.dgvICCardType.SelectedRows.Count > 0)//选中行 { if (dgvICCardType.SelectedRows.Count > 1) { MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //修改的值 int ID = int.Parse(this.dgvICCardType.SelectedRows[0].Cells["ICCardType_ID"].Value.ToString()); Expression <Func <ICCardType, bool> > funviewinto = n => n.ICCardType_ID == ID; foreach (var n in ICCardTypeDAL.Query(funviewinto)) { if (n.ICCardType_Name != null) { //IC卡类型名称 this.txtICCardType_Name.Text = n.ICCardType_Name; } if (n.ICCardType_Value != null) { //IC卡类型值 this.txtICCardType_Value.Text = n.ICCardType_Value; } if (n.ICCardType_State != null) { // IC卡类型状态 this.comboxICCardType_State.Text = n.ICCardType_State; } if (n.ICCardType_Description != null) { // IC卡类型描述 this.txtICCardType_Description.Text = n.ICCardType_Description; } if (n.ICCardType_Remark != null) { // IC卡类型备注 this.txtICCardType_Remark.Text = n.ICCardType_Remark; } if (n.ICCardType_Permissions != null) { ICCardPermissions.Text = n.ICCardType_Permissions; } break; } } } else { MessageBox.Show("请选择要修改的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }