Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.H_Basic_Course GetModel(string id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,subcourse,father from H_Subordinate_Course ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.basiccourse = ds.Tables[0].Rows[0]["subcourse"].ToString();
                model.province    = ds.Tables[0].Rows[0]["father"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
        private void InitData()
        {
            if (Request.QueryString["pid"] != null)
            {
                string pid = Request.QueryString["pid"].ToString();
                Model.H_Basic_Course basic_course = H_Basic_CourseClass.GetModel(pid);

                this.TextBasicCourse.Value = basic_course.basiccourse;
            }
        }
Пример #3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Model.H_Basic_Course basic_course = new Model.H_Basic_Course();
     basic_course.province    = this.HiddenProvince.Value.ToString();
     basic_course.basiccourse = this.TextBasicCourse.Value;
     if (H_Basic_CourseClass.Add(basic_course))
     {
         JScript.Alert("操作成功!", "a2", this);
     }
     else
     {
         JScript.Alert("操作失败!", "a2", this);
     }
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Model.H_Basic_Course basic_course = new Model.H_Basic_Course();
            basic_course.id          = int.Parse(Request.QueryString["pid"]);
            basic_course.basiccourse = this.TextBasicCourse.Value.Trim();

            if (H_Basic_CourseClass.Update(basic_course))
            {
                JScript.AlertAndRedirect("操作成功", "BasicCourseList.aspx", this);
            }
            else
            {
                JScript.AlertAndRedirect("操作失败", "a2", this);
            }
        }
Пример #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool Add(Model.H_Basic_Course model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into H_Subordinate_Course(");
            strSql.Append("subcourse,father)");
            strSql.Append(" values (");
            strSql.Append("@basiccourse,@province)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@basiccourse", SqlDbType.NVarChar, 50),
                new SqlParameter("@province",    SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.basiccourse;
            parameters[1].Value = model.province;

            return(DbHelperSQL.ExecuteSql(strSql.ToString(), parameters) > 0);
        }
Пример #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(Model.H_Basic_Course model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update H_Subordinate_Course set ");
            strSql.Append("subcourse=@basiccourse,");
            strSql.Append("father=@province");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@basiccourse", SqlDbType.NVarChar, 50),
                new SqlParameter("@province",    SqlDbType.Int,       4),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.basiccourse;
            parameters[1].Value = model.province;
            parameters[2].Value = model.id;

            return(DbHelperSQL.ExecuteSql(strSql.ToString(), parameters) > 0);
        }