Esempio n. 1
0
 /// <summary>
 /// 特殊技术要求添加/修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSpecialRequirement_Click(object sender, EventArgs e)
 {
     //数据验证
     if (txtContant.Text.Trim().Length == 0)
     {
         MessageBox.Show("请填写特殊技术要求后操作", "验证信息");
         txtContant.Focus();
         return;
     }
     //判断添加/修改
     if (txtSpecialRequirementId.Text.Trim().Length == 0)
     {
         //提交添加
         //封装对象
         SpecialRequirement objSpecialRequirement = new SpecialRequirement()
         {
             ProjectId = Convert.ToInt32(txtProjectId.Text.Trim()),
             Content   = txtContant.Text
         };
         //提交添加
         try
         {
             int specialRequirementId = objRequirementService.AddSpecialRequirement(objSpecialRequirement);
             if (specialRequirementId > 1)
             {
                 //提示添加成功
                 MessageBox.Show("特殊技术要求添加成功", "提示信息");
                 //刷新显示
                 txtContant.Text = "";
                 txtSpecialRequirementId.Text      = "";
                 dgvSpecialRequirements.DataSource = objRequirementService.GetSpecialRequirementsByODPNo(txtODPNo.Text.Trim());
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         //封装对象
         SpecialRequirement objSpecialRequirement = new SpecialRequirement()
         {
             SpecialRequirementId = Convert.ToInt32(txtSpecialRequirementId.Text.Trim()),
             ProjectId            = Convert.ToInt32(txtProjectId.Text.Trim()),
             Content = txtContant.Text
         };
         //提交修改
         //调用后台方法修改对象
         try
         {
             if (objRequirementService.EditSpecialRequirement(objSpecialRequirement) == 1)
             {
                 MessageBox.Show("修改特殊技术要求成功!", "提示信息");
                 txtContant.Text = "";
                 txtSpecialRequirementId.Text      = "";
                 dgvSpecialRequirements.DataSource = objRequirementService.GetSpecialRequirementsByODPNo(txtODPNo.Text.Trim());
                 btnSpecialRequirement.Text        = "添加特殊技术要求";
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }