using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace shuangyulin.Admin
{
    public partial class M_EditCourseInfo_QQ254540457 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DAL.Function.CheckState();
            if (!IsPostBack)
            {
                BindTeacher_QQ287307421courseTeacher();
                if (Request["courseNumber"] != null)
                {
                    LoadData();
                }
            }
        }
        private void BindTeacher_QQ287307421courseTeacher()
        {
            courseTeacher.DataSource = BLL.bllTeacher_QQ287307421.getAllTeacher_QQ287307421();
            courseTeacher.DataTextField = "teacherName";
            courseTeacher.DataValueField = "teacherNumber";
            courseTeacher.DataBind();
        }

        /*如果是需要对记录进行编辑需要在界面初始化显示数据*/
        private void LoadData()
        {
            if (!string.IsNullOrEmpty(Common.GetMes.GetRequestQuery(Request, "courseNumber")))
            {
                ENTITY.CourseInfo_QQ254540457 courseInfo_QQ254540457 = BLL.bllCourseInfo_QQ254540457.getSomeCourseInfo_QQ254540457(Common.GetMes.GetRequestQuery(Request, "courseNumber"));
                courseNumber.Value = courseInfo_QQ254540457.courseNumber;
                courseName.Value = courseInfo_QQ254540457.courseName;
                courseTeacher.SelectedValue = courseInfo_QQ254540457.courseTeacher;
                courseTime.Value = courseInfo_QQ254540457.courseTime;
                coursePlace.Value = courseInfo_QQ254540457.coursePlace;
                courseScore.Value = courseInfo_QQ254540457.courseScore.ToString("0.00");
                courseMemo.Value = courseInfo_QQ254540457.courseMemo;
            }
        }

        protected void BtnCourseInfo_QQ254540457Save_Click(object sender, EventArgs e)
        {
            ENTITY.CourseInfo_QQ254540457 courseInfo_QQ254540457 = new ENTITY.CourseInfo_QQ254540457();
            courseInfo_QQ254540457.courseNumber = this.courseNumber.Value;
            courseInfo_QQ254540457.courseName = courseName.Value;
            courseInfo_QQ254540457.courseTeacher = courseTeacher.SelectedValue;
            courseInfo_QQ254540457.courseTime = courseTime.Value;
            courseInfo_QQ254540457.coursePlace = coursePlace.Value;
            courseInfo_QQ254540457.courseScore = float.Parse(float.Parse(courseScore.Value).ToString("0.00"));
            courseInfo_QQ254540457.courseMemo = courseMemo.Value;
            if (!string.IsNullOrEmpty(Common.GetMes.GetRequestQuery(Request, "courseNumber")))
            {
                courseInfo_QQ254540457.courseNumber = Request["courseNumber"];
                if (BLL.bllCourseInfo_QQ254540457.EditCourseInfo_QQ254540457(courseInfo_QQ254540457))
                {
                    Common.ShowMessage.myScriptMes(Page, "Suess", "if(confirm(\"信息修改成功，是否继续修改？否则返回信息列表。\")) {location.href=\"M_EditCourseInfo_QQ254540457.aspx?courseNumber=" + Request["courseNumber"] + "\"} else  {location.href=\"M_CourseInfo_QQ254540457List.aspx\"} ");
                }
                else
                {
                    Common.ShowMessage.Show(Page, "error", "信息修改失败，请重试或联系管理人员..");
                }
            }
            else
            {
                if (BLL.bllCourseInfo_QQ254540457.AddCourseInfo_QQ254540457(courseInfo_QQ254540457))
                {
                   Common.ShowMessage.myScriptMes(Page, "Suess", "if(confirm(\"信息添加成功，是否继续添加？否则返回信息列表。\")) {location.href=\"M_EditCourseInfo_QQ254540457.aspx\"} else  {location.href=\"M_CourseInfo_QQ254540457List.aspx\"} ");
                }
                else
                {
                    Common.ShowMessage.Show(Page, "error", "信息添加失败，请重试或联系管理人员..");
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("M_CourseInfo_QQ254540457List.aspx");
        }
    }
}

