Ejemplo n.º 1
0
        /// <summary>
        /// 当操作类型为修改时将输入更新到数据库中
        /// </summary>
        protected void Update()
        {
            if (!DataValid())
            {
                return;
            }
            if (alBinderItems.Count == 0)
            {
                return;
            }
            BinderItem bi;
            int        i = 0;

            doh.Reset();
            for (i = 0; i < alBinderItems.Count; i++)
            {
                bi = (BinderItem)alBinderItems[i];
                //如果是单选按钮且没有选中则跳过这个字段
                if (bi.o is MyRadioButton)
                {
                    MyRadioButton mrb = (MyRadioButton)bi.o;
                    if (mrb.rb.Checked == false)
                    {
                        continue;
                    }
                }

                doh.AddFieldItem(bi.field, bi.GetValue());
            }

            doh.ConditionExpress = this.ConditionExpress;
            doh.Update(this.TableName);
            this.OnModifyOk(System.EventArgs.Empty);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 当操作类型为添加时将输入添加到数据库中
        /// </summary>
        protected void Add()
        {
            if (!DataValid())
            {
                return;
            }
            if (alBinderItems.Count == 0)
            {
                return;
            }
            BinderItem bi;
            int        i = 0;

            doh.Reset();

            for (i = 0; i < alBinderItems.Count; i++)
            {
                bi = (BinderItem)alBinderItems[i];
                //如果是单选按钮且没有选中则跳过这个字段
                if (bi.o is MyRadioButton)
                {
                    MyRadioButton mrb = (MyRadioButton)bi.o;
                    if (mrb.rb.Checked == false)
                    {
                        continue;
                    }
                }

                doh.AddFieldItem(bi.field, bi.GetValue());
            }

            int id = doh.Insert(this.TableName);

            this.OnAddOk(new JumboECMS.DBUtility.DbOperEventArgs(id));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据控件类型设定控件的值
        /// </summary>
        /// <param name="_value">要设定的值。</param>
        public void SetValue(string _value)
        {
            //属性类型
            if (o is MyProperty)
            {
                MyProperty  mp   = (MyProperty)o;
                System.Type type = mp.po.GetType();
                System.Reflection.PropertyInfo pi = type.GetProperty(mp.propertyName);
                pi.SetValue(mp.po, _value, null);
                //return type.InvokeMember(mp.propertyName,System.Reflection.BindingFlags.GetProperty,null,mp.po,);
                //return mp.propertyName;
            }

            //字符串类型
            if (o is String)
            {
                //this.SetString((string)o,_value);
                //return;
                string s = (string)o;
                s = _value;
                return;
            }
            //委托
            if (o is Action)
            {
                Action action = (Action)o;
                action(_value);
                return;
            }
            //下拉框
            if (o is DropDownList)
            {
                DropDownList ddl = (DropDownList)o;
                ListItem     li  = ddl.Items.FindByValue(_value);
                if (li != null)
                {
                    ddl.ClearSelection();
                    li.Selected = true;
                }
                return;
            }
            //复选框
            if (o is MyCheckBox)
            {
                MyCheckBox mcb = (MyCheckBox)o;
                if (mcb.Value == _value)
                {
                    mcb.cb.Checked = true;
                }
                return;
            }
            //单选按钮
            if (o is MyRadioButton)
            {
                MyRadioButton mrb = (MyRadioButton)o;
                if (mrb.Value == _value)
                {
                    mrb.rb.Checked = true;
                }
                return;
            }
            //文本框
            if (o is TextBox)
            {
                TextBox tb = (TextBox)o;
                tb.Text = _value;
                return;
            }
            //Label
            if (o is Label)
            {
                Label lbl = (Label)o;
                lbl.Text = _value;
                return;
            }
            //Literal
            if (o is Literal)
            {
                Literal ltl = (Literal)o;
                ltl.Text = _value;
                return;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据控件类型获得控件的值。
        /// </summary>
        /// <returns>控件的值。</returns>
        public string GetValue()
        {
            //属性类型
            if (o is MyProperty)
            {
                MyProperty  mp   = (MyProperty)o;
                System.Type type = mp.po.GetType();
                System.Reflection.PropertyInfo pi = type.GetProperty(mp.propertyName);
                return((string)pi.GetValue(mp.po, null));
                //return type.InvokeMember(mp.propertyName,System.Reflection.BindingFlags.GetProperty,null,mp.po,);
                //return mp.propertyName;
            }

            //字符串类型
            if (o is String)
            {
                string s = (string)o;
                return(s);
            }
            //方法委托
            if (o is Action)
            {
                Action action = (Action)o;
                return(action("_g_e_t_"));
            }
            //下拉框
            if (o is DropDownList)
            {
                DropDownList ddl = (DropDownList)o;
                return(ddl.SelectedValue);
            }
            //复选框
            if (o is MyCheckBox)
            {
                MyCheckBox mcb = (MyCheckBox)o;
                if (mcb.cb.Checked)
                {
                    return(mcb.Value);
                }
                else
                {
                    return("0");
                }
            }
            //单选按钮
            if (o is MyRadioButton)
            {
                MyRadioButton mrb = (MyRadioButton)o;
                if (mrb.rb.Checked)
                {
                    return(mrb.Value);
                }
            }
            //文本框
            if (o is TextBox)
            {
                TextBox tb = (TextBox)o;
                return(tb.Text);
            }
            //Label
            if (o is Label)
            {
                Label lbl = (Label)o;
                return(lbl.Text);
            }
            //Literal
            if (o is Literal)
            {
                Literal ltl = (Literal)o;
                return(ltl.Text);
            }
            return(string.Empty);
        }