예제 #1
0
 private void ShowInfo(string category)
 {
     UFB.BLL.CategoryManager bll   = new UFB.BLL.CategoryManager();
     UFB.Model.Category      model = bll.GetModel(category);
     this.lblcategory.Text = model.category;
     this.lbltime.Text     = model.time.ToString();
 }
예제 #2
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsDateTime(txttime.Text))
            {
                strErr += "time格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   category = this.lblcategory.Text;
            DateTime time     = DateTime.Parse(this.txttime.Text);


            UFB.Model.Category model = new UFB.Model.Category();
            model.category = category;
            model.time     = time;

            UFB.BLL.CategoryManager bll = new UFB.BLL.CategoryManager();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(UFB.Model.Category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Category set ");
            strSql.Append("time=@time");
            strSql.Append(" where category=@category ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@time",     SqlDbType.SmallDateTime),
                new SqlParameter("@category", SqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.time;
            parameters[1].Value = model.category;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(UFB.Model.Category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Category(");
            strSql.Append("category,time)");
            strSql.Append(" values (");
            strSql.Append("@category,@time)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@category", SqlDbType.VarChar, 64),
                new SqlParameter("@time",     SqlDbType.SmallDateTime)
            };
            parameters[0].Value = model.category;
            parameters[1].Value = model.time;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public UFB.Model.Category DataRowToModel(DataRow row)
 {
     UFB.Model.Category model = new UFB.Model.Category();
     if (row != null)
     {
         if (row["category"] != null)
         {
             model.category = row["category"].ToString();
         }
         if (row["time"] != null && row["time"].ToString() != "")
         {
             model.time = DateTime.Parse(row["time"].ToString());
         }
     }
     return(model);
 }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public UFB.Model.Category GetModel(string category)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 category,time from Category ");
            strSql.Append(" where category=@category ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@category", SqlDbType.VarChar, 64)
            };
            parameters[0].Value = category;

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

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