Exemplo n.º 1
0
        //添加检测技术
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            DETECTION_TECHNOLOGYInDao dao = new DETECTION_TECHNOLOGYInDao();
            string name = textEdit4.Text.Trim();

            //控制参数格式
            if (name == "")
            {
                MessageBox.Show("信息不能为空!");
                return;
            }
            string sql1 = "select * from DETECTION_TECHNOLOGY where Detection_Technology_NAME = '" + name + "'";

            if (common.SqlHelper.ExcuteSql(sql1) > 0)
            {
                MessageBox.Show("该检测技术已被添加过!", "信息提示", MessageBoxButtons.OK);
                return;
            }
            dao.Save(this.textEdit4.Text.Trim());
            FreshForm();
        }
        //保存检测技术信息
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            DETECTION_TECHNOLOGYInDao dao = new DETECTION_TECHNOLOGYInDao();
            string name = Detection_Technology_NAME.Text.Trim();

            //控制参数格式
            if (name == "")
            {
                MessageBox.Show("信息不能为空!");
                return;
            }
            switch (strOperationFlag)
            {
            case "add":
                string sql1 = "select * from DETECTION_TECHNOLOGY where Detection_Technology_NAME = '" + name + "'";
                if (common.SqlHelper.ExcuteSql(sql1) > 0)
                {
                    MessageBox.Show("该检测技术已被添加过!", "信息提示", MessageBoxButtons.OK);
                    return;
                }
                dao.Save(this.Detection_Technology_NAME.Text.Trim());
                this.DialogResult = DialogResult.OK;
                this.Close();
                break;

            case "modify":
                string sql2 = "select count(*) from DETECTION_TECHNOLOGY where Detection_Technology_NAME = '" + name + "' and DetectionTechnology_ID <> '" + DetectionTechnology_ID + "'";
                if (common.SqlHelper.ExcuteSql(sql2) > 0)
                {
                    MessageBox.Show("该检测技术已被添加过!", "信息提示", MessageBoxButtons.OK);
                    this.Detection_Technology_NAME.Focus();
                    return;
                }
                dao.Modify(DetectionTechnology_ID, this.Detection_Technology_NAME.Text.Trim());
                this.DialogResult = DialogResult.OK;
                this.Close();
                break;
            }
        }