示例#1
0
        public List <FormObject> GetFormObjectsByUser(User user)
        {
            List <FormObject> elements = new List <FormObject>();
            string            sql      = "select * from TF_FormObject where Owner=" + user.ID;
            DataTable         dt       = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                FormTypeLogic ftl = FormTypeLogic.GetInstance();
                FormItemLogic fil = FormItemLogic.GetInstance();
                UserLogic     ul  = UserLogic.GetInstance();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    FormObject element = new FormObject();
                    element.ID        = Convert.ToInt32(dt.Rows[i]["ID"]);
                    element.FormName  = dt.Rows[i]["FormName"].ToString();
                    element.FormType  = ftl.GetFormType(Convert.ToInt32(dt.Rows[i]["FormType"]));
                    element.FormItems = fil.GetFormItemsByIds(dt.Rows[i]["FormItems"].ToString());
                    element.Owner     = ul.GetUser(Convert.ToInt32(dt.Rows[i]["Owner"]));
                    element.Remark    = dt.Rows[i]["Remark"].ToString();
                    elements.Add(element);
                }
            }
            return(elements);
        }
示例#2
0
        public static FormTypeLogic GetInstance()
        {
            if (instance == null)
            {
                instance = new FormTypeLogic();
            }

            return(instance);
        }
示例#3
0
        private void LoadFormTypes()
        {
            comboBox1.Items.Clear();
            List <FormType> types = FormTypeLogic.GetInstance().GetAllFormTypes();

            foreach (FormType type in types)
            {
                comboBox1.Items.Add(type);
            }
        }
示例#4
0
        private void LoadFormTypes()
        {
            List <FormType> elements = FormTypeLogic.GetInstance().GetAllFormTypes();

            comboBox1.Items.Clear();
            foreach (FormType element in elements)
            {
                comboBox1.Items.Add(element);
            }
            dataGridView1.DataSource = FormTypeLogic.GetInstance().GetFormTypes(string.Empty);
        }
示例#5
0
        private DataTable Search(string name)
        {
            string nm = "";

            if (!string.IsNullOrEmpty(name) && name.Trim() != "")
            {
                nm = " and TypeName like '%" + name + "%'";
            }
            string where = "(1=1)" + nm;
            return(FormTypeLogic.GetInstance().GetFormTypes(where));
        }
示例#6
0
        private void LoadFormTypes()
        {
            List <FormType> elements = FormTypeLogic.GetInstance().GetAllFormTypes();

            comboBox2.Items.Clear();
            comboBox2.Items.Add("--不限--");
            foreach (FormType element in elements)
            {
                comboBox2.Items.Add(element);
            }
            comboBox2.SelectedIndex = 0;
        }
示例#7
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         FormType formType = (FormType)comboBox1.SelectedItem;
         formType.TypeName = textBox1.Text.Trim();
         formType.Remark   = textBox2.Text;
         FormTypeLogic al = FormTypeLogic.GetInstance();
         if (al.ExistsNameOther(formType.TypeName, formType.ID))
         {
             if (MessageBox.Show("系统中已经存在该表单类型,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
             {
                 if (al.UpdateFormType(formType, this.User))
                 {
                     LoadFormTypes();
                     MessageBox.Show("修改成功!");
                 }
                 else
                 {
                     MessageBox.Show("修改失败或者您不是管理员!");
                 }
             }
             else
             {
                 textBox1.Focus();
                 textBox1.SelectAll();
             }
         }
         else
         {
             if (al.UpdateFormType(formType, this.User))
             {
                 LoadFormTypes();
                 MessageBox.Show("修改成功!");
             }
             else
             {
                 MessageBox.Show("修改失败或者您不是管理员!");
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要修改的表单类型!");
     }
 }
示例#8
0
        public FormObject GetFormObject(int id)
        {
            string    sql = "select * from TF_FormObject where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                FormObject element = new FormObject();
                element.ID        = id;
                element.FormName  = dt.Rows[0]["FormName"].ToString();
                element.FormType  = FormTypeLogic.GetInstance().GetFormType(Convert.ToInt32(dt.Rows[0]["FormType"]));
                element.FormItems = FormItemLogic.GetInstance().GetFormItemsByIds(dt.Rows[0]["FormItems"].ToString());
                element.Owner     = UserLogic.GetInstance().GetUser(Convert.ToInt32(dt.Rows[0]["Owner"]));
                element.Remark    = dt.Rows[0]["Remark"].ToString();
                return(element);
            }
            return(null);
        }
示例#9
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)
         {
             FormType formType = (FormType)comboBox1.SelectedItem;
             if (FormTypeLogic.GetInstance().DeleteFormType(formType, this.User))
             {
                 LoadFormTypes();
             }
             else
             {
                 MessageBox.Show("删除失败或者您不是管理员!");
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要删除的表单类型!");
     }
 }
示例#10
0
        private void button1_Click(object sender, EventArgs e)
        {
            FormType formType = new FormType();

            formType.TypeName = textBox1.Text.Trim();
            formType.Remark   = textBox2.Text;
            FormTypeLogic al = FormTypeLogic.GetInstance();

            if (al.ExistsName(formType.TypeName))
            {
                if (MessageBox.Show("系统中已经存在该表单类型,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                {
                    int id = al.AddFormType(formType);
                    if (id > 0)
                    {
                        formType.ID = id;
                        LoadFormTypes();
                        MessageBox.Show("添加成功!");
                    }
                }
                else
                {
                    textBox1.Focus();
                    textBox1.SelectAll();
                }
            }
            else
            {
                int id = al.AddFormType(formType);
                if (id > 0)
                {
                    formType.ID = id;
                    LoadFormTypes();
                    MessageBox.Show("添加成功!");
                }
            }
        }