Post Job Free
Sign in

C# Web Ui

Location:
Da Nang, Vietnam
Posted:
June 19, 2025

Contact this candidate

Resume:

SAN PHAM

<%@ Page Title="" Language="C#" MasterPageFile Site1.Master" AutoEventWireup="true" CodeBehind="Sanpham.aspx.cs" Inherits="WebApplication1.Sanpham" %>

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

<style>

.hinhsp {

width: 100px;

height: 230px;

}

.main{

padding: 5px;

}

.gia{

color: red;

font-weight:600;

}

</style>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<asp:DataList ID="DataList1" runat="server" RepeatColumns="5">

<ItemTemplate>

<div class="main">

<asp:Image ID="Image1" runat="server" ImageUrl "~/img/" + Eval("HinhAnh") %>' CssClass="hinhsp" CommandArgument Eval("MaHang") %>' OnClick="ImageButton1_Click1"/>

<br />

<br />

Tên Sản Phẩm:

<asp:Label ID="Label1" runat="server" Text Eval("TenHang") asp:Label>

<br />

<span class="gia">

<%# Eval("DonGia", "{0:0}") %> VNĐ

</span>

<br />

<asp:Button ID="Button1" CssClass="btn" runat="server" Text="Xem Chi Tiết" />

</div>

</ItemTemplate>

</asp:DataList>

</asp:Content>

SAN PHAM 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;

using System.Data.SqlClient;

namespace WebApplication1

{

public partial class Sanpham : 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["mdm"] == null)

{

q = "select * from MatHang";

}

else

{

string madanhmuc = Context.Items["mdm"].ToString ;

q = "select * from MatHang where MaDM = '" + madanhmuc +

}

try

{

this.DataList1.DataSource = kn.GetData(q);

this.DataList1.DataBind ;

}

catch (SqlException ex)

{

Response.Write(ex.Message);

}

}

}

}

SITE 1

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="WebApplication1.Site1" %>

<!DOCTYPE html>

<html>

<head runat="server">

<title></title>

<asp:ContentPlaceHolder ID="head" runat="server">

</asp:ContentPlaceHolder>

<style>

.container {

width: 100%;

display: flex;

justify-content: space-around;

}

.left {

width: 20%;

}

.mid {

width: 50%;

}

.right {

width: 20%;

}

</style>

</head>

<body>

<form id="form1" runat="server">

<div class="container">

<div class="left">

<h2>DANH MỤC SẢN PHẨM </h2>

<asp:DataList ID="DataList1" runat="server">

<ItemTemplate>

<asp:LinkButton ID="LinkButton1" runat="server" Text Eval("TenDM") %>' CommandArgument Eval("MaDM") %>' OnClick="LinkButton1_Click1" />

</ItemTemplate>

</asp:DataList>

</div>

<div class="mid">

<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

</asp:ContentPlaceHolder>

</div>

<div class="right">

<div class="right_item div>

<b>So luong nguoi truy cap: </b>

<asp:Label ID="lblSoLuotTC" runat="server" Text="Label asp:Label>

</div>

</div>

</form>

</body>

</html>

SITE1 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;

using System.Data.SqlClient;

namespace WebApplication1

{

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);

}

if (Application["SoLuotTruycap"] != null)

{

lblSoLuotTC.Text = Application["SoLuotTruycap"].ToString ;

}

else

{

lblSoLuotTC.Text = "0";

}

}

protected void LinkButton1_Click1(object sender, EventArgs e)

{

string madanhmuc = ((LinkButton)sender).CommandArgument;

Context.Items["mdm"] = madanhmuc;

Server.Transfer("Sanpham.aspx");

}

}

}

XULY nhớ thay chuỗi

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Data;

using System.Data.SqlClient;

namespace WebApplication1

{

public class xuly

{

SqlConnection con;

private void connect {

con = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\IS 385 BF\D\WebApplication1\WebApplication1\App_Data\QLBH1.mdf; Integrated Security = True");

con.Open ;

}

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;

}

}

}



Contact this candidate