Ejemplo n.º 1
0
        public static FormObject GetFormModule(FormObject formObject, User user)
        {
            FormObject module = new FormObject();

            module.ID       = formObject.ID;
            module.FormName = formObject.FormName;
            module.FormType = formObject.FormType;
            if (user != null)
            {
                module.Owner = user;
            }
            else
            {
                module.Owner = formObject.Owner;
            }
            module.Remark    = formObject.Remark;
            module.FormItems = new List <FormItem>();
            foreach (FormItem item in formObject.FormItems)
            {
                FormItem fi = new FormItem();
                fi.ItemName  = item.ItemName;
                fi.ItemType  = item.ItemType;
                fi.ItemValue = "";
                fi.Flag      = item.Flag;
                int id = FormItemLogic.GetInstance().AddFormItem(fi);
                fi.ID = id;
                module.FormItems.Add(fi);
            }
            return(module);
        }
Ejemplo n.º 2
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         FormItem formItem = comboBox1.SelectedItem as FormItem;
         formEditControl1.Field = formItem;
     }
 }
Ejemplo n.º 3
0
        public FormEditControl()
        {
            InitializeComponent();
            Form owner = this.FindForm();
            int  count = Commons.GetControlMaxNumInForm <FormEditControl>(owner, "formEditControl");

            field = FormItem.Empty(FormItem.FieldNamePrex + Convert.ToString(count + 1));
        }
Ejemplo n.º 4
0
 public DocInfoControl()
 {
     InitializeComponent();
     ac      = new AttachmentControl();
     ac.Dock = DockStyle.Fill;
     ac.SendToBack();
     panel1.Controls.Add(ac);
     field = new FormItem();
 }
Ejemplo n.º 5
0
        void fec_AddItemHandler(object sender, EventArgs e)
        {
            FormEditControl thisItem = sender as FormEditControl;
            string          newName;
            int             index = items.GetIndex(thisItem.Field, out newName);

            if (index > -1)
            {
                items.Insert(index + 1, FormItem.Empty(newName));
                LoadItems();
            }
        }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            FormItem      formItem = formEditControl1.Field;
            FormItemLogic al       = FormItemLogic.GetInstance();
            int           id       = al.AddFormItem(formItem);

            if (id > 0)
            {
                formItem.ID = id;
                LoadFormItems();
                MessageBox.Show("添加成功!");
            }
        }
Ejemplo n.º 7
0
        public static int GetIndex(this List <FormItem> list, FormItem element)
        {
            int thisKey = element.GetHashCode();

            for (int i = 0; i < list.Count; i++)
            {
                int currKey = list[i].GetHashCode();
                if (thisKey == currKey)
                {
                    return(i);
                }
            }
            return(-1);
        }
Ejemplo n.º 8
0
        public int AddFormItem(FormItem element)
        {
            string sql = "insert into TF_FormItem (ItemName, ItemValue, ItemType, Flag) values ('" + element.ItemName + "', '" + element.ItemValue + "', '" + element.ItemType + "', " + element.Flag + "); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                return(R);
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 9
0
        public List <FormItem> GetFormItemsByIds(string items)
        {
            List <FormItem> elements = new List <FormItem>();

            if (!string.IsNullOrEmpty(items))
            {
                string[] ss = items.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (ss.Length > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (string s in ss)
                    {
                        string id = s.Trim();
                        int    ID;
                        if (int.TryParse(id, out ID))
                        {
                            if (sb.Length == 0)
                            {
                                sb.Append(id);
                            }
                            else
                            {
                                sb.Append("," + id);
                            }
                        }
                    }
                    if (sb.Length > 0)
                    {
                        string    sql = "select * from TF_FormItem where ID in (" + sb.ToString() + ")";
                        DataTable dt  = sqlHelper.Query(sql);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                FormItem element = new FormItem();
                                element.ID        = Convert.ToInt32(dt.Rows[i]["ID"]);
                                element.ItemName  = dt.Rows[i]["ItemName"].ToString();
                                element.ItemValue = dt.Rows[i]["ItemValue"].ToString();
                                element.ItemType  = dt.Rows[i]["ItemType"].ToString();
                                element.Flag      = Convert.ToInt32(dt.Rows[i]["Flag"]);
                                elements.Add(element);
                            }
                        }
                    }
                }
            }
            return(elements);
        }
Ejemplo n.º 10
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         FormItem      formItem = formEditControl1.Field;
         FormItemLogic al       = FormItemLogic.GetInstance();
         if (al.UpdateFormItem(formItem))
         {
             LoadFormItems();
             MessageBox.Show("修改成功!");
         }
     }
     else
     {
         MessageBox.Show("先选定要修改的表单字段!");
     }
 }
Ejemplo n.º 11
0
        public FormItem GetFormItem(int id)
        {
            string    sql = "select * from TF_FormItem where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                FormItem element = new FormItem();
                element.ID        = id;
                element.ItemName  = dt.Rows[0]["ItemName"].ToString();
                element.ItemValue = dt.Rows[0]["ItemValue"].ToString();
                element.ItemType  = dt.Rows[0]["ItemType"].ToString();
                element.Flag      = Convert.ToInt32(dt.Rows[0]["Flag"]);
                return(element);
            }
            return(null);
        }
Ejemplo n.º 12
0
        private DocObject GetDocObject()
        {
            string name = textBox1.Text.Trim();

            if (name == "")
            {
                name = "未命名文档";
            }

            DocObject document = new DocObject();

            document.ID     = (doc == null ? 0 : doc.ID);
            document.Name   = name;
            document.Form   = form;
            document.Owner  = this.User;//文档的作者自动更新为最后修改文档的用户
            document.Remark = textBox2.Text;
            FormItemLogic fil = FormItemLogic.GetInstance();

            foreach (Control c in panel2.Controls)
            {
                if (c is DocEditControl)
                {
                    DocEditControl dec  = c as DocEditControl;
                    FormItem       item = dec.Field;
                    int            id   = 0;
                    if (doc != null)
                    {
                        id = fil.SaveFormItem(item);
                    }
                    else
                    {
                        id = fil.AddFormItem(item);
                    }
                    if (id > 0)
                    {
                        item.ID = id;
                        document.DocItems.Add(item);
                    }
                }
            }
            doc = document;
            return(document);
        }
Ejemplo n.º 13
0
 private void LoadItems(List <FormItem> items)
 {
     if (items != null)
     {
         panel2.SuspendLayout();
         panel2.Controls.Clear();
         for (int i = 0; i < items.Count; i++)
         {
             FormItem       item = items[i];
             DocInfoControl dic  = new DocInfoControl();
             dic.Field    = item;
             dic.Location = new Point(width, height + (height + dic.Height) * i);
             dic.Width    = panel2.Width - width * 2;
             dic.Anchor   = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
             panel2.Controls.Add(dic);
         }
         panel2.ResumeLayout(true);
     }
 }
Ejemplo n.º 14
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         if (MessageBox.Show("确定要删除该表单字段?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
         {
             FormItem formItem = new FormItem();
             formItem.ID = ((FormItem)comboBox1.SelectedItem).ID;
             if (FormItemLogic.GetInstance().DeleteFormItem(formItem))
             {
                 LoadFormItems();
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要删除的表单字段!");
     }
 }
Ejemplo n.º 15
0
        public List <FormItem> GetAllFormItems()
        {
            List <FormItem> elements = new List <FormItem>();
            string          sql      = "select * from TF_FormItem";
            DataTable       dt       = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    FormItem element = new FormItem();
                    element.ID        = Convert.ToInt32(dt.Rows[i]["ID"]);
                    element.ItemName  = dt.Rows[i]["ItemName"].ToString();
                    element.ItemValue = dt.Rows[i]["ItemValue"].ToString();
                    element.ItemType  = dt.Rows[i]["ItemType"].ToString();
                    element.Flag      = Convert.ToInt32(dt.Rows[i]["Flag"]);
                    elements.Add(element);
                }
            }
            return(elements);
        }
Ejemplo n.º 16
0
 public DocEditControl()
 {
     InitializeComponent();
     tb                      = new TextBox();
     tb.ForeColor            = Color.Blue;
     tb.AcceptsReturn        = true;
     tb.AcceptsTab           = true;
     tb.Dock                 = DockStyle.Fill;
     nud                     = new NumericUpDown();
     nud.ForeColor           = Color.Blue;
     nud.DecimalPlaces       = 2;
     nud.Maximum             = 1000000000;
     nud.Minimum             = -999999999;
     nud.Dock                = DockStyle.Fill;
     dtp                     = new DateTimePicker();
     dtp.ForeColor           = Color.Blue;
     dtp.CustomFormat        = "yyyy-MM-dd HH:mm:ss";
     dtp.Format              = DateTimePickerFormat.Custom;
     dtp.Dock                = DockStyle.Fill;
     uc                      = new UploadControl();
     uc.Dock                 = DockStyle.Fill;
     comboBox1.SelectedIndex = 0;
     field                   = new FormItem();
 }
Ejemplo n.º 17
0
 private void LoadItems()
 {
     if (items != null)
     {
         panel2.SuspendLayout();
         panel2.Controls.Clear();
         for (int i = 0; i < items.Count; i++)
         {
             FormItem        item = items[i];
             FormEditControl fec  = new FormEditControl();
             fec.Field                  = item;
             fec.Location               = new Point(width, height + (height + fec.Height) * i);
             fec.AddItemHandler        += new EventHandler(fec_AddItemHandler);
             fec.RemoveItemHandler     += new EventHandler(fec_RemoveItemHandler);
             fec.ChangeItemNameHandler += new FieldNameChangedHandler(fec_ItemNameChangedHandler);
             if (items.Count == 1)
             {
                 fec.CanRemove = false;//最后一个必须留着,免得无法再添加
             }
             panel2.Controls.Add(fec);
         }
         panel2.ResumeLayout(true);
     }
 }
Ejemplo n.º 18
0
        private void LoadItems(List <FormItem> items)
        {
            if (items != null)
            {
                panel2.SuspendLayout();
                panel2.Controls.Clear();
                for (int i = 0; i < items.Count; i++)
                {
                    FormItem item = items[i];
                    if (doc == null)
                    {
                        SystemType type = Commons.GetSystemType(item.ItemType);
                        switch (type)
                        {
                        case SystemType.附件:
                            break;

                        case SystemType.时间:
                            item.ItemValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            break;

                        case SystemType.数字:
                            item.ItemValue = "0.00";
                            break;

                        case SystemType.字符:
                            item.ItemValue = string.Empty;
                            break;

                        default:
                            break;
                        }
                    }
                    DocEditControl dec = new DocEditControl();
                    dec.Field             = item;
                    dec.Location          = new Point(width, height + (height + dec.Height) * i);
                    dec.Width             = panel2.Width - width * 2;
                    dec.Anchor            = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                    dec.comboBox1.Enabled = (doc == null);
                    if (!dec.comboBox1.Enabled)
                    {//已经存在的文档,限制编辑
                        bool canEdit = false;
                        bool isAppr;
                        int  level;
                        dec.GetExecAppr(out isAppr, out level);
                        TaskInfo task = TaskInfoLogic.GetInstance().GetTaskInfoByEntityId(doc.ID);
                        if (task != null)
                        {
                            TaskStageTemplate stageTemp     = task.Flow.Template.Stages[task.Flow.CurrentIndex];
                            TaskStatus        currentStatus = task.Flow.Current.Status;
                            if (level == 0)
                            {
                                if (task.Sponsor == this.User.Username && currentStatus == TaskStatus.Initiative)
                                {
                                    canEdit = true;//只有未被接收(即初始化状态)的文档允许文档发起者修改普通字段
                                }
                            }
                            else//level>0是执行字段和审批字段...
                            {
                                if (isAppr)//审批
                                {
                                    if (stageTemp.Approvers.Contains(this.User.ID.ToString()) && currentStatus == TaskStatus.Processed)
                                    {
                                        canEdit = true;
                                    }
                                }
                                else//执行
                                {
                                    if (stageTemp.Executors.Contains(this.User.ID.ToString()) && currentStatus == TaskStatus.Processing)
                                    {
                                        canEdit = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            canEdit = true;//没启动流程之前的文档可以修改任何字段
                        }
                        dec.CanEdit = canEdit;
                    }
                    panel2.Controls.Add(dec);
                }
                panel2.ResumeLayout(true);
            }
        }