コード例 #1
0
        /// <summary>
        /// “修改” 查看数据按钮的单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.txtCustomerInfo_Name.Text == "")
                {
                    PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "公司名称不能为空!", txtCustomerInfo_Name, this);
                    return;
                }

                if (this.dgvCustomerInfo.SelectedRows.Count > 0)//选中行
                {
                    if (dgvCustomerInfo.SelectedRows.Count > 1)
                    {
                        MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (!btnCheck())
                        {
                            return;              // 去重复
                        }
                        #region 2012-04-23  选中行修改数据
                        Expression <Func <CustomerInfo, bool> > p = n => n.CustomerInfo_ID == int.Parse(this.dgvCustomerInfo.SelectedRows[0].Cells["CustomerInfo_ID"].Value.ToString());
                        string strfront          = "";
                        string strContent        = "";
                        Action <CustomerInfo> ap = s =>
                        {
                            strfront               = s.CustomerInfo_Name + "," + s.CustomerInfo_State + "," + s.CustomerInfo_Type + "," + s.CustomerInfo_Email + "," + s.CustomerInfo_Contact + "," + s.CustomerInfo_ADD + "," + s.CustomerInfo_Remark;
                            s.CustomerInfo_Name    = this.txtCustomerInfo_Name.Text.Trim();
                            s.CustomerInfo_State   = this.comboxCustomerInfo_State.Text.Trim();
                            s.CustomerInfo_Type    = this.txtCustomerInfo_Type.Text.Trim();
                            s.CustomerInfo_Email   = this.txtCustomerInfo_Email.Text.Trim();
                            s.CustomerInfo_Contact = this.txtCustomerInfo_Contact.Text.Trim();
                            s.CustomerInfo_ADD     = this.txtCustomerInfo_ADD.Text.Trim();
                            s.CustomerInfo_Remark  = this.txtCustomerInfo_Remark.Text.Trim();
                            strContent             = s.CustomerInfo_Name + "," + s.CustomerInfo_State + "," + s.CustomerInfo_Type + "," + s.CustomerInfo_Email + "," + s.CustomerInfo_Contact + "," + s.CustomerInfo_ADD + "," + s.CustomerInfo_Remark;
                        };

                        if (CustomerInfoDAL.Update(p, ap))
                        {
                            MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            CommonalityEntity.WriteLogData("修改", "更新公司信息;修改前:" + strfront + ";修改后:" + strContent, CommonalityEntity.USERNAME);//添加日志

                            Empty();
                        }
                        else
                        {
                            MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        #endregion
                    }
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("公司信息管理 btnUpdate_Click()");
            }
            finally
            {
                LogInfoLoad("");
                this.btnUpdate.Enabled = false;
                this.btnSave.Enabled   = true;
            }
        }
コード例 #2
0
 public static int Update(CustomerInfo model)
 {
     return(CustomerInfoDAL.Update(model));
 }