⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classdb.cs

📁 天织在线购物网站完整源码及文档 本网站是一套基于Web2.0思想设计、采用asp.net2.0开发的社区门户产品。它同时也是一套Web2.0全面解决方案
💻 CS
字号:
/********************************************************************************
** 作者:高亮
** 创始时间: 2007-12-22
** 描述:
**    主要用于后台管理员添加商品,…
** 表:
*********************************************************************************/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

/// <summary>
/// classDB 的摘要说明
/// </summary>
public class classDB
{
    SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["CartConnectionString"].ConnectionString);
	public classDB()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    /// <summary>
    /// 添加一个订单用户
    /// </summary>
    /// <param name="CID">用户</param>
    /// <param name="OTotalNumber">订单是数量</param>
    /// <param name="OtalalPrice">订单的总价格</param>
    /// <returns></returns>
    public int InsertUser(String CID, Int64 OTotalNumber, float OtalalPrice)
    {

        String I_CID = CID;
        Int64 I_OTatalNumber = OTotalNumber;
        float I_OtalalPrice = OtalalPrice;      
        String SqlCmd = "Insert into OrderUser(CID,OTotalPrice,OTotalNumber,OState) Values('" + I_CID + "','" + I_OtalalPrice + "','" + I_OTatalNumber + "','" + 1 + "')";
        SqlCommand cmd = new SqlCommand(SqlCmd, myConnection);
        int Result = -1;
        try
        {
            myConnection.Open();
            Result = cmd.ExecuteNonQuery();
        }
        catch (SqlException ex)
        {
            throw (ex);
        }
        finally
        {
            myConnection.Close();
        }
        return Result;
    }
    /// <summary>
    /// 插入订单
    /// </summary>
    /// <param name="CID">订单id号码</param>
    /// <param name="QIName"></param>
    /// <param name="QIZip"></param>
    /// <param name="QIAddress"></param>
    /// <param name="QIMobilePhone"></param>
    /// <param name="QIHomePhone"></param>
    /// <param name="QEMail"></param>
    /// <returns></returns>
    public int InsertOrderInformation(String CID, String QIName, String QIZip, String QIAddress, String QIMobilePhone, String QIHomePhone, String QEMail)
    {
        String I_CID = CID;
        String I_QIName = QIName;
        String I_QIZip = QIZip;
        String I__QIAddress = QIAddress;
        String I_QIMobilePhone = QIMobilePhone;
        String I_QIHomePhone = QIHomePhone;
        String I_QEMail = QEMail;
        String SqlCmd = "update OrderInformation set CID='" + I_CID + "',QIName='" + I_QIName + "',QIZip='" + I_QIZip + "',QIAddress='" + I__QIAddress + "',QIMobilePhone='" + I_QIMobilePhone + "',QIHomePhone='"+I_QIHomePhone+"',QEMail='" + I_QEMail + "' where CID is null";
        SqlCommand cmd = new SqlCommand(SqlCmd, myConnection);
        int Result = -1;
        try
        {
            myConnection.Open();
            Result = cmd.ExecuteNonQuery();
        }
        catch (SqlException ex)
        {
            throw (ex);
        }
        finally
        {
            myConnection.Close();
        }
        return Result;
    }
    /// <summary>
    /// 得到订单id号码
    /// </summary>
    /// <returns></returns>
    public int InfoOID()
    {
        String sqlCmd = "select top 1 OID from OrderUser order by OID desc";
        SqlCommand cmd = new SqlCommand(sqlCmd, myConnection);
        int OIDtmp = 0;
        try
        {
            myConnection.Open();
            SqlDataReader MyReader = cmd.ExecuteReader();
            if (MyReader.Read())
            {
                OIDtmp = MyReader.GetInt32(0);
              
            }
            return OIDtmp;
        }
        catch (SqlException ex)
        {
            throw (ex);
        }
        finally
        {
            myConnection.Close();
        }
    }
    public int CopypCart(String id)
    {
        Int32 Oid=InfoOID();
        String tempid = id;
        String sqlcmd = "insert into submitOrder (OId,GoodSID,Num,SumPrice)select " + Oid + ",GoodSID,Num,SumPrice from tb_ShopCart where MemberID='" + tempid + "'";
        SqlCommand cmd = new SqlCommand(sqlcmd, myConnection);
        try
        {
            myConnection.Open();
            int nResult = -1;
            nResult = cmd.ExecuteNonQuery();
            return nResult;
        }catch(SqlException er)
        {
            throw (er);
        }
        finally
        {
          myConnection.Close();
        }
    }
    public int DeleteCart(String id)
    {
        String tempid = id;
        String sqlcmd = "delete tb_ShopCart where Memberid="+id;
        SqlCommand cmd = new SqlCommand(sqlcmd, myConnection);
        try
        {
            myConnection.Open();
            int nResult = -1;
            nResult = cmd.ExecuteNonQuery();
            return nResult;
        }
        catch (SqlException er)
        {
            throw (er);
        }
        finally
        {
            myConnection.Close();
        }
     
     }
     public int showOrder(String OID)
     {
         String S_OID = OID;
         String sqlCmd = "select count(OID) from OrderUser where CID=" + S_OID;
         SqlCommand cmd = new SqlCommand(sqlCmd, myConnection);
         int OIDtmp = 0;
         try
         {
             myConnection.Open();
             SqlDataReader MyReader = cmd.ExecuteReader();
             if (MyReader.Read())
             {
                 OIDtmp = MyReader.GetInt32(0);
             }
             return OIDtmp;
         }
         catch (SqlException ex)
         {
             throw (ex);
         }
         finally
         {
             myConnection.Close();
         }
     }
     public int IsCartNO(String OID)
     {
         String S_OID = OID;
         String sqlCmd = "select count(CartID) from tb_ShopCart where MemberID=" + S_OID;
         SqlCommand cmd = new SqlCommand(sqlCmd, myConnection);
         int OIDtmp = 0;
         try
         {
             myConnection.Open();
             SqlDataReader MyReader = cmd.ExecuteReader();
             if (MyReader.Read())
             {
                 OIDtmp = MyReader.GetInt32(0);
             }
             return OIDtmp;
         }
         catch (SqlException ex)
         {
             throw (ex);
         }
         finally
         {
             myConnection.Close();
         }
     }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -