0% found this document useful (0 votes)
4 views8 pages

Nguyenthithaovi 5278

The document contains code for a web application developed in C# using ASP.NET, including master pages, data handling, and user interface elements. It features a layout with a sidebar for navigation, a central content area for displaying products, and a login section. The application interacts with a SQL database to retrieve and display product information based on user selections.

Uploaded by

binhlethi759
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

Nguyenthithaovi 5278

The document contains code for a web application developed in C# using ASP.NET, including master pages, data handling, and user interface elements. It features a layout with a sidebar for navigation, a central content area for displaying products, and a login section. The application interacts with a SQL database to retrieve and display product information based on user selections.

Uploaded by

binhlethi759
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Họ và tên: Nguyễn Thị Thảo Vi

Mã sinh viên:29204665278

I.Site1.Master.
1. <%@ Master Language="C#" AutoEventWireup="true"
CodeBehind="Site1.master.cs" Inherits="nguyenthithaovi_5278.Site1" %>
2.
3. <!DOCTYPE html>
4.
5. <html>
6. <head runat="server">
7. <title></title>
8. <link href="StyleSheet1.css" rel="stylesheet" />
9. <asp:ContentPlaceHolder ID="head" runat="server">
10. </asp:ContentPlaceHolder>
11.</head>
12.<body>
13. <form id="form1" runat="server">
14. <div class="container" style="display:flex" >
15. <div class="left">
16. <div class="sidebar">
17. <asp:DataList ID="DataList1" runat="server">
18. <ItemTemplate>
19. <asp:LinkButton ID="LinkButton1" runat="server"
Text='<%# Eval("TenDM") %>' CommandArgument='<%# Eval("MaDM") %>'
OnClick="LinkButton1_Click"></asp:LinkButton>
20. </ItemTemplate>
21. </asp:DataList>
22. </div>
23. </div>
24. <div class="mid">
25. <asp:ContentPlaceHolder ID="ContentPlaceHolder1"
runat="server">
26. </asp:ContentPlaceHolder>
27. </div>
28. <div class="right">
29. <div class="login">
30. <b>ĐĂNG NHẬP HỆ THỐNG</b>
31. <br />
32. <label>Tên Đăng Nhập</label>
33. <input type="Text" />
34. <br />
35. <label>Mật Khẩu</label>
36. <input type="password" />
37. <br />
38. <label>
39. <input type="checkbox" />
40. Ghi Nhớ Mật Khẩu</label>
41. <br />
42. <br />
43. <button>Đăng Nhập</button>
44. </div>
45. </div>
46. </div>
47. </form>
48.</body>
49.</html>
II. Site1.Master.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace nguyenthithaovi_5278
{
public partial class Site1 : System.Web.UI.MasterPage
{
xuly kn = new xuly();
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack) return;
string q = "select* from DanhMuc";
try
{
this.DataList1.DataSource = kn.GetData(q);
this.DataList1.DataBind();
}
catch (SqlException ex)
{
Response.Write(ex.Message);

}
}

protected void LinkButton1_Click(object sender, EventArgs e)


{
string madm = ((LinkButton)sender).CommandArgument;
Context.Items["dm"] = madm;
Server.Transfer("mathang.aspx");
}
}
}

III.styleSheet1.css
.container{
display:flex;
border:2px solid red;
padding:10px;
}
.sidebar{
width:50%%;
border-right:5px solid red;
padding:20px;
}
.sidebar a{
display:block;
color:blue;
text-decoration:underline;
margin-bottom:5px;
}
.mid{
width:70%;
display:flex;
justify-content:space-around;
padding:5px;
text-align:center;
border:1px solid pink;
padding:10px;
}
.mid img{
width:100%;
height:auto;
}
.right{
width:10%;
border-left:1px solid red;
padding:10px;
}
.right input{
display:block;
margin-bottom:10px;
width: 96%;
padding:5px;
}
.right button{
padding:5px 10px;
}

IV.xuly.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

namespace nguyenthithaovi_5278
{
public class xuly
{
SqlConnection con;
private void connect()
{
con = new SqlConnection(@"Data Source=(LocalDB)\
MSSQLLocalDB;AttachDbFilename=D:\code\Nguyenthithaovidoancanhan-5278\
nguyenthithaovi-5278\nguyenthithaovi-5278\App_Data\Database1.mdf;Integrated
Security=True");
con.Open();
// thầy đểdấ u @ ở đâu Vi ?
}
private void close_connect()
{
if (con.State == ConnectionState.Open)
con.Close();
}
public DataTable GetData (string q)
{
DataTable dt = new DataTable();
try
{
connect();
SqlDataAdapter da = new SqlDataAdapter(q, con);
da.Fill(dt);
}
catch
{
dt = null;
}
finally
{
close_connect();
}
return dt ;
}
}
}

V.mathang.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"
AutoEventWireup="true" CodeBehind="mathang.aspx.cs"
Inherits="nguyenthithaovi_5278.mathang" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style>
.hinhsp{
width:150px;
height:180px;
margin-top:10px;
transition:0.5s;

}
.hinhsp:hover{
transform:scale(1.1);

}
.dongia{
color:red;
font-weight:600;
}
.main{
padding:10px;
}
.chitiet{
color:black;
background-color:blanchedalmond;
border:5px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<asp:DataList ID="DataList1" runat="server" RepeatColumns="4">
<ItemTemplate>
<div class="main"></div>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("TenHang")
%>'></asp:Label>
<br />
<asp:ImageButton ID="ImageButton1" runat="server" CommandArgument='<
%# Eval("MaHang") %>' ImageUrl='<%# "~/img/" + Eval ("HinhAnh") %>'
CssClass="hinhsp" />
<br />
<span class="dongia"> <%# Eval("DonGia","{0:0}") %></span>
<br />
<asp:LinkButton ID="LinkButton1" runat="server">Xem chi
tiết</asp:LinkButton>
</ItemTemplate>

</asp:DataList>
</asp:Content>

VI.mathang.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace nguyenthithaovi_5278
{
public partial class mathang : System.Web.UI.Page
{
xuly kn = new xuly();
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack) return;
string q = "select* from DanhMuc";
if (Context.Items["madm"] == null)
{
q = "select* from MatHang";
}
else
{
string dm = Context.Items["madm"].ToString();
q = "select* from MatHang where MaDM ='" + dm + "'";
}
try
{
this.DataList1.DataSource = kn.GetData(q);
this.DataList1.DataBind();
}
catch (SqlException ex)
{
Response.Write(ex.Message);

}
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
string mathang = ((ImageButton)sender).CommandArgument;
Context.Items["mh"] = mathang;
Server.Transfer("chitiet.aspx");
}
}
}

VII.chitiet.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"


AutoEventWireup="true" CodeBehind="chitiet.aspx.cs"
Inherits="nguyenthithaovi_5278.chitiet" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">


<style>
.sanpham{
width:250px;
height:auto;
margin-right:10px;
transition:0,5s;
}
.hinh{
transform:scale(1.1);
}
.tensp{
font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-
serif;
font-size:25px;
}
.gia{
color:red;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<div class="sanpham">
</div>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/img/" +
Eval("Hinh") %>' CssClass="hinh" />
<div>
<div class="item">
<div class="tensp">Tên Loại Truyện: <%# Eval("TenHang")
%></div>
<div class="gia">Giá:<%# Eval("DonGia") %></div>
<div class="thongtin">Thông Tin Loại Truyện:<%#Eval("MoTa")
%></div>
</div>
</div>
</ItemTemplate>

</asp:DataList>
</asp:Content>
VIII.chitiet.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace nguyenthithaovi_5278
{
public partial class chitiet : System.Web.UI.Page
{
xuly kn = new xuly();
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack) return;
string q;
if (Context.Items["dm"] == null)
{
q = "select* from MatHang";
}
else
{
string dm = Context.Items["dm"].ToString();
q = "select* from MatHang where MaHang ='" + dm + "'";
}
try
{
this.DataList1.DataSource = kn.GetData(q);
this.DataList1.DataBind();
}
catch (SqlException ex)
{
Response.Write(ex.Message);

}
}
}
}

IX.Giao diện

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy