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

📄 capnhat.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 string a = "";
    protected void Page_Load(object sender, EventArgs e)
    {

       
        if (Session["Capnhat"] != null)
        {
            a = Session["mssv"].ToString();
            if (!IsPostBack)
            {
                lbkq.Text = "Chào, bạn đang " + Session["Capnhat"].ToString() + " dữ liệu";
                if (a == Session["mssv"].ToString())
                {
                    txttmssv.Value = a;
                    txtthten.Value = Session["hten"].ToString();
                    txttlop.Value = Session["lop"].ToString();
                    txttdiem.Value = Session["diem"].ToString();
                    txttmon.Value = Session["mon"].ToString();                 
                }
            }
        }
        else
            Response.Redirect("Login.aspx");
    }

    protected void btsua_Click(object sender, EventArgs e)
    {
        string strCurrentPath = Request.PhysicalPath;
        string strXMLPath = strCurrentPath.Substring(0, strCurrentPath.LastIndexOf("\\"))
                            + "\\QuanLySinhVien.xml";
        XmlDocument doc = new XmlDocument();
        doc.Load(strXMLPath);
        XmlNodeList mssv, tho, lop, diem, monhoc;
        mssv = doc.DocumentElement.SelectNodes("//SVien/MSSV");
        tho = doc.DocumentElement.SelectNodes("//SVien/HoTen");
        lop = doc.DocumentElement.SelectNodes("//Lop/Ten");
        diem = doc.DocumentElement.SelectNodes("//Diem/DiemThi");
        monhoc = doc.DocumentElement.SelectNodes("//Diem/MonHocID");
        int co = 0;
        for (int i = 0; i < tho.Count; i++)
        {
            if (a== mssv[i].FirstChild.Value&&co==0)
            { co++;
                mssv[i].FirstChild.Value = txttmssv.Value;
                tho[i].FirstChild.Value = txtthten.Value;
                lop[0].FirstChild.Value = txttlop.Value;
                diem[i].FirstChild.Value = txttdiem.Value;
                monhoc[i].FirstChild.Value = txttmon.Value;
                lbkq.Text = "Ban da cap nhat thanh cong";
                doc.Save(strXMLPath);
            }           
        }
    }
</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 /><br /><br /><br />
        <table border="0" style="z-index: 103; left: 6px; position: relative; top: -47px">
            <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: 23px">
                    Lớp:</td>
                <td colspan="2" style="width: 160px; height: 23px">
                    <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; height: 26px;">
                    Môn:</td>
                <td colspan="2" style="width: 160px; height: 26px;">
                    <input id="txttmon" runat="server" style="position: relative" type="text" /></td>
            </tr>
        </table>
        <asp:Button ID="Button1" runat="server" OnClick="btsua_Click" Style="z-index: 102;
            left: 14px; position: relative; top: -35px" Text="Sửa" /></div>
    </form>
</body>
</html>

⌨️ 快捷键说明

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