熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

連鎖中心配送系統:連鎖店信息查看[2]

2013-11-13 11:08:35  來源: .NET編程 
    ——此文章摘自《ASPNET +SQL Server網絡應用系統開發案例精解》定價 特價 詳細>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave>

                       </TR>
                       </TABLE>
             </FONT>
             </TD>
    </TR>
    </TABLE>
    <uc:stfooter id=STFooter runat=server></uc:stfooter>

    .STUserDepaspxcs的主要代碼及其解釋

    STUserDepaspxcs主要代碼實現了查看自己連鎖店信息的功能頁面進行初始化時通過調用BindGrid()方法來從數據庫中獲取連鎖店信息填充DataGrid控件主要代碼如下
    private void Page_Load(object sender SystemEventArgs e)
    {
             if(Session[STNickName] != null)
             {
                       //獲得數據庫連接字符串
                       string STconnection = ConfigurationSettingsAppSettings[strconnection];
                       //創建數據庫連接
                       STconn = new SqlConnection(STconnection);
                       if(!IsPostBack)
                       {
                                //自定義ST_DgBind()方法加載自己連鎖店的信息
                                BindGrid();
                       }
             }
             else
             {
                       ResponseRedirect(/Indexaspx);
             }
    }
    public void BindGrid()
    {
             STconnOpen();
             //創建查詢連鎖店信息的sql語句
             string STstrsql=select STDep* from STDepSTUser where STDepSTDepID = STUserSTDepID;
             //創建數據庫的SqlCommand對象
             SqlCommand STcmd = new SqlCommand(STstrsqlSTconn);
             //創建SqlCommand對象的ExecuteReader()方法用來讀取數據
             SqlDataReader STsdr = STcmdExecuteReader();
             while(STsdrRead())
             {
                       //將連鎖店ID保存到會話中
                       Session[STDepID] = STsdr[STDepID];
                       //STDepID文本框得到連鎖店ID
                       STDepIDText = Session[STDepID]ToString();
                       Session[STDepName] = STsdr[STDepName];
                       STDepNameText = Session[STDepName]ToString();
                       Session[STDepMaster] = STsdr[STDepMaster];
                       STDepMasterText = Session[STDepMaster]ToString();
                       Session[STDepInfo] = STsdr[STDepInfo];
                       STDepInfoText = Session[STDepInfo]ToString();
             }
    }

right>[http://developcsaicn/dotnet_ASP/htm>]  []  


From:http://tw.wingwit.com/Article/program/net/201311/15250.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.