China Industrial Network. E-commerce shopping center system. Emall

xiaoxiao2021-03-05  26

/// China Industrial Network. E-commerce shopping center system.emall /// demo address: http://emall.12986.com/// 中国 商商 网 - http://www.12986.com /// Copyright ( c) 1998-2005 /// author: Dili JF Senders /// technical support: If any technical issues, please go to the China Business network consulting technical support web site: http: //cs.12986.com/using System; using System. Data; using system.drawing; using system.web; usbcontrols; using system.web.ui.htmlcontrols; using system.data.sqlclient; Namespace Emall {////// Pub's summary description .

/// public class Pub {// database utility variable public SqlConnection SqlConnection1; public SqlCommand SqlCommand1; public SqlDataAdapter SqlDataAdapter1; public SqlDataAdapter SqlDataAdapter2; public SqlDataReader SqlDataReader1; public SqlCommandBuilder SqlCommandBuilder1; public DataSet DataSet1; public DataTable DataTable1; public DataRow DataRow1; // non-public database variables public string LoginName; // login user public string SiteName = System.Configuration.ConfigurationSettings.AppSettings [ "SiteName"]; // site name public string SiteNav; // site navigation public string sTitle = System.Configuration.ConfigurationSettings .Appsettings ["sitename"]; // Site Title // Page Navigation Public INT PageSize = 5; // Each page Display Record Public Int Recordcount, PAGLIC PUB () {// // Todo: here Add constructor logic //} // 0. ------------------ General operation ---------------------- Public vid Navinfo (String Smsg, String SMSGURL, STRING SMSGTARGET) {Stitle = Stitle "-" SMSG; Sitenav = " SiteName " ";} // 1. ---------------------------------------------------------------------------------------------------------------------------------------------------- Database operation -------------------- /// // / / connection open /// public void connopen () {sqlConnection1 = new SqlConnection (System.Configuration. ConfigurationSettings.AppSettings ["conn"]); SqlConnection1.Open ();} // /// Connectation (previously clear DateSet1 in Dateset1) /// public void connclose () {if (dataset1! =

NULL) {DataSet1.clear ();} if (SqlConnection1! = null) {SQLConnection1.close ();}} // / /// Establish a DataSet object, populate or architecture (if necessary) DataSet object, dataset Is data in memory /// / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /, );} // /// Reference stored procedure configuration DataSet //// // ////////bit (STRING SP) () (SQLDATAADAPTER1 = New SqlDataAdapter (sp, sqlconnection1); dataset1 = new DataSet (); sqldataadapter1.fill (DataSet1);} // /// Establish a DataSet object, use the record padding or architecture (if necessary) DataSet object, DataSet is the data in memory /// / / The name of the source table of the table /// Open the table SQL statement public void Fill (String Ta Blename, String SQL) {connopen (); sqldataadapter1 = new SqlDataAdapter (SQL, SqlConnection1); DataSet1 = New DataSet (); SqlDataAdapter1.fill (Dataset1, Tablename);} /// // Give DataSet object Add a map ///// sql statement public void filladd (String SSQL) {SqlDataAdapter1 = New SqlDataAdapter (SSQL, SqlConnection1); SqlDataAdapter1.fill (Dataset1);} //// Give DataSet Object Add Multi-enabled table /// /// sql statement public void film (String Tablename, String SSQL) {SqlDataAdapter1 = New SqlDataAdapter (SSQL, SqlConnection1);

SqlDataAdapter1.fill (Dataset1, Tablename);} /// ///////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// String Skey; String SSQL = "SELECT TOP 1 " FID " from " Tablename " ORDER BY " FID " DESC "; if (GetRowcount (SSQL) == 0) {SKEY =" 1 ";} else {GetRecord (SSQL); SKEY = (int.Parse (DATAROW1 [FID] .tostring ()) 1) .tostring (); // Get database table key value} return SKEY;} // // Get a collection table collection included in the DataSet object INDEX is 0 MMS / / / / / SQL statement public void gettable (string ssql) {Fill (SSQL); DataTable1 = dataset1.tables [0];} /// // / The table record number of statements / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / {Int count = dataset1.tables [0] .Rows.count; connclose (); return count;} catCH};}} /// /////////////////bit 0; One line of data /// / / / / / / / / / / / / / / / / / / / / / / / / / (/)

} // / / / Execute the transact-sql statement, perform insert, modify, delete the database ///////////////////////////// ' (SSQL, SqlConnection1); sqlcommand1.executenonury (); sqlcommand1.dispose ();} // 2. ------------------ Binding control ------ ---------------- /// /// bind the DataGrid control and display data /// /// Sql statement /// DataGrid control id value public void BindDataGrid (string sSQL , DataGrid DataGrid1) {Fill (SSQL); DataGrid1.datasource = Dataset1.Tables [0] .defaultView; DataGrid1.database ();} // /// Bind DataList control and display data ///// SQL Statement /// DataList control ID value public void binddatalist (String SSQL, Datalist Datalist1) {Fill (SSQL); DATALIST1.DATASOURCE = DataSet1.tables [0] .defaultView; DataList1.DatabaseD ();} /// /// Bind the Repeater control and display the number // /// SQL statement /// REPEATER control ID value Public void bindrepeater (String SSQL, Repeater Repeater1) {Fill (SSQL); Repeater1.DataSource = DataSet1.tables [0 ] .Defaultview; reteater1.databind ();} // 3. ------------------ Operation business ------------- ------- // /// Returns the current user's shopping cart ID //// Returns the current user's shopping cart ID public string getshoppingcartId () {system.web.httpContext context = system.Web. HTTPCONTEXT.CURRENT; // If the user has logged in to the system after verifying, then the user's Customerid is used as the shopping cart id if (Context.usend.Identity.Name! = ") {Return context.user.Identity.name ;

} / / Otherwise, if the browser cookie has been assigned to the user a shopping cart id if (Context.Request.Cookies ["ShoppingCartID"]! = Null) {return context.request.cookies ["ShoppingCartID"]. Value; } Else {// generate a random GUID (global unique identification number) guid tempcartid = guid.newguid (); // back to write to the cookie specified by the client ["ShoppingCartID"] .Value = Tempcartid.toString (); // simultaneously returns TempCartId Return TempcartId.toString ();}} //// /////////////////////////// ////////////////////////////////////////////////////// ; SqlCommand1 = new SqlCommand ( "spNewsList", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlDataReader result = SqlCommand1.ExecuteReader (CommandBehavior.CloseConnection); return result;} /// /// user login /// /// /// email when the corresponding password login /// public String spCustomersLogin (string sEmail, string sPassword) {ConnOpen (); SqlCommand1 = new SqlCommand ( "spCustomersLogin", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Param1 = new SqlParameter ( "@ Email", SqlDbType.VarChar, 100); SqlParameter Param2 = new SqlParameter ( "@ Password", SqlDbType.VarChar, 50); SqlParameter Param3 = new SqlParameter ( "@ ID ", Sqldbtype.int, 4); sqlcommand1.parameters.add (param1);

SqlCommand1.Parameters.Add (Param2); SqlCommand1.Parameters.Add (Param3); Param1.Value = sEmail; Param2.Value = sPassword; Param3.Direction = ParameterDirection.Output; SqlCommand1.ExecuteNonQuery (); int ID = (int) (Param3.value); if (id == 0) Return null; else returnid.tostring ();} ///// Update password //// Login Email /// The corresponding password new password /// /// public String spCustomersUpdatePassword (string sEmail, string sPassword, string sPasswordNew) {ConnOpen (); SqlCommand1 = new SqlCommand ( "spCustomersUpdatePassword", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Param1 = New SqlParameter ("@ email", SqldbType.varchar, 100); SqlParameter Param2 = New Sqlparameter ("@ passwordold", sqldbtype.varchar, 50); SQLParameter PA ram3 = new SqlParameter ( "@ PasswordNew", SqlDbType.VarChar, 50); SqlParameter Param4 = new SqlParameter ( "@ Result", SqlDbType.VarChar, 100); SqlCommand1.Parameters.Add (Param1); SqlCommand1.Parameters.Add ( param2); SqlCommand1.Parameters.Add (Param3); SqlCommand1.Parameters.Add (param4); Param1.Value = sEmail; Param2.Value = sPassword; Param3.Value = sPasswordNew; Param4.Direction = ParameterDirection.Output; SqlCommand1.ExecuteNonQuery (); Return param4.value.tostring ();

} // /// Get product list // /// query field value, such as item number or product name, etc. / Press the product classification value /// true / false: Press the specified query field value / Press the product classification /// PUBLIC SqlDataReader spProductsSearch (string sStr, bool T) {ConnOpen (); SqlCommand1 = new SqlCommand ( "spProductsSearch", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Para1 = new SqlParameter ( "@ Search", SqlDbType.VarChar, 255 ); SQLParameter Para2 = New SQLParameter ("@searchtype", sqldbtype.bit, 1); sqlcommand1.parameters.add (para1); sqlcommand1.parameters.add (para2); para1.value = sstr; para2.value = t; SqlDataReader Result = SQLCOMMAND1.EXECUTEREADER (Commandbehavior.CloseConnection); return result;} // / / Number of items /// // // // // // // // // //> Specify Source field /// Additional Have specified product category /// Return to the most Top number Product list public SqlDataReader SPPRODUCTSTOP (S tring Top, string OrderBy, string CategoryID) {ConnOpen (); SqlCommand1 = new SqlCommand ( "spProductsTop", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Para1 = new SqlParameter ( "@ Top", SqlDbType.VarChar, 25 ); SqlParameter Para2 = new SqlParameter ( "@ OrderBy", SqlDbType.VarChar, 50); SqlParameter Para3 = new SqlParameter ( "@ CategoryID", SqlDbType.VarChar, 25); SqlCommand1.Parameters.Add (Para1); SqlCommand1.Parameters .Add (para2); sqlcommand1.parameters.add (Para3);

Para1.Value = Top; Para2.Value = OrderBy; Para3.Value = CategoryID; SqlDataReader result = SqlCommand1.ExecuteReader (CommandBehavior.CloseConnection); return result;} /// /// stored list of items of procedure SqlDataAdapter manner... All the specified designated OrderBy /// /// OrderBy public void spProductsAllOrderBy (string OrderBy) {ConnOpen (); SqlDataAdapter1 = new SqlDataAdapter ( "spProductsTop", SqlConnection1); SqlDataAdapter1.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter Para1 = new SqlParameter ( "@ Top", SqlDbType.VarChar, 25); SqlParameter Para2 = new SqlParameter ( "@ OrderBy", SqlDbType.VarChar, 50); SqlParameter Para3 = new SqlParameter ( "@ CategoryID", SqlDbType.VarChar, 25); Sqldataadapter1.selectCommand.Parameters.Add (Para1); SqlDataAdapter1.selectCommand.Parameters.Add (PARA2); SqlDataAdapter1.selectCommand.Paramet ERS.Add (Para3); Para1.Value = "100 percent"; Para2.Value = OrderBy; para 3.Value = "-100"; dataset1 = new dataset (); sqldataadapter1.fill (dataset1);} /// / / / Return to several links list /// // // // // // // // // ///> Specifying the number of records /// Returns a few links to the most Top list Public SqlDataReader SPCustomerstop (String Stop, string sorderby) {Connopen ); Sqlcommand1 = new sqlcommand ("spcustomerstop", sqlConnection1); sqlcommand1.commandtype = commandtype.storedProcedure;

SqlParameter Para1 = new SqlParameter ( "@ Top", SqlDbType.VarChar, 25); SqlParameter Para2 = new SqlParameter ( "@ ORDERBY", SqlDbType.VarChar, 50); SqlCommand1.Parameters.Add (Para1); SqlCommand1.Parameters.Add (Para2); Para1.Value = sTop; Para2.Value = sORDERBY; SqlDataReader result = SqlCommand1.ExecuteReader (CommandBehavior.CloseConnection); return result;} /// /// Gets the detailed item ID /// /// to view the details of the commodity ID /// returns public SqlDataReader spProductDetail (int ProductID) {ConnOpen (); SqlCommand1 = new SqlCommand ( "spProductDetail", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Para1 = new SqlParameter ( "@ ProductID ", SqldbType.int, 4); SQLCommand1.Parameters.add (Para1); Para1.Value = ProductId; SqlDataReader Result = SQLCommand1.executeReader (C ommandBehavior.CloseConnection); return result;} /// /// Gets a list of goods specified field type field type /// /// /// public SqlDataReader GetProductsOrderBy (string sFieldName) {ConnOpen ();. SqlCommand1 = new SqlCommand ( "GetProductsOrderBy", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Param1 = new SqlParameter ( "@ FieldName", SqlDbType.VarChar, 255); SqlCommand1.Parameters.Add (Param1); Param1.Value = sFieldName; SqlDataReader Result =

Sqlcommand1.executeReader (Commandbehavior.CloseConnection); returnrate;} /// // Display the record of the specified shopping cart ID //// ///////// PUBLIC SQLDATAREADER SPSHOPPINGCARTLIST (String ScartID) {connOpen (); SqlCommand1 = new SqlCommand ( "spShoppingCartList", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Param1 = new SqlParameter ( "@ cartID", SqlDbType.VarChar, 50); SqlCommand1.Parameters.Add (Param1); Param1.Value = ScartID; SqlDataReader Result = Sqlcommand1.ExecuteReader (Commandbehavior.CloseConne); returnrate;} /// // Get the total amount of the specified shopping cart ID ///// Shop ID /// Total amount Public Decimal SPSHOPPINGCartTotal (String scartID) {connopen (); sqlcommand1 = new sqlcommand ("spshoppingcarttotal", sqlConnection1); sqlcommand1.commandtype = co mmandType.StoredProcedure; SqlParameter Param1 = new SqlParameter ( "@ CartID", SqlDbType.VarChar, 50); SqlParameter Param2 = new SqlParameter ( "@ TotalCost", SqlDbType.Money, 8); SqlCommand1.Parameters.Add (Param1); SqlCommand1 .Parameters.Add (Param2); Param1.Value = sCartID; Param2.Direction = ParameterDirection.Output; SqlCommand1.ExecuteNonQuery (); (! Param2.Value.ToString () = "") if {return (decimal) Param2.Value Else {return 0;

}} /// // / Add the current product to the specified shopping cart /// // Shop ID /// ////// Product Quantity Public VoID SPSHOPPINGCARTDITEM (String ScartID, int iproductid, int iquantity) { ConnOpen (); SqlCommand1 = new SqlCommand ( "spShoppingCartAddItem", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Param1 = new SqlParameter ( "@ ProductID", SqlDbType.Int, 4); SqlParameter Param2 = new SqlParameter ( "@ cartID ", SqlDbType.VarChar, 50); SqlParameter Param3 = new SqlParameter (" @ Quantity ", SqlDbType.Int, 4); SqlCommand1.Parameters.Add (Param1); SqlCommand1.Parameters.Add (Param2); SqlCommand1.Parameters. Add (param3); param1.value = iproductid; param2.value = scartId; param3.value = iQuantity; sqlcommand1.executenonQuery ();} ///// Id /// Specify the product ID /// to update the number of public void spshoppingcartupdateQty (String ScartID, int iproductid, int iquantity) {if (iQuantity /// shopping cart. Delete selected //// / / Specify shopping cart ID / // designated item ID public void spShoppingCartRemoveItem (string sCartID, int iProductID) {ConnOpen (); SqlCommand1 = new SqlCommand ( "spShoppingCartRemoveItem", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Param1 = new SqlParameter ( "@ cartID" Sqldbtype.varchar, 50); sqlparameter param2 = new sqlparameter ("

@ProductID ", SqlDbType.Int, 4); SqlCommand1.Parameters.Add (Param1); SqlCommand1.Parameters.Add (Param2); Param1.Value = sCartID; Param2.Value = iProductID; SqlCommand1.ExecuteNonQuery ();} // / / / / Truck confirmation as an order // // Specify customer ID /// Specify shopping cart ID /// Add Note Description / // Return the generated order ID to the customer public int spotersInsert (int icrid, string sCartID, string sMemo) {ConnOpen (); SqlCommand1 = new SqlCommand ( "spOrdersInsert", SqlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Param1 = new SqlParameter ( "@ cartID", SqlDbType.VarChar, 50); SqlParameter param2 = new SqlParameter ( "@ CustomerID", SqlDbType.Int, 4); SqlParameter Param3 = new SqlParameter ( "@ Memo", SqlDbType.VarChar, 2000); SqlParameter param4 = new SqlParameter ( "@ OrderID", SqlDbType.Int, 4); sqlcommand1.parameters.ad d (Param1); SqlCommand1.Parameters.Add (Param2); SqlCommand1.Parameters.Add (Param3); SqlCommand1.Parameters.Add (Param4); Param1.Value = sCartID; Param2.Value = iCustomerID; Param3.Value = sMemo; Param4.direction = parameterdirection.output; sqlcommand1.executenonury (); return (int) param4.value;

} /// // Role: Go to another from a shopping cart to another /// / case: After the login or registration process is completed, transfer the temporary shopping cart to the user's shopping cart. // / /// ID /// original cart now cart ID public void spShoppingCartMigrate (String sOldCartId, String sNewCartId) {ConnOpen (); SqlCommand1 = new SqlCommand ( "spShoppingCartMigrate", SqlConnection1); SqlCommand1.CommandType = CommandType. StoredProcedure; SqlParameter Param1 = new SqlParameter ( "@ OldCartId", SqlDbType.VarChar, 50); SqlParameter Param2 = new SqlParameter ( "@ NewCartId", SqlDbType.VarChar, 50); SqlCommand1.Parameters.Add (Param1); SqlCommand1.Parameters .Add (param2); param1.value = SOLDCARTID; param2.value = snewcartid; sqlcommand1.executenonury ();} /// /// Empty shopping cart //// public void Emptycart (String scartID) {Connopen ); Sqlcommand1 = new sqlcommand ("ShoppingCartempty", S qlConnection1); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Param1 = new SqlParameter ( "@ CartID", SqlDbType.VarChar, 50); SqlCommand1.Parameters.Add (Param1); Param1.Value = sCartID; SqlCommand1.ExecuteNonQuery (); } // 4. ----------------------- Other practical processes / functions ----------------- ---------- /// // // Check the day before yesterday and the day /// // // // //////// // public string Checkdate (DateTime DT) {String SSTR; datetime = datetime.toDay; if (dt.date ==

转载请注明原文地址:https://www.9cbs.com/read-31803.html

New Post(0)