Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfoBll bll   = new MemberTypeInfoBll();
            MemberTypeInfo    model = new MemberTypeInfo()
            {
                MTitle    = txtTitle.Text,
                MDiscount = Convert.ToDecimal(txtDiscount.Text),
            };

            if (btnSave.Text == "添加")
            {
                if (!bll.Add(model))
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                model.MId = Convert.ToInt32(txtId.Text);
                if (!bll.Update(model))
                {
                    MessageBox.Show("修改失败");
                }
            }

            Reset();
            LoadList();
            resulted = DialogResult.OK;
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfo mti = new MemberTypeInfo();

            mti.MTitle    = txtTitle.Text;
            mti.MDiscount = Convert.ToDecimal(txtDiscount.Text);
            if (!btnSave.Text.Equals("保存"))
            {
                mti.MId = Convert.ToInt32(txtId.Text);
                if (mtiBll.UpdateMTI(mti))
                {
                    LoadList();
                    txtId.Text       = "添加时无编号";
                    txtDiscount.Text = "";
                    txtTitle.Text    = "";
                    btnSave.Text     = "保存";
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
                result = DialogResult.OK;
                return;
            }
            if (mtiBll.AddMTI(mti))
            {
                LoadList();
            }
            else
            {
                MessageBox.Show("添加失败");
            }
            result = DialogResult.OK;
        }
Beispiel #3
0
        private static IMemberAccessor CreateMemberAccessor(MemberTypeInfo mi, bool readOnly, IObjectCache <string> memberCache)
        {
            var genType = typeof(DelegateMemberAccessor <,>).MakeGenericType(mi.DeclaringType, mi.MemberType);
            var result  = Activator.CreateInstance(genType, mi.Name, readOnly, memberCache);

            return((IMemberAccessor)result);
        }
Beispiel #4
0
 private void button_添加_Click(object sender, EventArgs e)
 {
     if (textBox_标题.Text != "" && textBox_折扣.Text != "")
     {
         try
         {
             MemberTypeInfo mti = new MemberTypeInfo()
             {
                 MTitle    = textBox_标题.Text,
                 MDiscount = decimal.Parse(textBox_折扣.Text),
                 MIsdelete = false
             };
             if (MTIBll.Insert(mti))
             {
                 GetInfo();
                 button_取消.PerformClick();
             }
             else
             {
                 button_取消.PerformClick();
                 MessageBox.Show("添加不成功,请重试");
             }
         }
         catch (FormatException)
         {
             MessageBox.Show("折扣必须是数字");
         }
     }
     else
     {
         MessageBox.Show("文本框不能为空");
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfo mti = new MemberTypeInfo();

            mti.MDiscount = Convert.ToDecimal(txtDiscount.Text);
            mti.MTitle    = txtTitle.Text;
            if (txtId.Text == "添加时无编号")//表示增加
            {
                if (mtiBll.Add(mti))
                {
                    LoadList();
                    ClearText();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后再试!");
                }
            }
            else
            {
                mti.MId = Convert.ToInt32(txtId.Text);
                if (mtiBll.Edit(mti))
                {
                    LoadList();
                    ClearText();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍后再试!");
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfo mti = new MemberTypeInfo()
            {
                MTitle    = txtTitle.Text,
                MDiscount = Convert.ToDecimal(txtDiscount.Text)
            };

            if (txtId.Text.Equals("No ID"))
            {
                if (mtiBll.Add(mti))
                {
                    LoadList();
                }
            }
            else
            {
                mti.MId = int.Parse(txtId.Text);
                if (mtiBll.Edit(mti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("Failed.");
                }
            }
            txtId.Text       = "No ID";
            txtTitle.Text    = "";
            txtDiscount.Text = "";
            btnSave.Text     = "Add";

            result = DialogResult.OK;
        }
 public bool Alert(MemberTypeInfo mti)
 {
     if (mbtdal.Update(mti) > 0)
     {
         return(true);
     }
     return(false);
 }
Beispiel #8
0
        //修改
        public int updateMTI(MemberTypeInfo mti)
        {
            string sql = "update membertypeinfo set mtitle=@title,MDiscount=@discount where mid=@id";

            SQLiteParameter[] sp = { new SQLiteParameter("@title", mti.MTitle)
                                     ,                             new SQLiteParameter("@discount", mti.MDiscount)
                                     ,                             new SQLiteParameter("@id", mti.MId) };
            return(SqliteHelper.ExecuteNonQuery(sql, sp));
        }
        public bool Add(MemberTypeInfo mti)
        {
            if (mbtdal.Insert(mti) > 0)
            {
                return(true);
            }

            return(false);
        }
        public SystemClassWithMembersAndTypes(DeserializeReader reader) : base(reader, RecordType.SystemClassWithMembersAndTypes)
        {
            ClassInfo      = new ClassInfo(reader);
            MemberTypeInfo = new MemberTypeInfo(reader, ClassInfo);

            if (MemberTypeInfo.Types.Count != ClassInfo.MemberCount)
            {
                throw new InvalidStructureException("Member type count mismatch");
            }
        }
Beispiel #11
0
        public int Delete(MemberTypeInfo mti)
        {
            string sql = "DELETE FROM MemberTypeInfo WHERE MId =@id";

            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@id", mti.MId)
            };
            return(SqliteHelper.ExecuteNonQuery(sql, ps));
        }
Beispiel #12
0
        //添加
        public int insertMTI(MemberTypeInfo mti)
        {
            string sql = "insert into membertypeinfo(mtitle,MDiscount,MIsDelete)"
                         + "values(@title,@discount,@MIsDelete)";

            SQLiteParameter[] sp = { new SQLiteParameter("@title", mti.MTitle)
                                     ,                             new SQLiteParameter("@discount", mti.MDiscount)
                                     ,                             new SQLiteParameter("@MIsDelete", false) };
            return(SqliteHelper.ExecuteNonQuery(sql, sp));
        }
Beispiel #13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //判断输入有效性
            if (string.IsNullOrWhiteSpace(txtTitle.Text))
            {
                MessageBox.Show("请输入标题");
                txtTitle.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(txtDiscount.Text))
            {
                MessageBox.Show("请输入折扣");
                txtDiscount.Focus();
                return;
            }
            //接收用户输入的值,构造对象
            MemberTypeInfo mti = new MemberTypeInfo()
            {
                MTitle    = txtTitle.Text,
                MDiscount = decimal.Parse(txtDiscount.Text)
            };

            if (txtId.Text.Equals("添加时无编号"))
            {
                //添加操作
                if (mtiBll.Add(mti))    //调用添加方法
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍候重试");
                }
            }
            else
            {
                //修改操作
                mti.MId = int.Parse(txtId.Text);
                if (mtiBll.Edit(mti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍候重试");
                }
            }
            //将控件还原
            txtId.Text       = "添加时无编号";
            txtTitle.Text    = "";
            txtDiscount.Text = "";
            btnSave.Text     = "添加";

            result = DialogResult.OK;
        }
Beispiel #14
0
        public int Insert(MemberTypeInfo memberTypeInfo)
        {
            string sql = "insert into MemberTypeInfo(mtitle,mdiscount,misdelete) values(@title,@discount,0)";

            SQLiteParameter[] parameter =
            {
                new SQLiteParameter("@title",    memberTypeInfo.MTitle),
                new SQLiteParameter("@discount", memberTypeInfo.MDiscount),
            };
            return(SqliteHelper.ExecuteNonQuery(sql, parameter));
        }
Beispiel #15
0
        public int Insert(MemberTypeInfo mti)
        {
            var sql = "insert into membertypeinfo (mtitle,mdiscount,misDelete) values (@title,@discount,0)";

            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@title",    mti.MTitle),
                new SQLiteParameter("@discount", mti.MDiscount)
            };
            return(SqliteHelper.ExecuteNonQuery(sql, ps));
        }
        public int Insert(MemberTypeInfo memberTypeInfo)
        {
            string sql = "insert into MemberTypeInfo('MTitle','MDiscount','MIsDelete') values(@title,@discount,0)";

            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@title",    memberTypeInfo.MTitle),
                new SQLiteParameter("@discount", memberTypeInfo.MDiscount),
            };
            return(SqliteHelper.ExecuteNonQuery(sql, ps));
        }
        public int Insert(MemberTypeInfo mti)
        {
            string sql = "insert into MemberTypeInfo (MTitle,MDiscount,MIsDelete) values (@MTitle,@MDiscount,0)";

            SQLiteParameter[] sp =
            {
                new SQLiteParameter("MTitle",    mti.MTitle),
                new SQLiteParameter("MDiscount", mti.MDiscount)
            };
            return(SQLiteHelper.ExecuteNonQuery(sql, sp));
        }
Beispiel #18
0
        public int Update(MemberTypeInfo memberTypeInfo)
        {
            string sql = "update membertypeinfo set mtitle=@title,mdiscount=@discount where mid=@id";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@title",    memberTypeInfo.MTitle),
                new SQLiteParameter("@discount", memberTypeInfo.MDiscount),
                new SQLiteParameter("@id",       memberTypeInfo.MId),
            };
            return(SqliteHelper.ExecuteNonQuery(sql, parameters));
        }
        public int Update(MemberTypeInfo mti)
        {
            string sql = "update MemberTypeInfo set MTitle=@MTitle,MDiscount=@MDiscount where Mid=@Mid";

            SQLiteParameter[] sp =
            {
                new SQLiteParameter("MTitle",    mti.MTitle),
                new SQLiteParameter("MDiscount", mti.MDiscount),
                new SQLiteParameter("Mid",       mti.MId)
            };
            return(SQLiteHelper.ExecuteNonQuery(sql, sp));
        }
        public int Insert(MemberTypeInfo mit)
        {
            //构造插入语句,注意:必须列与值要相对应
            string sql = "insert into MemberTypeInfo(MTitle,MDiscount,MIsDelete) values(@title,@discount,0)";

            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@title",    mit.MTitle),
                new SQLiteParameter("@discount", mit.MDiscount)
            };
            return(SqliteHelper.ExecuteNonQuery(sql, ps));
        }
        public int Update(MemberTypeInfo memberTypeInfo)
        {
            string sql = "update MemberTypeInfo set MDiscount=@discount,MTitle=@title where MId=@id";

            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@discount", memberTypeInfo.MDiscount),
                new SQLiteParameter("@title",    memberTypeInfo.MTitle),
                new SQLiteParameter("@id",       memberTypeInfo.MId)
            };
            return(SqliteHelper.ExecuteNonQuery(sql, ps));
        }
Beispiel #22
0
        public int Update(MemberTypeInfo model)
        {
            string sql = "update MemberTypeInfo set Mtitle=@title,MDiscount=@count where Mid=@id";

            SQLiteParameter[] param =
            {
                new SQLiteParameter("@title", model.MTitle),
                new SQLiteParameter("@count", model.MDiscount),
                new SQLiteParameter("@id",    model.MId)
            };
            return(SqliteHelper.ExecuteNonQuery(sql, param));
        }
Beispiel #23
0
        public int Add(MemberTypeInfo model)
        {
            string sql = "insert into MemberTypeInfo(MTitle,MDiscount,MIsDelete) values(@title,@discount,@isdelete)";

            SQLiteParameter[] param =
            {
                new SQLiteParameter("@title",    model.MTitle),
                new SQLiteParameter("@discount", model.MDiscount),
                new SQLiteParameter("@isdelete", model.MIsDelete)
            };
            return(SqliteHelper.ExecuteNonQuery(sql, param));
        }
Beispiel #24
0
        public int Update(MemberTypeInfo mti)
        {
            var sql = "update membertypeinfo set mtitle=@mtitle,mdiscount=@mdiscount where mid=@mid";

            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@mtitle",    mti.MTitle),
                new SQLiteParameter("@mdiscount", mti.MDiscount),
                new SQLiteParameter("@mid",       mti.Mid)
            };
            return(SqliteHelper.ExecuteNonQuery(sql, ps));
        }
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="mti"></param>
        /// <returns></returns>
        public int Insert(MemberTypeInfo mti)
        {
            string sqltext = "insert into MemberTypeInfo(MTitle,MDiscount,MIsDelete) values(@title,@discount,0)";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@title",    DbType.String),
                new SQLiteParameter("@discount", DbType.Decimal),
            };
            parameters[0].Value = mti.MTitle;
            parameters[1].Value = mti.MDiscount;
            return(SQLiteHelper.ExecuteNonQuery(sqltext, parameters));
        }
Beispiel #26
0
        /// <summary>
        /// insert MemberTypeInfo对象
        /// </summary>
        /// <param name="mti"></param>
        /// <returns></returns>
        public int Insert(MemberTypeInfo mti)
        {
            //构造insert语句
            string sql = "INSERT INTO MemberTypeInfo(MTitle, MDiscount, MIsDelete) VALUES(@title, @discount, 1)";

            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@title",    mti.MTitle),
                new SQLiteParameter("@discount", mti.MDiscount),
            };

            return(SqliteHelper.ExecuteNonQuery(sql, ps));
        }
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="mti"></param>
        /// <returns></returns>
        public int Insert(MemberTypeInfo mti)
        {
            //构造添加sql语句
            string sql = "INSERT INTO MemberTypeInfo (MTitle,MDiscount,MIsDelete) VALUES(@MTitle,@MDiscount,0)";

            //构造参数
            MySqlParameter[] ps =
            {
                new MySqlParameter("@MTitle",    mti.MTitle),
                new MySqlParameter("@MDiscount", mti.MDiscount),
            };
            //调用操作数据方法
            return(MysqlHelper.ExecuteNonQuery(sql, ps));
        }
        public int Update(MemberTypeInfo mti)
        {
            string sql = "update MemberTypeInfo set Mtitle=@title,Mdiscount=@discount,MIsDelete=@isdelete where mid=@id";

            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@id",       mti.Mid),
                new SQLiteParameter("@title",    mti.Mtitle),
                new SQLiteParameter("@discount", mti.Mdiscount),
                new SQLiteParameter("@isdelete", mti.MIsDelete)
            };

            return(SqliteHelper.Execute(sql, sqltype.ExecuteNonQuery, ps));
        }
Beispiel #29
0
        //添加
        public int Insert(MemberTypeInfo mti)
        {
            //构造insert语句
            string sql = "insert into MemberTypeInfo(mtitle,mdiscount,misDelete) values(@title,@discount,0)";

            //为sql语句构造参数
            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@title",    mti.MTitle),
                new SQLiteParameter("@discount", mti.MDiscount)
            };
            //执行
            return(SqliteHelper.ExecuteNonQuery(sql, ps));
        }
        public int Insert(MemberTypeInfo mti)
        {
            string sql = "insert into MemberTypeInfo(mid,mtitle,mdiscount,misdelete) values(@id,@type,@discount,@isdelete)";

            SQLiteParameter[] ps =
            {
                new SQLiteParameter("@id",       mti.Mid),
                new SQLiteParameter("@type",     mti.Mtitle),
                new SQLiteParameter("@discount", mti.Mdiscount),
                new SQLiteParameter("@isdelete", mti.MIsDelete)
            };

            return(SqliteHelper.Execute(sql, sqltype.ExecuteNonQuery, ps));
        }