⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wfrmcoursematerialadd.aspx.cs

📁 Teacher Manager System
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using tw.org.iii.crm.data;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            fillCourseIDtoDropdownlist();
            txtCreator.Text = getFacade().目前使用者.USERNAME;

        }
    }
    private CCourseFactory iv_courseFactory;
    private CCourseFactory getCourseFactory()
    {
        if (iv_courseFactory == null)
        {
            iv_courseFactory = new CCourseFactory(Session["DbManager"].ToString());
        }
        return iv_courseFactory;
    }
    private CCourseMaterialFactory iv_教材Factory;
    private CCourseMaterialFactory get教材Factory()
    {
        if (iv_教材Factory == null)
        {
            iv_教材Factory = new CCourseMaterialFactory(Session["DbManager"].ToString());
        }
        return iv_教材Factory;

    }
    private void fillCourseIDtoDropdownlist()
    {
        CCourse[] l_課程s = getCourseFactory().getAll();
        DropDownList1.Items.Clear();
        foreach (CCourse c in l_課程s)
        {

            ListItem l = new ListItem();
            l.Text = c.CourseID;
            l.Value = c.CourseID;
            this.DropDownList1.Items.Add(l);
        }


    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        CCourseMaterial[] l_cms=get教材Factory().檢查是否重覆(fillInto());

        if (l_cms == null)
        {
            get教材Factory().update(fillInto());
            Response.Write("<script>alert('新增成功');</script>");
            Session["CM"] = "新增";
            Response.Redirect("WfrmCourseMaterial.aspx");

        }
        else
        {
            Response.Write("<script>alert('新增失敗,課程教材已重複');</script>");
            cleartext();
        }


    }

    private void cleartext()
    {
        txtAuther.Text = "";       
        txtMaterial.Text = "";
        txtMnote.Text = "";
        txtPublisher.Text = "";

    }

    private CCourseMaterial fillInto()
    {
        CCourseMaterial l_cm = new CCourseMaterial();
        l_cm.CourseID = DropDownList1.SelectedValue;
        l_cm.Material = txtMaterial.Text;
        l_cm.Author = txtAuther.Text;
        l_cm.Publisher = txtPublisher.Text;
        l_cm.MNote = txtMnote.Text;
        l_cm.Creator = txtCreator.Text;
        return l_cm;
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        CCourse l_course=getCourseFactory().queryByCourseID(DropDownList1.SelectedValue);
        txtCourseName.Text = l_course.CourseName;
        txtCourseName.ReadOnly = true;
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("WfrmCourseMaterial.aspx");
    }
    private CCFacade getFacade()
    {
        CCFacade l_facade = (CCFacade)Session["USER"];
        if (l_facade == null)
            Response.Redirect("WfrmLogeinPage.aspx");
        return l_facade;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -