www.pudn.com > WorkflowDesigner.rar > FlowInfoDlg.cs, change:2007-11-27,size:7435b


using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
using WorkflowDesigner.Designer; 
namespace WorkflowDesigner 
{ 
    public partial class FlowInfoDlg : Form 
    { 
        //流程id如果流程id为-1表示为新增情况 
        private int flowid = -1; 
        private WfFlowDocument _flow; 
        public int Flowid 
        { 
          get { return flowid; } 
          set { flowid = value; } 
        } 
         
        public FlowInfoDlg(WfFlowDocument flow) 
        { 
            InitializeComponent(); 
            _flow = flow; 
            BindRoleInfo(); 
            LoadFlowInfo(); 
            if(this._flow.Role!=null) 
                this.comboBoxRole.SelectedValue = this._flow.Role.Name; 
        } 
 
 
        private void LoadFlowInfo() 
        { 
            //注意:需要判断入口 如果属于连接数据库得情况,那么有些控件就不能修改,有些控件能够修改 
            //SetContrl(); 
            this.textBoxName.Text = this._flow.Name; 
             
 
            if (this._flow.Workday != 0) 
            { 
                this.checkBoxIsWorkday.Checked = true; 
                this.textBoxMustTime.Enabled = true; 
                this.checkBoxIsWarningDay.Enabled = true; 
            } 
            if (this._flow.Warning_time != 0) 
            { 
                this.checkBoxIsWarningDay.Checked = true; 
                this.textBoxWarningTime.Enabled = true; 
            } 
            this.textBoxMustTime.Text = this._flow.Workday.ToString("0.00"); 
            this.textBoxWarningTime.Text = this._flow.Warning_time.ToString("0.00"); 
            //GetMartTemplet(); 
             
             
        } 
 
        private void BindRoleInfo() 
        { 
            IList<WfRole> Roles = Program.WorkflowControl.WfPackageDocument.RoleList; 
            this.comboBoxRole.DataSource = Roles; 
            this.comboBoxRole.DisplayMember = "Name"; 
            this.comboBoxRole.ValueMember = "Name"; 
        } 
 
        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; 
            } 
            if (this.checkBoxIsWorkday.Checked) 
            { 
                if (this.textBoxMustTime.Text.Trim() == "") 
                { 
                    MessageBox.Show("请填写流程时限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
                    this.textBoxMustTime.Focus(); 
                    return false; 
                } 
                else 
                { 
                    //判断输入的格式是否正确 
                    if (!CommFunction.IsWorkDay(this.textBoxMustTime.Text)) 
                    { 
                        MessageBox.Show("请填写正确流程所需时间格式[00000.00]!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
                        this.textBoxMustTime.Focus(); 
                        return false; 
                    } 
                    else if (Convert.ToDecimal(this.textBoxMustTime.Text.Trim()) == 0) 
                    { 
                        MessageBox.Show("请填写流程时限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
                        this.textBoxMustTime.Focus(); 
                        return false; 
                    } 
                } 
            } 
            if (this.checkBoxIsWarningDay.Checked) 
            { 
                if (this.textBoxWarningTime.Text.Trim() == "") 
                { 
                    MessageBox.Show("请填写流程预警时限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
                    this.textBoxWarningTime.Focus(); 
                    return false; 
                } 
                else 
                { 
                    //判断输入的格式是否正确 
                    if (!CommFunction.IsWorkDay(this.textBoxWarningTime.Text)) 
                    { 
                        MessageBox.Show("请填写正确流程预警时间格式[00000.00]!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
                        this.textBoxMustTime.Focus(); 
                        return false; 
                    } 
                    else if (Convert.ToDecimal(this.textBoxWarningTime.Text.Trim()) == 0) 
                    { 
                        MessageBox.Show("请填写流程预警时限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
                        this.textBoxWarningTime.Focus(); 
                        return false; 
                    } 
                } 
            } 
 
            if (this.comboBoxRole.Text == "") 
            { 
                MessageBox.Show("请选择创建角色!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
                this.comboBoxRole.Focus(); 
                return false; 
            } 
            return true; 
        } 
        private WfRole GetRoleInfoByRoleName(String RoleName) 
        { 
            foreach (WfRole vo in Program.WorkflowControl.WfPackageDocument.RoleList) 
            { 
                if (vo.Name == RoleName) 
                { 
                    return vo; 
                } 
            } 
            return null; 
        } 
        private void Save() 
        { 
             
            //保存填写的信息 
            try { 
                WfRole role = this.GetRoleInfoByRoleName(this.comboBoxRole.SelectedValue.ToString()); 
                Program.WorkflowControl.UpdateFlow(_flow, this.textBoxName.Text, Convert.ToDouble(this.textBoxMustTime.Text), Convert.ToDouble(this.textBoxWarningTime.Text), role); 
                MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); 
                this.Close(); 
            } 
            catch(Exception err) 
            { 
                MessageBox.Show(err.Message); 
            } 
 
 
 
        } 
 
        private void checkBoxIsWorkday_CheckedChanged(object sender, EventArgs e) 
        { 
            this.textBoxMustTime.Text = "0.00"; 
            this.checkBoxIsWorkday.Checked = this.checkBoxIsWorkday.Checked; 
            this.textBoxMustTime.Enabled = this.checkBoxIsWorkday.Checked; 
            this.checkBoxIsWarningDay.Enabled = this.checkBoxIsWorkday.Checked; 
            if (!this.checkBoxIsWorkday.Checked) 
            { 
                this.textBoxWarningTime.Text = "0.00"; 
                this.checkBoxIsWarningDay.Checked = false; 
                this.textBoxWarningTime.Enabled = false; 
            } 
             
 
        } 
 
        private void checkBoxIsWarningDay_CheckedChanged(object sender, EventArgs e) 
        { 
            this.textBoxWarningTime.Text = "0.00"; 
            this.checkBoxIsWarningDay.Checked = this.checkBoxIsWarningDay.Checked; 
            this.textBoxWarningTime.Enabled = this.checkBoxIsWarningDay.Checked; 
        } 
    } 
}