www.pudn.com > WorkflowDesigner.rar > AppInfoDlg.cs, change:2007-11-20,size:4918b


using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
using Bussiness; 
 
namespace WorkflowDesigner 
{ 
    public partial class AppInfoDlg : Form 
    { 
        public AppInfoDlg(WfApplication app) 
        { 
         
             
 
 
            _isNewAppOperation = false; 
            this._app = app; 
            InitializeComponent(); 
            if (_app == null) 
            { 
                _isNewAppOperation = true; 
            } 
            else 
            { 
                //赋值 
                 
 
 
 
 
            } 
        } 
        private bool _isNewAppOperation; 
 
        private WfApplication _app; 
 
        public WfApplication App 
        { 
            get { return _app; } 
            set { _app = value; } 
        } 
 
        private void AppInfoDlg_Load(object sender, EventArgs e) 
        { 
            //填充类型 
            BindAppTypeInfo(); 
            //填充组信息 
            BindGroupInfo(); 
            if (!this._isNewAppOperation) 
            { 
                this.textBoxName.Text = this._app.Name; 
                this.comboBoxGroup.SelectedValue = this._app.Group; 
                this.comboBoxType.SelectedValue = this._app.Type; 
                this.textBoxPath.Text = this._app.Path; 
                this.textBoxParam.Text = this._app.Param; 
                //this.textBoxRank.Text = this._app.Rank.ToString(); 
            } 
            else 
            {  
                //得到最大应用数 
                //自增 
 
            
           //int count = Program.WorkflowControl.GetApplicationCount(); 
           //     count++; 
           //     this.textBoxRank.Text = count.ToString(); 
                 
 
 
 
            } 
        } 
 
        private void BindAppTypeInfo() 
        {  
            //构建DataTable 
            DataTable dt = new DataTable(); 
            dt.Columns.Add("ID", typeof(int)); 
            dt.Columns.Add("Name", typeof(String)); 
             
            DataRow dr = dt.NewRow(); 
            dr["ID"] = "0"; 
            dr["Name"] = "表单"; 
            dt.Rows.Add(dr); 
 
            dr = dt.NewRow(); 
            dr["ID"] = "1"; 
            dr["Name"] = "报表"; 
            dt.Rows.Add(dr); 
 
            dr = dt.NewRow(); 
            dr["ID"] = "2"; 
            dr["Name"] = "URL"; 
            dt.Rows.Add(dr); 
 
 
            this.comboBoxType.DataSource = dt; 
            this.comboBoxType.DisplayMember = "Name"; 
            this.comboBoxType.ValueMember = "ID"; 
 
        } 
 
        private void BindGroupInfo() 
        {  
            DO_AppInfo oper = new DO_AppInfo(); 
            DataSet ds = oper.GetAllGroupInfo(); 
            this.comboBoxGroup.DataSource = ds.Tables[0]; 
            this.comboBoxGroup.DisplayMember = "Name"; 
            this.comboBoxGroup.ValueMember = "ID"; 
 
        } 
 
        private void buttonCancel_Click(object sender, EventArgs e) 
        { 
            //关闭窗体 
            this.Close(); 
        } 
 
        private void buttonOk_Click(object sender, EventArgs e) 
        { 
            if (this.IsVaild()) 
            { 
                this.Save(); 
            } 
        } 
 
 
        private bool IsVaild() 
        { 
            //名称为必填 
            if (this.textBoxName.Text.Trim() == "") 
            { 
                MessageBox.Show("请填写应用名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
                this.textBoxName.Focus(); 
                return false; 
            } 
            return true; 
        } 
 
        private void Save() 
        { 
            try 
            { 
                //保存信息 
                String roleName = this.textBoxName.Text.Trim(); 
                String type = this.comboBoxType.SelectedValue.ToString(); 
                String gourp = this.comboBoxGroup.SelectedValue.ToString(); 
                String path = this.textBoxPath.Text; 
                String param = this.textBoxParam.Text; 
               // int rank = 0; 
                //if (this.textBoxRank.Text!="") 
                //    rank = Convert.ToInt32(this.textBoxRank.Text); 
                 
                if (this._isNewAppOperation) 
                { 
                    Program.WorkflowControl.NewApplication(roleName, type, gourp, path, param); 
                } 
                else 
                { 
                    Program.WorkflowControl.UpdateApplication(this._app, roleName, type, gourp, path, param); 
                } 
 
                MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); 
                this.Close(); 
            } 
            catch (Exception err) 
            { 
                MessageBox.Show(err.Message); 
            } 
 
        } 
    } 
}