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

📄 them.aspx

📁 web asp.net, code c# and use xml.
💻 ASPX
字号:
<%@ Page Language="C#" %>
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.OleDb" %>
<%@Import Namespace="System.Xml" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {                   
                    if (Session["username"] != null)
                    {
                        lbkq.Text = "Chào, bạn đang " + Session["Them"].ToString() + " dữ liệu";
                    }         
            else
            {
                Response.Redirect("Login.aspx");
            }
    }

    protected void btthem_Click(object sender, EventArgs e)
    {
        string strCurrentPath = Request.PhysicalPath;
        string strXMLPath = strCurrentPath.Substring(0, strCurrentPath.LastIndexOf("\\"))
                            + "\\newQuanLySinhVien.xml";
        XmlDocument doc = new XmlDocument();
        doc.Load(strXMLPath);
        XmlElement root = doc.DocumentElement;
        XmlElement svnode = doc.CreateElement("SinhVien");
        XmlElement sv = doc.CreateElement("SVien");
        XmlElement lopnode = doc.CreateElement("LopNode");
        XmlElement lop = doc.CreateElement("Lop");
        XmlElement tlop = doc.CreateElement("Ten");
        tlop.InnerText = txttlop.Value;
        XmlElement diem = doc.CreateElement("Diem");
        diem.InnerText = txttdiem.Value;
        XmlElement mon = doc.CreateElement("Mon");
        mon.InnerText = txttmon.Value;
        XmlElement mssv = doc.CreateElement("MSSV");
        mssv.InnerText = txttmssv.Value;
        sv.AppendChild(mssv);
        XmlElement hten = doc.CreateElement("HoTen");
        hten.InnerText = txtthten.Value;
         sv.AppendChild(hten);
        XmlElement lopid = doc.CreateElement("LopID");
        lopid.InnerText = "1";
        sv.AppendChild(lopid);
        lop.AppendChild(lopid);
        lop.AppendChild(tlop);
        lop.AppendChild(diem);
        lop.AppendChild(mon);
        lopnode.AppendChild(lop);
        svnode.AppendChild(sv);
        root.AppendChild(svnode);
        root.AppendChild(lopnode);
        doc.Save(strXMLPath);
        lbkq.Text = "Thong tin đã dc them vao trong csdl";
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lbkq" runat="server" Height="25px" Style="z-index: 100; left: 21px;
            position: absolute; top: 11px"></asp:Label>
        <br />
        <br />
        <asp:Button ID="btthem" runat="server" OnClick="btthem_Click" Style="z-index: 100;
            left: 6px; position: relative; top: 125px" Text="Thêm" /><table border="0" style="z-index: 103;
                left: 6px; position: relative; top: -50px">
                <tr>
                    <td style="width: 82px; height: 21px">
                        Mssv:</td>
                    <td colspan="2" style="width: 160px; height: 21px">
                        <input id="txttmssv" runat="server" type="text" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 82px; height: 21px">
                        Họ tên:</td>
                    <td colspan="2" style="width: 160px; height: 21px">
                        &nbsp;<input id="txtthten" runat="server" style="left: -3px; width: 149px; position: relative;
                            top: 0px" type="text" /></td>
                </tr>
                <tr>
                    <td style="width: 82px; height: 21px">
                        Lớp:</td>
                    <td colspan="2" style="width: 160px; height: 21px">
                        <input id="txttlop" runat="server" style="position: relative" type="text" /></td>
                </tr>
                <tr>
                    <td style="width: 82px">
                        Điểm:</td>
                    <td colspan="2" style="width: 160px">
                        <input id="txttdiem" runat="server" style="position: relative" type="text" /></td>
                </tr>
                <tr>
                    <td style="width: 82px">
                        Môn</td>
                    <td colspan="2" style="width: 160px">
                        <input id="txttmon" runat="server" style="position: relative" type="text" /></td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>

⌨️ 快捷键说明

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