/// <summary> /// 双击组件时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvBusinessType_DoubleClick(object sender, EventArgs e) { this.btnUpdate.Enabled = true; this.btnSave.Enabled = false; if (this.dgvBusinessType.SelectedRows.Count > 0)//选中行 { if (dgvBusinessType.SelectedRows.Count > 1) { MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //修改的值 int ID = int.Parse(this.dgvBusinessType.SelectedRows[0].Cells["BusinessType_ID"].Value.ToString()); Expression <Func <BusinessType, bool> > funviewinto = n => n.BusinessType_ID == ID; foreach (var n in BusinessTypeDAL.QueryView(funviewinto)) { if (n.BusinessType_Name != null) { // 业务类别名称 this.txtBusinessType_Name.Text = n.BusinessType_Name; } if (n.BusinessType_CarType_ID != null && n.BusinessType_CarType_ID > 0) { cmbCarType.Text = LinQBaseDao.GetSingle("select CarType_Name from CarType where CarType_ID=" + n.BusinessType_CarType_ID).ToString(); } if (n.BusinessType_State != null) { // 业务类别状态 this.cbxBusinessType_State.Text = n.BusinessType_State; } if (n.BusinessType_Loaded != null) { //装货类型 this.cbxBusinessType_Loaded.Text = n.BusinessType_Loaded; } if (n.BusinessType_Use != null) { //业务类别用途 this.txtBusinessType_Use.Text = n.BusinessType_Use; } if (n.BusinessType_Content != null) { // 业务类别描述 this.txtBusinessType_Content.Text = n.BusinessType_Content; } if (n.BusinessType_Remark != null) { // 业务类别备注 this.txtBusinessType_Remark.Text = n.BusinessType_Remark; } break; } } } else { MessageBox.Show("请选择要修改的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 查重方法 /// </summary> /// <returns></returns> private bool btnCheckupdate() { bool rbool = true; try { string BusinessType_Name = this.txtBusinessType_Name.Text.ToString(); //判断名称是否已存在 Expression <Func <BusinessType, bool> > funviewFVNInfo = n => n.BusinessType_Name == BusinessType_Name && n.BusinessType_Name != this.dgvBusinessType.SelectedRows[0].Cells["BusinessType_Name"].Value.ToString(); if (BusinessTypeDAL.QueryView(funviewFVNInfo).Count() > 0) { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "该业务类型名称已存在", txtBusinessType_Name, this); this.txtBusinessType_Name.Focus(); rbool = false;; } return(rbool); } catch { CommonalityEntity.WriteTextLog("地感管理 btnCheck()"); rbool = false; } return(rbool); }