/// <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;
     }
 }