توضیحات تکمیلی برنامه این هفته: (البته ممنون میشم در مشکلات برنامه نویسی کمک بفرمایید ....)
صفحه اولی که میاد به کاربر میگه اول لاگین بشین بعد وارد صفحات بعد بشین ، در واقع کار طراحی اولیه انجام میده:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form action="chk.aspx" method="get">
<table border=5% cellpadding=5% cellspacing=5%>
<tr>
<td>
username:<input type="text" name="usr" />
<br /><br />
password:<input type="password" name="psw" />
<br /><br />
<input type="submit" value="EnterForLogin" />
</td>
    
<td>
<img src="pic/images.jpg" />
</td>
</tr>
</table>
</form>
<br /><br />
<div>
          
<a href="adduser.aspx">برای ثبت نام اینجا کلیک کنید....ممنون</a>
</div>
<div>
<%
if (Request["msg"]!=null)
{
Response.Write(Request["msg"]);
}
%>
</div>
</body>
</html>
این قسمت که با نام chk هست میاد میبینه وقتی ثبت نام انجام دادی برو مثلا به جاهای دیگه :
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%
bool found = false;
try
{
string strcon, strformat;
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Request.PhysicalApplicationPath+"basket.mdb";
strformat = "Select * from tbluser";
OleDbConnection olcon = new OleDbConnection(strcon);
OleDbCommand olcom = new OleDbCommand(strformat, olcon);
OleDbDataReader olreader;
olcon.Open();
olreader = olcom.ExecuteReader();
while (olreader.Read())
{
if (olreader["uname"].ToString()==Request["usr"]&&olreader["upass"].ToString()==Request["psw"])
{
found = true;
Session["usr"] = Request["usr"];
Session["uid"] = olreader["uid"].ToString();
break;
}
}
olreader.Close();
olcon.Close();
}
catch (Exception ecp)
{
Response.Redirect("login.aspx?msg=" + ecp.Message);
}
if (found==true)
{
Session["log"] = "yes";
Response.Redirect("default.aspx");
}
else
{
Response.Redirect("login.aspx?msg=wrong username or password");
}
%>
این قسمت میاد طراحی اولیه اضافه کردن کاربران به لیست رو انجام میده:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>add user</title>
</head>
<body>
<form action="adduseropr.aspx" method="get">
<table>
<tr>
<td>
<input type="text" name="usr"/>
<br /><br />
<input type="password" name="psw" />
<br /><br />
<input type="submit" value="save" />
</td>
<td>
<img src="pic/index.jpg" style="width: 204px" />
</td>
</tr>
</table>
</form>
<div>
<%
if (Request["msg"]!=null)
{
Response.Write(Request["msg"]);
}
%>
</div>
</body>
</html>
قسمت پردازشی برای اینکه بیاد اطلاعات کاربرا رو به لیست اضافه کنه:
<%@ Page Language="C#" %>
<%@ Import Namespace ="System.Data.OleDb" %>
<%
try
{
string strcon, strformat;
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Request.PhysicalApplicationPath + "basket.mdb";
strformat = string.Format("Insert InTo tbluser (uname,upass) Values ('{0}','{1}')", Request["usr"], Request["psw"]);
OleDbConnection olcon = new OleDbConnection(strcon);
OleDbCommand olcom = new OleDbCommand(strformat, olcon);
olcon.Open();
olcom.ExecuteNonQuery();
olcon.Close();
}
catch (Exception ecp)
{
Response.Redirect("adduser.aspx?msg=" + ecp.Message);
}
Response.Redirect("login.aspx?msg=you are added ....login now!");
%>
صفحه default میاد اون لیستی از خریدا رو که داریم با زدن لینک مربوطه میفرسته به اون قسمت که اسمش group:
<%@ Page Language="C#" %>
<%
if (Session["log"]!="yes")
{
Response.Redirect("login.aspx?msg=you must first sign in");
}
else
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.MinValue);
}
%>
<html>
<body>
<table>
<tr>
<td>
<a href="group.aspx">سبد خرید</a>
</td>
                
<td>
<img src="pic/images1.jpg" />
</td>
</tr>
</table>
</body>
</html>
group اون دسته ای هست که میاد اطلاعات لیتس رو نمایش میده:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.OleDb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<div>
<table border=10% cellpadding =5% cellspacing=5%>
<tr>
<td>
نام گروه
</td>
<td>
آدرس
</td>
</tr>
<%
try
{
string strcon, strformat;
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Request.PhysicalApplicationPath+"basket.mdb";
strformat = "Select * from tblgroup";
OleDbConnection olcon = new OleDbConnection(strcon);
OleDbCommand olcom = new OleDbCommand(strformat, olcon);
OleDbDataReader olreader;
olcon.Open();
olreader = olcom.ExecuteReader();
while (olreader.Read())
{
Response.Write(string.Format("<tr><td>{1}</td><td><a href='product.aspx?gid={0}'>برو</a></td></tr>", olreader["gid"], olreader["gname"]));
}
olreader.Close();
olcon.Close();
}
catch (Exception ecp)
{
Response.Write(ecp.Message);
}
%>
</table>
</div>
</body>
</html>
در قسمت product میاد اون محصولاتی که مربوط به هر کدوم از سرلیستامون محسوب میشه در اینجا عنوان میکنه:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.OleDb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<table border=10% cellpadding=5% cellspacing=5%>
<tr>
<td>
کد کالا
</td>
<td>
نام کالا
</td>
<td>
قیمت
</td>
<td>
خرید
</td>
</tr>
<%
try
{
string strcon, strformat;
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Request.PhysicalApplicationPath+"basket.mdb";
strformat = string.Format("Select * from tblproduct Where gid={0}",Request["gid"]);
OleDbConnection olcon = new OleDbConnection(strcon);
OleDbCommand olcom = new OleDbCommand(strformat, olcon);
OleDbDataReader olreader;
olcon.Open();
olreader = olcom.ExecuteReader();
while (olreader.Read())
{
Response.Write(string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td><a href='addBasket.aspx?pid={0}'>اضافه به سبد</a></td></tr>\r\n", olreader["pid"], olreader["pname"], olreader["price"]));
}
olreader.Close();
olcon.Close();
}
catch (Exception ecp)
{
Response.Write(ecp.Message);
}
%>
</table>
</body>
</html>
در این قسمت به سبد خرید اضافه میکنه:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.OleDb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<%
try
{
if (Session["log"] != "yes")
Response.Redirect("login.aspx?msg= shoma login nashodid");
else
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.MinValue);
}
string strcon, strformat;
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Request.PhysicalApplicationPath+"basket.mdb";
strformat = string.Format("insert into tblbasket(uid,pid) values ({0},{1})",Session["uid"],Request["pid"]);
OleDbConnection olcon = new OleDbConnection(strcon);
OleDbCommand olcom = new OleDbCommand(strformat, olcon);
olcon.Open();
olcom.ExecuteNonQuery();
olcon.Close();
Response.Redirect("basket.aspx");
}
catch (Exception ecp)
{
Response.Write(ecp.Message);
}
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
</body>
</html>
در این قسمت وضعیت نهایی خرید رو نمایش میده:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.OleDb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>سبد شما</title>
</head>
<body>
<table border=10% cellpadding=5% cellspacing=5%>
<tr>
<td>
نام کالا
</td>
<td>
نوع کالا
</td>
<td>
قیمت
</td>
<td>
وضعیت خرید
</td>
</tr>
<%
try
{
string strcon, strformat;
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Request.PhysicalApplicationPath+"basket.mdb";
strformat = string.Format("Select * from query1 Where uid={0}",Session["uid"]);
OleDbConnection olcon = new OleDbConnection(strcon);
OleDbCommand olcom = new OleDbCommand(strformat, olcon);
OleDbDataReader olreader;
olcon.Open();
olreader = olcom.ExecuteReader();
while (olreader.Read())
{
Response.Write(string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>معلق</td></tr>\r\n", olreader["pname"], olreader["gname"], olreader["price"]));
}
olreader.Close();
olcon.Close();
}
catch (Exception ecp)
{
Response.Write(ecp.Message);
}
%>
</table>
<a href="group.aspx">برگشت برای خرید</a>
</body>
</html>
موفق باشین
"سوالی بود بفرمایین"
بااحترام
برنامه ای که کدش رو براتون شرح دادم:
http://s2.picofile.com/file/7181863973/group.zip.html
علاقه مندی ها (Bookmarks)