• 大小: 539KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-10-27
  • 语言: C#
  • 标签: ASP.NET  

资源简介

这个是基于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\base\images\ui-bg_flat_0_aaaaaa_40x100.png

     文件        178  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-bg_flat_75_ffffff_40x100.png

     文件        120  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-bg_glass_55_fbf9ee_1x400.png

     文件        105  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-bg_glass_65_ffffff_1x400.png

     文件        111  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-bg_glass_75_dadada_1x400.png

     文件        110  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-bg_glass_75_e6e6e6_1x400.png

     文件        119  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-bg_glass_95_fef1ec_1x400.png

     文件        101  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-bg_highlight-soft_75_cccccc_1x100.png

     文件       4369  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-icons_222222_256x240.png

     文件       4369  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-icons_2e83ff_256x240.png

     文件       4369  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-icons_454545_256x240.png

     文件       4369  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-icons_888888_256x240.png

     文件       4369  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\images\ui-icons_cd0a0a_256x240.png

     文件      39084  2012-12-20 21:14  iPhone\iPhone\Content\themes\base\jquery-ui.css

     文件        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个文件信息

评论

共有 条评论