classDB.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:7k
源码类别:
Email客户端
开发平台:
Visual C++
- /********************************************************************************
- ** 作者:ebDoing
- ** 创始时间: 2008-10-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();
- }
- }
- }