classDB.cs
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:7k
源码类别:

Email客户端

开发平台:

Visual C++

  1. /********************************************************************************
  2. ** 作者:ebDoing
  3. ** 创始时间: 2008-10-22
  4. ** 描述:
  5. **    主要用于后台订单处理,…
  6. ** 表:
  7. *********************************************************************************/
  8. using System;
  9. using System.Data;
  10. using System.Configuration;
  11. using System.Web;
  12. using System.Web.Security;
  13. using System.Web.UI;
  14. using System.Web.UI.WebControls;
  15. using System.Web.UI.WebControls.WebParts;
  16. using System.Web.UI.HtmlControls;
  17. using System.Data.SqlClient;
  18. /// <summary>
  19. /// classDB 的摘要说明
  20. /// </summary>
  21. public class classDB
  22. {
  23.     SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["CartConnectionString"].ConnectionString);
  24. public classDB()
  25. {
  26. //
  27. // TODO: 在此处添加构造函数逻辑
  28. //
  29. }
  30.     /// <summary>
  31.     /// 添加一个订单用户
  32.     /// </summary>
  33.     /// <param name="CID">用户</param>
  34.     /// <param name="OTotalNumber">订单是数量</param>
  35.     /// <param name="OtalalPrice">订单的总价格</param>
  36.     /// <returns></returns>
  37.     public int InsertUser(String CID, Int64 OTotalNumber, float OtalalPrice)
  38.     {
  39.         String I_CID = CID;
  40.         Int64 I_OTatalNumber = OTotalNumber;
  41.         float I_OtalalPrice = OtalalPrice;      
  42.         String SqlCmd = "Insert into OrderUser(CID,OTotalPrice,OTotalNumber,OState) Values('" + I_CID + "','" + I_OtalalPrice + "','" + I_OTatalNumber + "','" + 1 + "')";
  43.         SqlCommand cmd = new SqlCommand(SqlCmd, myConnection);
  44.         int Result = -1;
  45.         try
  46.         {
  47.             myConnection.Open();
  48.             Result = cmd.ExecuteNonQuery();
  49.         }
  50.         catch (SqlException ex)
  51.         {
  52.             throw (ex);
  53.         }
  54.         finally
  55.         {
  56.             myConnection.Close();
  57.         }
  58.         return Result;
  59.     }
  60.     /// <summary>
  61.     /// 插入订单
  62.     /// </summary>
  63.     /// <param name="CID">订单id号码</param>
  64.     /// <param name="QIName"></param>
  65.     /// <param name="QIZip"></param>
  66.     /// <param name="QIAddress"></param>
  67.     /// <param name="QIMobilePhone"></param>
  68.     /// <param name="QIHomePhone"></param>
  69.     /// <param name="QEMail"></param>
  70.     /// <returns></returns>
  71.     public int InsertOrderInformation(String CID, String QIName, String QIZip, String QIAddress, String QIMobilePhone, String QIHomePhone, String QEMail)
  72.     {
  73.         String I_CID = CID;
  74.         String I_QIName = QIName;
  75.         String I_QIZip = QIZip;
  76.         String I__QIAddress = QIAddress;
  77.         String I_QIMobilePhone = QIMobilePhone;
  78.         String I_QIHomePhone = QIHomePhone;
  79.         String I_QEMail = QEMail;
  80.         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";
  81.         SqlCommand cmd = new SqlCommand(SqlCmd, myConnection);
  82.         int Result = -1;
  83.         try
  84.         {
  85.             myConnection.Open();
  86.             Result = cmd.ExecuteNonQuery();
  87.         }
  88.         catch (SqlException ex)
  89.         {
  90.             throw (ex);
  91.         }
  92.         finally
  93.         {
  94.             myConnection.Close();
  95.         }
  96.         return Result;
  97.     }
  98.     /// <summary>
  99.     /// 得到订单id号码
  100.     /// </summary>
  101.     /// <returns></returns>
  102.     public int InfoOID()
  103.     {
  104.         String sqlCmd = "select top 1 OID from OrderUser order by OID desc";
  105.         SqlCommand cmd = new SqlCommand(sqlCmd, myConnection);
  106.         int OIDtmp = 0;
  107.         try
  108.         {
  109.             myConnection.Open();
  110.             SqlDataReader MyReader = cmd.ExecuteReader();
  111.             if (MyReader.Read())
  112.             {
  113.                 OIDtmp = MyReader.GetInt32(0);
  114.               
  115.             }
  116.             return OIDtmp;
  117.         }
  118.         catch (SqlException ex)
  119.         {
  120.             throw (ex);
  121.         }
  122.         finally
  123.         {
  124.             myConnection.Close();
  125.         }
  126.     }
  127.     public int CopypCart(String id)
  128.     {
  129.         Int32 Oid=InfoOID();
  130.         String tempid = id;
  131.         String sqlcmd = "insert into submitOrder (OId,GoodSID,Num,SumPrice)select " + Oid + ",GoodSID,Num,SumPrice from tb_ShopCart where MemberID='" + tempid + "'";
  132.         SqlCommand cmd = new SqlCommand(sqlcmd, myConnection);
  133.         try
  134.         {
  135.             myConnection.Open();
  136.             int nResult = -1;
  137.             nResult = cmd.ExecuteNonQuery();
  138.             return nResult;
  139.         }catch(SqlException er)
  140.         {
  141.             throw (er);
  142.         }
  143.         finally
  144.         {
  145.           myConnection.Close();
  146.         }
  147.     }
  148.     public int DeleteCart(String id)
  149.     {
  150.         String tempid = id;
  151.         String sqlcmd = "delete tb_ShopCart where Memberid="+id;
  152.         SqlCommand cmd = new SqlCommand(sqlcmd, myConnection);
  153.         try
  154.         {
  155.             myConnection.Open();
  156.             int nResult = -1;
  157.             nResult = cmd.ExecuteNonQuery();
  158.             return nResult;
  159.         }
  160.         catch (SqlException er)
  161.         {
  162.             throw (er);
  163.         }
  164.         finally
  165.         {
  166.             myConnection.Close();
  167.         }
  168.      
  169.      }
  170.      public int showOrder(String OID)
  171.      {
  172.          String S_OID = OID;
  173.          String sqlCmd = "select count(OID) from OrderUser where CID=" + S_OID;
  174.          SqlCommand cmd = new SqlCommand(sqlCmd, myConnection);
  175.          int OIDtmp = 0;
  176.          try
  177.          {
  178.              myConnection.Open();
  179.              SqlDataReader MyReader = cmd.ExecuteReader();
  180.              if (MyReader.Read())
  181.              {
  182.                  OIDtmp = MyReader.GetInt32(0);
  183.              }
  184.              return OIDtmp;
  185.          }
  186.          catch (SqlException ex)
  187.          {
  188.              throw (ex);
  189.          }
  190.          finally
  191.          {
  192.              myConnection.Close();
  193.          }
  194.      }
  195.      public int IsCartNO(String OID)
  196.      {
  197.          String S_OID = OID;
  198.          String sqlCmd = "select count(CartID) from tb_ShopCart where MemberID=" + S_OID;
  199.          SqlCommand cmd = new SqlCommand(sqlCmd, myConnection);
  200.          int OIDtmp = 0;
  201.          try
  202.          {
  203.              myConnection.Open();
  204.              SqlDataReader MyReader = cmd.ExecuteReader();
  205.              if (MyReader.Read())
  206.              {
  207.                  OIDtmp = MyReader.GetInt32(0);
  208.              }
  209.              return OIDtmp;
  210.          }
  211.          catch (SqlException ex)
  212.          {
  213.              throw (ex);
  214.          }
  215.          finally
  216.          {
  217.              myConnection.Close();
  218.          }
  219.      }
  220. }