/// <summary> /// 添加项目类型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddProjectType_Click(object sender, EventArgs e) { #region 数据验证 if (txtTypeName.Text.Trim().Length == 0) { MessageBox.Show("请输入项目类型名称", "验证信息"); txtTypeName.Focus(); return; } #endregion //封装对象 ProjectType objProjectType = new ProjectType() { TypeName = txtTypeName.Text.Trim(), KMLink = txtKMLink.Text.Trim() }; //提交添加 try { int typeId = objProjectTypeService.AddProjectType(objProjectType); if (typeId > 1) { //提示添加成功 MessageBox.Show("项目类型添加成功", "提示信息"); //刷新显示 dgvProjectTypes.DataSource = objProjectTypeService.GetAllProjectTypes(); //清空内容 txtTypeName.Text = ""; txtKMLink.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }