資源簡介
這個是基于aspx做的簡單的手機銷售管理系統,里面含有完整的代碼,適合初學者使用,對于入門有很大促進作用

代碼片段和文件信息
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;??//加上這一行
public?partial?class?Edit?:?System.Web.UI.Page
{
????protected?void?Page_Load(object?sender?EventArgs?e)
????{
????????if?(Session[“ukind“]?==?“管理員“)
????????{
????????????if?(!IsPostBack)??//回訪不執行(本頁用不到,因為沒有回訪操作)
????????????{
????????????????this.Bind();
????????????}
????????}
????????else
????????{
????????????Response.Redirect(“Login.aspx“);
????????}
????}
????///?
????///?為?GridView1?綁定數據源
????///?
????protected?void?Bind()
????{
????????string?strConn?=?System.Configuration.ConfigurationManager.AppSettings[“strConn“];
????????SqlConnection?cn?=?new?SqlConnection(strConn);
????????cn.Open();
????????SqlCommand?cm?=?new?SqlCommand(“SELECT?*?FROM?Phones?ORDER?BY?Bcode“?cn);
????????SqlDataReader?dr?=?cm.ExecuteReader();
????????GridView1.DataSource?=?dr;
????????GridView1.DataKeyNames?=?new?string[]?{?“Bcode“?};?//將?Bcode?字段設為GridView1的主鍵
????????GridView1.DataBind();
????????dr.Close();
????????cn.Close();
????}
????protected?void?GridView1_RowEditing(object?sender?GridViewEditEventArgs?e)
????{
????????GridView1.EditIndex?=?e.NewEditIndex;?//e.NewEditIndex傳過來的是行號(從0開始)
????????Bind();?//設置了編輯行后再綁定
????}
????protected?void?GridView1_RowCancelingEdit(object?sender?GridViewCancelEditEventArgs?e)
????{
????????GridView1.EditIndex?=?-1;
????????Bind();
????}
????protected?void?GridView1_RowUpdating(object?sender?GridViewUpdateEventArgs?e)
????{
????????string?strConn?=?System.Configuration.ConfigurationManager.AppSettings[“strConn“];
????????SqlConnection?cn?=?new?SqlConnection(strConn);
????????cn.Open();
????????//構造查詢字符串
????????string?sqlBcode?=?“UPDATE?Phones?SET?[Bcode]=‘“
?????????????????????+?((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim()?//
?????????????????????+?“‘“
?????????????????????+?“?WHERE?Bcode=“
?????????????????????+?GridView1.DataKeys[e.RowIndex].Value;?//獲取?GridView1?的主鍵值
????????string?sqlPName?=?“UPDATE?Phones?SET?[PName]=‘“
?????????????????????+?((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim()?//
?????????????????????+?“‘“
?????????????????????+?“?WHERE?Bcode=“
?????????????????????+?GridView1.DataKeys[e.RowIndex].Value;?//獲取?GridView1?的主鍵值
????????string?sqlPrice?=?“UPDATE?Phones?SET?[Price]=‘“
?????????????????????+?((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim()?//
?????????????????????+?“‘“
?????????????????????+?“?WHERE?Bcode=“
?????????????????????+?GridView1.DataKeys[e.RowIndex].Value;?//獲取?GridView1?的主鍵值
????????string?sqlBrand?=?“UPDATE?Phones?SET?[Brand]=‘“
?????????????????????+?((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim()?//
?????????????????????+?“‘“
?????????????????????+?“?W
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2185??2012-12-19?21:18??iPhone\Edit.aspx
?????文件???????5203??2012-12-19?21:18??iPhone\Edit.aspx.cs
?????文件??????35845??2012-12-18?15:34??iPhone\images\login.jpg
?????文件??????21440??2012-12-18?16:06??iPhone\images\logo.jpg
?????文件??????46685??2012-12-18?15:50??iPhone\images\X.jpg
?????文件??????13321??2012-12-18?15:49??iPhone\images\Y.jpg
?????文件??????27648??2012-12-20?21:44??iPhone\iPhone\bin\iPhone.dll
?????文件??????44544??2012-12-20?21:44??iPhone\iPhone\bin\iPhone.pdb
?????文件???????1005??2012-12-20?21:14??iPhone\iPhone\Content\Site.css
?????文件????????180??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件????????178??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件????????120??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件????????105??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件????????111??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件????????110??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件????????119??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件????????101??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件???????4369??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件???????4369??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件???????4369??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件???????4369??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件???????4369??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件??????39084??2012-12-20?21:14??iPhone\iPhone\Content\themes\ba
?????文件????????340??2012-12-20?21:15??iPhone\iPhone\Controllers\HomeController.cs
?????文件???????1378??2012-12-20?21:56??iPhone\iPhone\Controllers\UserController.cs
?????文件?????????98??2012-12-20?21:14??iPhone\iPhone\Global.asax
?????文件???????1183??2012-12-20?21:14??iPhone\iPhone\Global.asax.cs
?????文件???????8132??2012-12-20?21:56??iPhone\iPhone\iPhone.csproj
?????文件???????1087??2012-12-20?21:56??iPhone\iPhone\iPhone.csproj.user
?????文件??????31919??2012-12-20?21:21??iPhone\iPhone\Models\iphone.Designer.cs
............此處省略71個文件信息
評論
共有 條評論