Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(OLBookstore.Model.Publishers model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Publishers set ");
#warning 系统发现缺少更新的字段,请手工确认如此更新是否正确!
            strSql.Append("Id=@Id,");
            strSql.Append("Name=@Name");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",   SqlDbType.Int,      4),
                new SqlParameter("@Name", SqlDbType.NVarChar, 200)
            };
            parameters[0].Value = model.Id;
            parameters[1].Value = model.Name;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(OLBookstore.Model.Publishers model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Publishers(");
            strSql.Append("Name)");
            strSql.Append(" values (");
            strSql.Append("@Name)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name", SqlDbType.NVarChar, 200)
            };
            parameters[0].Value = model.Name;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 private void ShowInfo(int Id)
 {
     OLBookstore.BLL.PublishersManager bll   = new OLBookstore.BLL.PublishersManager();
     OLBookstore.Model.Publishers      model = bll.GetModel(Id);
     this.lblId.Text   = model.Id.ToString();
     this.lblName.Text = model.Name;
 }
Exemple #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public OLBookstore.Model.Publishers DataRowToModel(DataRow row)
 {
     OLBookstore.Model.Publishers model = new OLBookstore.Model.Publishers();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
     }
     return(model);
 }
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    Id   = int.Parse(this.lblId.Text);
            string Name = this.lblName.Text;


            OLBookstore.Model.Publishers model = new OLBookstore.Model.Publishers();
            model.Id   = Id;
            model.Name = Name;

            OLBookstore.BLL.PublishersManager bll = new OLBookstore.BLL.PublishersManager();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Exemple #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtName.Text.Trim().Length == 0)
            {
                strErr += "Name不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string Name = this.txtName.Text;

            OLBookstore.Model.Publishers model = new OLBookstore.Model.Publishers();
            model.Name = Name;

            OLBookstore.BLL.PublishersManager bll = new OLBookstore.BLL.PublishersManager();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Exemple #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OLBookstore.Model.Publishers GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Name from Publishers ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            OLBookstore.Model.Publishers model = new OLBookstore.Model.Publishers();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

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