Пример #1
0
        private bool DoEdit(int id)
        {
            bool result = true;

            int    BrandsID   = id;
            string BrandsName = this.txtBrandsName.Text;
            int    SortIndex  = int.Parse(this.txtSortIndex.Text);
            string Remark     = this.txtRemark.Value;


            WebSiteModel.Brands model = new WebSiteModel.Brands();

            model.BrandsID   = BrandsID;
            model.BrandsName = BrandsName;
            model.SortIndex  = SortIndex;
            model.Remark     = Remark;

            WebSiteData.Brands bll = new WebSiteData.Brands();

            if (!bll.Update(model))
            {
                result = false;
            }

            return(result);
        }
Пример #2
0
        protected void btnMutil_Click(object sender, EventArgs e)
        {
            string[]           arr = this.txtBrandsName.Text.Split('|');
            WebSiteData.Brands dal = new WebSiteData.Brands();

            int n = 0;

            for (int i = 0; i < arr.Length; i++)
            {
                string BrandsName = arr[i];
                int    SortIndex  = int.Parse(this.txtSortIndex.Text);
                string Remark     = this.txtRemark.Value;

                WebSiteModel.Brands model = new WebSiteModel.Brands();

                model.BrandsName = BrandsName;
                model.SortIndex  = SortIndex;
                model.Remark     = Remark;


                n = dal.Add(model);

                if (n < 1)
                {
                    Response.Write("<span>添加失败了!</span>");
                    continue;
                }
                else
                {
                    Response.Write("<span>添加成功了!</span>");
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebSiteModel.Brands model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Brands(");
            strSql.Append("BrandsName,SortIndex,Remark)");
            strSql.Append(" values (");
            strSql.Append("@BrandsName,@SortIndex,@Remark)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@BrandsName", DbType.String),
                new SQLiteParameter("@SortIndex",  DbType.Int32,8),
                new SQLiteParameter("@Remark",     DbType.String)
            };
            parameters[0].Value = model.BrandsName;
            parameters[1].Value = model.SortIndex;
            parameters[2].Value = model.Remark;

            object obj = DbHelperSQLite.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebSiteModel.Brands model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Brands set ");
            strSql.Append("BrandsName=@BrandsName,");
            strSql.Append("SortIndex=@SortIndex,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where BrandsID=@BrandsID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@BrandsName", DbType.String),
                new SQLiteParameter("@SortIndex",  DbType.Int32,8),
                new SQLiteParameter("@Remark",     DbType.String),
                new SQLiteParameter("@BrandsID",   DbType.Int32, 8)
            };
            parameters[0].Value = model.BrandsName;
            parameters[1].Value = model.SortIndex;
            parameters[2].Value = model.Remark;
            parameters[3].Value = model.BrandsID;

            int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        private void ShowInfo(int BrandsID)
        {
            WebSiteData.Brands  bll   = new WebSiteData.Brands();
            WebSiteModel.Brands model = bll.GetModel(BrandsID);

            this.lblBrandsID.Text   = model.BrandsID.ToString();
            this.txtBrandsName.Text = model.BrandsName;
            this.txtSortIndex.Text  = model.SortIndex.ToString();
            this.txtRemark.Value    = model.Remark;
        }
Пример #6
0
        private bool DoAdd()
        {
            bool result = true;

            string BrandsName = this.txtBrandsName.Text;
            int    SortIndex  = int.Parse(this.txtSortIndex.Text);
            string Remark     = this.txtRemark.Value;

            WebSiteModel.Brands model = new WebSiteModel.Brands();

            model.BrandsName = BrandsName;
            model.SortIndex  = SortIndex;
            model.Remark     = Remark;

            WebSiteData.Brands bll = new WebSiteData.Brands();

            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return(result);
        }
Пример #7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebSiteModel.Brands DataRowToModel(DataRow row)
 {
     WebSiteModel.Brands model = new WebSiteModel.Brands();
     if (row != null)
     {
         if (row["BrandsID"] != null && row["BrandsID"].ToString() != "")
         {
             model.BrandsID = int.Parse(row["BrandsID"].ToString());
         }
         if (row["BrandsName"] != null)
         {
             model.BrandsName = row["BrandsName"].ToString();
         }
         if (row["SortIndex"] != null && row["SortIndex"].ToString() != "")
         {
             model.SortIndex = int.Parse(row["SortIndex"].ToString());
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
     }
     return(model);
 }
Пример #8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebSiteModel.Brands GetModel(int BrandsID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select BrandsID,BrandsName,SortIndex,Remark from Brands ");
            strSql.Append(" where BrandsID=@BrandsID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@BrandsID", DbType.Int32, 4)
            };
            parameters[0].Value = BrandsID;

            WebSiteModel.Brands model = new WebSiteModel.Brands();
            DataSet             ds    = DbHelperSQLite.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }