Beispiel #1
0
        //点击确定按钮
        private void btnSure_Click(object sender, EventArgs e)
        {
            //添加项目
            if (this.Text == TITLE_ADD_PRO)
            {
                ProjectBll proBll = new ProjectBll();
                Project    pro    = new Project();

                if (!Tool.isNull(txtName.Text) && !Tool.isNull(txtPLId.Text) && !Tool.isNull(txtPMId.Text))
                {
                    if (txtPLId.Tag == null) //|| txtPMId.Tag == null)
                    {
                        MessageBox.Show(SHOW_INPUT_TIPS_MESSAGE);
                        txtPLId.Focus();
                        return;
                    }
                    if (txtPMId.Tag == null)
                    {
                        MessageBox.Show(SHOW_INPUT_TIPS_MESSAGE);
                        txtPMId.Focus();
                        return;
                    }
                    pro.PName  = txtName.Text.Trim();
                    pro.PLId   = txtPLId.Tag.ToString().ToUpper();
                    pro.PMId   = txtPMId.Tag.ToString().ToUpper();
                    pro.Status = cmboxStatus.SelectedIndex == 1 ? "未激活" : "已激活";
                    bool a = proBll.IsNameExist(pro.PName);
                    if (a)
                    {
                        lblNameShow.Text = LBLSHOW_PRONAME_IS_EXIST;
                        return;
                    }
                    bool b = proBll.ProAdd(pro);
                    if (b)
                    {
                        MessageBox.Show(SHOW_ADD_SUCESS);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show(SHOW_PLEASE_CHECK);
                    if (txtName.Text == string.Empty)
                    {
                        txtName.Focus();
                        return;
                    }
                    if (txtPLId.Text == string.Empty)
                    {
                        txtPLId.Focus();
                        return;
                    }
                    if (txtPMId.Text == string.Empty)
                    {
                        txtPMId.Focus();
                        return;
                    }
                }
            }

            //更新项目
            else
            {
                ProjectBll proBll = new ProjectBll();
                Project    pro    = new Project();


                if (!Tool.isNull(txtName.Text) && !Tool.isNull(txtPLId.Text) && !Tool.isNull(txtPMId.Text))
                {
                    if (txtPLId.Tag == null)//|| txtPMId.Tag == null)
                    {
                        MessageBox.Show(SHOW_INPUT_TIPS_MESSAGE);
                        txtPLId.Focus();
                        return;
                    }
                    if (txtPMId.Tag == null)
                    {
                        MessageBox.Show(SHOW_INPUT_TIPS_MESSAGE);
                        txtPMId.Focus();
                        return;
                    }
                    pro.PName  = txtName.Text.Trim();
                    pro.PLId   = txtPLId.Tag.ToString().ToUpper();
                    pro.PMId   = txtPMId.Tag.ToString().ToUpper();
                    pro.Status = cmboxStatus.SelectedIndex == 1 ? "未激活" : "已激活";


                    bool b = proBll.UpdatePro(pro);
                    if (b)
                    {
                        MessageBox.Show(SHOW_UPDATE_SUCESS);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show(SHOW_PLEASE_CHECK);
                    if (txtName.Text == string.Empty)
                    {
                        txtName.Focus();
                        return;
                    }
                    if (txtPLId.Text == string.Empty)
                    {
                        txtPLId.Focus();
                        return;
                    }
                    if (txtPMId.Text == string.Empty)
                    {
                        txtPMId.Focus();
                        return;
                    }
                }
            }
        }