Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool Add(Model.H_Detail_Course model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into H_Detail_Course(");
            strSql.Append("subordinate_course_id,course_name,course_ori_price,course_sel_price,course_pur_price,student_share,clerk_share,service_share)");
            strSql.Append(" values (");
            strSql.Append("@subordinate_course_id,@course_name,@course_ori_price,@course_sel_price,@course_pur_price,@student_share,@clerk_share,@service_share)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@subordinate_course_id", SqlDbType.Int,       4),
                new SqlParameter("@course_name",           SqlDbType.NVarChar, 50),
                new SqlParameter("@course_ori_price",      SqlDbType.Float,     9),
                new SqlParameter("@course_sel_price",      SqlDbType.Float,     9),
                new SqlParameter("@course_pur_price",      SqlDbType.Float,     9),
                new SqlParameter("@student_share",         SqlDbType.Float,     9),
                new SqlParameter("@clerk_share",           SqlDbType.Float,     9),
                new SqlParameter("@service_share",         SqlDbType.Float, 9)
            };
            parameters[0].Value = model.subordinate_course_id;
            parameters[1].Value = model.course_name;
            parameters[2].Value = model.course_ori_price;
            parameters[3].Value = model.course_sel_price;
            parameters[4].Value = model.course_pur_price;
            parameters[5].Value = model.student_share;
            parameters[6].Value = model.clerk_share;
            parameters[7].Value = model.service_share;

            return(DbHelperSQL.ExecuteSql(strSql.ToString(), parameters) > 0);
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.H_Detail_Course GetModel(string id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,subordinate_course_id,course_name,course_ori_price,course_sel_price,course_pur_price,student_share,clerk_share,service_share from H_Detail_Course ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.H_Detail_Course model = new Model.H_Detail_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());
                }
                if (ds.Tables[0].Rows[0]["subordinate_course_id"].ToString() != "")
                {
                    model.subordinate_course_id = int.Parse(ds.Tables[0].Rows[0]["subordinate_course_id"].ToString());
                }
                model.course_name = ds.Tables[0].Rows[0]["course_name"].ToString();
                if (ds.Tables[0].Rows[0]["course_ori_price"].ToString() != "")
                {
                    model.course_ori_price = double.Parse(ds.Tables[0].Rows[0]["course_ori_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["course_sel_price"].ToString() != "")
                {
                    model.course_sel_price = double.Parse(ds.Tables[0].Rows[0]["course_sel_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["course_pur_price"].ToString() != "")
                {
                    model.course_pur_price = double.Parse(ds.Tables[0].Rows[0]["course_pur_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["student_share"].ToString() != "")
                {
                    model.student_share = double.Parse(ds.Tables[0].Rows[0]["student_share"].ToString());
                }
                if (ds.Tables[0].Rows[0]["clerk_share"].ToString() != "")
                {
                    model.clerk_share = double.Parse(ds.Tables[0].Rows[0]["clerk_share"].ToString());
                }
                if (ds.Tables[0].Rows[0]["service_share"].ToString() != "")
                {
                    model.service_share = double.Parse(ds.Tables[0].Rows[0]["service_share"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
 private void InitData()
 {
     if (Request.QueryString["pid"] != null)
     {
         string pid = Request.QueryString["pid"].ToString();
         Model.H_Detail_Course detail_course = H_Detail_CourseClass.GetModel(pid);
         this.TextDetailCourse.Value  = detail_course.course_name;
         this.TextPur_Price.Value     = detail_course.course_pur_price.ToString();
         this.TextSel_Price.Value     = detail_course.course_sel_price.ToString();
         this.TextStudent_Share.Value = detail_course.student_share.ToString();
         this.TextClerk_Share.Value   = detail_course.clerk_share.ToString();
         this.TextService_Share.Value = detail_course.service_share.ToString();
     }
 }
Пример #4
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Model.H_Detail_Course detail_course = new Model.H_Detail_Course();
     detail_course.subordinate_course_id = int.Parse(pid);
     detail_course.course_name           = this.TextDetailCourse.Value.Trim();
     detail_course.course_sel_price      = double.Parse(this.TextSel_Price.Value.Trim());
     detail_course.course_pur_price      = double.Parse(this.TextPur_Price.Value.Trim());
     detail_course.clerk_share           = double.Parse(this.TextClerk_Share.Value.Trim());
     detail_course.student_share         = double.Parse(this.TextStudent_Share.Value.Trim());
     detail_course.service_share         = double.Parse(this.TextService_Share.Value.Trim());
     if (H_Detail_CourseClass.Add(detail_course))
     {
         JScript.AlertAndRedirect("操作成功", "DetailCourseList.aspx?pid=" + pid + "", this);
     }
     else
     {
         JScript.Alert("操作失败", "a2", this);
     }
 }
Пример #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(Model.H_Detail_Course model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update H_Detail_Course set ");
            strSql.Append("subordinate_course_id=@subordinate_course_id,");
            strSql.Append("course_name=@course_name,");
            strSql.Append("course_ori_price=@course_ori_price,");
            strSql.Append("course_sel_price=@course_sel_price,");
            strSql.Append("course_pur_price=@course_pur_price,");
            strSql.Append("student_share=@student_share,");
            strSql.Append("clerk_share=@clerk_share,");
            strSql.Append("service_share=@service_share");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@subordinate_course_id", SqlDbType.Int,       4),
                new SqlParameter("@course_name",           SqlDbType.NVarChar, 50),
                new SqlParameter("@course_ori_price",      SqlDbType.Float,     9),
                new SqlParameter("@course_sel_price",      SqlDbType.Float,     9),
                new SqlParameter("@course_pur_price",      SqlDbType.Float,     9),
                new SqlParameter("@student_share",         SqlDbType.Float,     9),
                new SqlParameter("@clerk_share",           SqlDbType.Float,     9),
                new SqlParameter("@service_share",         SqlDbType.Float,     9),
                new SqlParameter("@id",                    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.subordinate_course_id;
            parameters[1].Value = model.course_name;
            parameters[2].Value = model.course_ori_price;
            parameters[3].Value = model.course_sel_price;
            parameters[4].Value = model.course_pur_price;
            parameters[5].Value = model.student_share;
            parameters[6].Value = model.clerk_share;
            parameters[7].Value = model.service_share;
            parameters[8].Value = model.id;

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