private void btn_Save_Click(object sender, EventArgs e)
        {
            #region 新增
            if (type == 0)//新增
            {
                if (string.IsNullOrEmpty(txtbox_Code.Text) || string.IsNullOrWhiteSpace(txtbox_Code.Text))
                {
                    MessageBox.Show("快捷插入模块编码不能为空!");
                    txtbox_Code.Focus();
                }
                else
                {
                    if (string.IsNullOrEmpty(txtbox_Name.Text) || string.IsNullOrWhiteSpace(txtbox_Name.Text))
                    {
                        MessageBox.Show("快捷插入模块名称不能为空!");
                        txtbox_Name.Focus();
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(txtbox_Value.Text) || string.IsNullOrWhiteSpace(txtbox_Value.Text))
                        {
                            MessageBox.Show("快捷插入模块值不能为空!");
                            txtbox_Value.Focus();
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(richtxtbox_Instruction.Text) || string.IsNullOrWhiteSpace(richtxtbox_Instruction.Text))
                            {
                                MessageBox.Show("快捷插入使用说明不能为空!");
                                richtxtbox_Instruction.Focus();
                            }
                            else
                            {
                                code        = txtbox_Code.Text.Trim();
                                name        = txtbox_Name.Text.Trim();
                                value       = txtbox_Value.Text.Trim();
                                instruction = richtxtbox_Instruction.Text.Trim();

                                string result = ConfigSettings.setQuickInsertModelCodeNameValue(code, name, value, instruction);

                                if (result == "新增成功")
                                {
                                    MessageBox.Show(code + result);
                                    this.Close();
                                }
                                else
                                {
                                    MessageBox.Show(result);
                                    txtbox_Code.Focus();
                                    txtbox_Code.SelectAll();
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            #region 非新增
            else
            {
                #region 编辑
                if (type == 1)//编辑
                {
                    if (string.IsNullOrEmpty(txtbox_Code.Text) || string.IsNullOrWhiteSpace(txtbox_Code.Text))
                    {
                        MessageBox.Show("快捷插入模块编码不能为空!");
                        txtbox_Code.Focus();
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(txtbox_Name.Text) || string.IsNullOrWhiteSpace(txtbox_Name.Text))
                        {
                            MessageBox.Show("快捷插入模块名称不能为空!");
                            txtbox_Name.Focus();
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(txtbox_Value.Text) || string.IsNullOrWhiteSpace(txtbox_Value.Text))
                            {
                                MessageBox.Show("快捷插入模块值不能为空!");
                                txtbox_Value.Focus();
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(richtxtbox_Instruction.Text) || string.IsNullOrWhiteSpace(richtxtbox_Instruction.Text))
                                {
                                    MessageBox.Show("快捷插入使用说明不能为空!");
                                    richtxtbox_Instruction.Focus();
                                }
                                else
                                {
                                    code        = txtbox_Code.Text.Trim();
                                    name        = txtbox_Name.Text.Trim();
                                    value       = txtbox_Value.Text.Trim();
                                    instruction = richtxtbox_Instruction.Text.Trim();

                                    string result = ConfigSettings.editQuickInsertModelCodeNameValue(code, name, value, instruction);

                                    if (result == "修改成功")
                                    {
                                        MessageBox.Show(code + result);
                                        this.Close();
                                    }
                                    else
                                    {
                                        MessageBox.Show(result);
                                        txtbox_Name.Focus();
                                        txtbox_Name.SelectAll();
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
                else
                {
                    MessageBox.Show("出错!");
                    this.Close();
                }
            }
            #endregion
        }
Пример #2
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            #region 新增
            if (type == 0)//新增
            {
                if (string.IsNullOrEmpty(txtbox_Code.Text) || string.IsNullOrWhiteSpace(txtbox_Code.Text))
                {
                    MessageBox.Show("常用SQL编码不能为空!");
                    txtbox_Code.Focus();
                }
                else
                {
                    if (string.IsNullOrEmpty(txtbox_Name.Text) || string.IsNullOrWhiteSpace(txtbox_Name.Text))
                    {
                        MessageBox.Show("常用SQL名称不能为空!");
                        txtbox_Name.Focus();
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(richtxtbox_Value.Text) || string.IsNullOrWhiteSpace(richtxtbox_Value.Text))
                        {
                            MessageBox.Show("常用SQL语句不能为空!");
                            richtxtbox_Value.Focus();
                        }
                        else
                        {
                            code  = txtbox_Code.Text.Trim();
                            name  = txtbox_Name.Text.Trim();
                            value = richtxtbox_Value.Text.Trim();

                            string result = ConfigSettings.setCommonlyUsedSQLCodeNameValue(code, name, value);

                            if (result == "新增成功")
                            {
                                MessageBox.Show(code + result);
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show(result);
                                txtbox_Code.Focus();
                                txtbox_Code.SelectAll();
                            }
                        }
                    }
                }
            }
            #endregion
            #region 非新增
            else
            {
                #region 编辑
                if (type == 1)//编辑
                {
                    if (string.IsNullOrEmpty(txtbox_Code.Text) || string.IsNullOrWhiteSpace(txtbox_Code.Text))
                    {
                        MessageBox.Show("常用SQL编码不能为空!");
                        txtbox_Code.Focus();
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(txtbox_Name.Text) || string.IsNullOrWhiteSpace(txtbox_Name.Text))
                        {
                            MessageBox.Show("常用SQL名称不能为空!");
                            txtbox_Name.Focus();
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(richtxtbox_Value.Text) || string.IsNullOrWhiteSpace(richtxtbox_Value.Text))
                            {
                                MessageBox.Show("常用SQL语句不能为空!");
                                richtxtbox_Value.Focus();
                            }
                            else
                            {
                                code  = txtbox_Code.Text.Trim();
                                name  = txtbox_Name.Text.Trim();
                                value = richtxtbox_Value.Text.Trim();

                                string result = ConfigSettings.editCommonlyUsedSQLCodeNameValue(code, name, value);

                                if (result == "修改成功")
                                {
                                    MessageBox.Show(code + result);
                                    this.Close();
                                }
                                else
                                {
                                    MessageBox.Show(result);
                                    txtbox_Name.Focus();
                                    txtbox_Name.SelectAll();
                                }
                            }
                        }
                    }
                }
                #endregion
                else
                {
                    MessageBox.Show("出错!");
                    this.Close();
                }
            }
            #endregion
        }