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

Email客户端

开发平台:

Visual C++

  1. /********************************************************************************
  2. ** 作者:ebDoing
  3. ** 创始时间: 2008-10-22
  4. ** 描述:
  5. **    主要用于购物车的信息处理,…
  6. *********************************************************************************/
  7. using System;
  8. using System.Data;
  9. using System.Configuration;
  10. using System.Web;
  11. using System.Web.Security;
  12. using System.Web.UI;
  13. using System.Web.UI.WebControls;
  14. using System.Web.UI.WebControls.WebParts;
  15. using System.Web.UI.HtmlControls;
  16. using System.Data.SqlClient;
  17. namespace ShopCart
  18. {
  19.     /// <summary>
  20.     /// UserInfoClass 的摘要说明
  21.     /// </summary>
  22.     public class UserInfoClass
  23.     {
  24.         DBClass dbObj = new DBClass();
  25.         public UserInfoClass()
  26.         {
  27.             //
  28.             // TODO: 在此处添加构造函数逻辑
  29.             //
  30.         }
  31.         /// <summary>
  32.         /// 返回合计总数的Ds
  33.         /// </summary>
  34.         /// <param name="P_Str_srcTable">信息表名</param>
  35.         /// <param name="P_Int_MemberID">员工编号</param>
  36.         /// <returns>返回合计总数的Ds</returns>
  37.         public DataSet ReturnTotalDs(int P_Int_MemberID, string P_Str_srcTable)
  38.         {
  39.             SqlConnection myConn = dbObj.GetConnection();
  40.             SqlCommand myCmd = new SqlCommand("Proc_TotalInfo", myConn);
  41.             myCmd.CommandType = CommandType.StoredProcedure;
  42.             //添加参数
  43.             SqlParameter MemberID = new SqlParameter("@MemberID", SqlDbType.BigInt, 8);
  44.             MemberID.Value = P_Int_MemberID;
  45.             myCmd.Parameters.Add(MemberID);
  46.             //执行过程
  47.             myConn.Open();
  48.             try
  49.             {
  50.                 myCmd.ExecuteNonQuery();
  51.             }
  52.             catch (Exception ex)
  53.             {
  54.                 throw (ex);
  55.             }
  56.             finally
  57.             {
  58.                 myCmd.Dispose();
  59.                 myConn.Close();
  60.             }
  61.             SqlDataAdapter da = new SqlDataAdapter(myCmd);
  62.             DataSet ds = new DataSet();
  63.             da.Fill(ds, P_Str_srcTable);
  64.             return ds;
  65.         }
  66.         public string VarStr(string sString, int nLeng)
  67.         {
  68.             int index = sString.IndexOf(".");
  69.             if (index == -1 || index + 2 >= sString.Length)
  70.                 return sString;
  71.             else
  72.                 return sString.Substring(0, (index + nLeng + 1));
  73.         }
  74.         public void SCIBind(string P_Str_srcTable, GridView gvName, int P_Int_MemberID)
  75.         {
  76.             SqlConnection myConn = dbObj.GetConnection();
  77.             SqlCommand myCmd = new SqlCommand("Proc_GetShopCart", myConn);
  78.             myCmd.CommandType = CommandType.StoredProcedure;
  79.             //添加参数
  80.             SqlParameter MemberID = new SqlParameter("@MemberID", SqlDbType.BigInt, 8);
  81.             MemberID.Value = P_Int_MemberID;
  82.             myCmd.Parameters.Add(MemberID);
  83.             //执行过程
  84.             myConn.Open();
  85.             try
  86.             {
  87.                 myCmd.ExecuteNonQuery();
  88.             }
  89.             catch (Exception ex)
  90.             {
  91.                 throw (ex);
  92.             }
  93.             finally
  94.             {
  95.                 myCmd.Dispose();
  96.                 myConn.Close();
  97.             }
  98.             SqlDataAdapter da = new SqlDataAdapter(myCmd);
  99.             DataSet ds = new DataSet();
  100.             da.Fill(ds, P_Str_srcTable);
  101.             gvName.DataSource = ds.Tables[P_Str_srcTable].DefaultView;
  102.             gvName.DataBind();
  103.         }
  104.         //**************************购物车**********************************************************
  105.         /// <summary>
  106.         /// 向购物车中添加信息
  107.         /// </summary>
  108.         /// <param name="P_Int_GoodsID">商品编号</param>
  109.         /// <param name="P_Flt_MemberPrice">会员价格</param>
  110.         /// <param name="P_Int_MemberID">会员编号</param>
  111.         public void AddShopCart(int P_Int_GoodsID, float P_Flt_MemberPrice, int P_Int_MemberID, float P_Flt_GoodsWeight)
  112.         {
  113.             SqlConnection myConn = dbObj.GetConnection();
  114.             SqlCommand myCmd = new SqlCommand("Proc_InsertShopCart", myConn);
  115.             myCmd.CommandType = CommandType.StoredProcedure;
  116.             //添加参数
  117.             SqlParameter GoodsID = new SqlParameter("@GoodsID", SqlDbType.BigInt, 8);
  118.             GoodsID.Value = P_Int_GoodsID;
  119.             myCmd.Parameters.Add(GoodsID);
  120.             //添加参数
  121.             SqlParameter MemberPrice = new SqlParameter("@MemberPrice", SqlDbType.Float, 8);
  122.             MemberPrice.Value = P_Flt_MemberPrice;
  123.             myCmd.Parameters.Add(MemberPrice);
  124.             //添加参数
  125.             SqlParameter MemberID = new SqlParameter("@MemberID", SqlDbType.BigInt, 8);
  126.             MemberID.Value = P_Int_MemberID;
  127.             myCmd.Parameters.Add(MemberID);
  128.             //添加参数
  129.             SqlParameter GoodsWeight = new SqlParameter("@GoodsWeight", SqlDbType.Float, 8);
  130.             GoodsWeight.Value = P_Flt_GoodsWeight;
  131.             myCmd.Parameters.Add(GoodsWeight);
  132.             //执行过程
  133.             myConn.Open();
  134.             try
  135.             {
  136.                 myCmd.ExecuteNonQuery();
  137.             }
  138.             catch (Exception ex)
  139.             {
  140.                 throw (ex);
  141.             }
  142.             finally
  143.             {
  144.                 myCmd.Dispose();
  145.                 myConn.Close();
  146.             }
  147.         }
  148.         /// <summary>
  149.         /// 删除购物车中的信息
  150.         /// </summary>
  151.         /// <param name="P_Int_MemberID">会员编号</param>
  152.         public void DeleteShopCart(int P_Int_MemberID)
  153.         {
  154.             SqlConnection myConn = dbObj.GetConnection();
  155.             SqlCommand myCmd = new SqlCommand("Proc_DeleteShopCart", myConn);
  156.             myCmd.CommandType = CommandType.StoredProcedure;
  157.             //添加参数
  158.             SqlParameter MemberID = new SqlParameter("@MemberID", SqlDbType.BigInt, 8);
  159.             MemberID.Value = P_Int_MemberID;
  160.             myCmd.Parameters.Add(MemberID);
  161.             //执行过程
  162.             myConn.Open();
  163.             try
  164.             {
  165.                 myCmd.ExecuteNonQuery();
  166.             }
  167.             catch (Exception ex)
  168.             {
  169.                 throw (ex);
  170.             }
  171.             finally
  172.             {
  173.                 myCmd.Dispose();
  174.                 myConn.Close();
  175.             }
  176.         }
  177.         /// <summary>
  178.         ///  删除指定购物车中的信息
  179.         /// </summary>
  180.         /// <param name="P_Int_MemberID">会员编号</param>
  181.         /// <param name="P_Int_CartID">商品编号</param>
  182.         public void DeleteShopCartByID(int P_Int_MemberID, int P_Int_CartID)
  183.         {
  184.             SqlConnection myConn = dbObj.GetConnection();
  185.             SqlCommand myCmd = new SqlCommand("Proc_DeleteSCByID", myConn);
  186.             myCmd.CommandType = CommandType.StoredProcedure;
  187.             //添加参数
  188.             SqlParameter MemberID = new SqlParameter("@MemberID", SqlDbType.BigInt, 8);
  189.             MemberID.Value = P_Int_MemberID;
  190.             myCmd.Parameters.Add(MemberID);
  191.             //添加参数
  192.             SqlParameter CartID = new SqlParameter("@CartID", SqlDbType.BigInt, 8);
  193.             CartID.Value = P_Int_CartID;
  194.             myCmd.Parameters.Add(CartID);
  195.             //执行过程
  196.             myConn.Open();
  197.             try
  198.             {
  199.                 myCmd.ExecuteNonQuery();
  200.             }
  201.             catch (Exception ex)
  202.             {
  203.                 throw (ex);
  204.             }
  205.             finally
  206.             {
  207.                 myCmd.Dispose();
  208.                 myConn.Close();
  209.             }
  210.         }
  211.         /// <summary>
  212.         /// 当购物车中商品数量改变时,修改购物车中的信息
  213.         /// </summary>
  214.         /// <param name="P_Int_MemberID">会员ID号</param>
  215.         /// <param name="P_Int_CartID">商品编号</param>
  216.         /// <param name="P_Int_Num">商品数量</param>
  217.         public void UpdateSCI(int P_Int_MemberID, int P_Int_CartID, int P_Int_Num)
  218.         {
  219.             SqlConnection myConn = dbObj.GetConnection();
  220.             SqlCommand myCmd = new SqlCommand("Proc_UpdateSC", myConn);
  221.             myCmd.CommandType = CommandType.StoredProcedure;
  222.             //添加参数
  223.             SqlParameter MemberID = new SqlParameter("@MemberID", SqlDbType.BigInt, 8);
  224.             MemberID.Value = P_Int_MemberID;
  225.             myCmd.Parameters.Add(MemberID);
  226.             //添加参数
  227.             SqlParameter CartID = new SqlParameter("@CartID", SqlDbType.BigInt, 8);
  228.             CartID.Value = P_Int_CartID;
  229.             myCmd.Parameters.Add(CartID);
  230.             //添加参数
  231.             SqlParameter Num = new SqlParameter("@Num", SqlDbType.BigInt, 8);
  232.             Num.Value = P_Int_Num;
  233.             myCmd.Parameters.Add(Num);
  234.             //执行过程
  235.             myConn.Open();
  236.             try
  237.             {
  238.                 myCmd.ExecuteNonQuery();
  239.             }
  240.             catch (Exception ex)
  241.             {
  242.                 throw (ex);
  243.             }
  244.             finally
  245.             {
  246.                 myCmd.Dispose();
  247.                 myConn.Close();
  248.             }
  249.         }
  250.         public void DGIBind(int P_Int_Deplay, string P_Str_srcTable, DataList DLName)
  251.         {
  252.             SqlConnection myConn = dbObj.GetConnection();
  253.             SqlCommand myCmd = new SqlCommand("Proc_DeplayGInfo", myConn);
  254.             myCmd.CommandType = CommandType.StoredProcedure;
  255.             //添加参数
  256.             SqlParameter Deplay = new SqlParameter("@Deplay", SqlDbType.Int, 4);
  257.             Deplay.Value = P_Int_Deplay;
  258.             myCmd.Parameters.Add(Deplay);
  259.             //执行过程
  260.             myConn.Open();
  261.             try
  262.             {
  263.                 myCmd.ExecuteNonQuery();
  264.             }
  265.             catch (Exception ex)
  266.             {
  267.                 throw (ex);
  268.             }
  269.             finally
  270.             {
  271.                 myCmd.Dispose();
  272.                 myConn.Close();
  273.             }
  274.             SqlDataAdapter da = new SqlDataAdapter(myCmd);
  275.             DataSet ds = new DataSet();
  276.             da.Fill(ds, P_Str_srcTable);
  277.             DLName.DataSource = ds.Tables[P_Str_srcTable].DefaultView;
  278.             DLName.DataBind();
  279.         }
  280.         /// <summary>
  281.         /// 以商品类别分类绑定商品信息
  282.         /// </summary>
  283.         /// <param name="P_Int_ClassID">商品类别编号</param>
  284.         /// <param name="P_Str_srcTable">表信息</param>
  285.         /// <param name="DLName">绑定控件名</param>
  286.         public void DCGIBind(int P_Int_ClassID, string P_Str_srcTable, DataList DLName)
  287.         {
  288.             SqlConnection myConn = dbObj.GetConnection();
  289.             SqlCommand myCmd = new SqlCommand("Proc_DeplayGIByC", myConn);
  290.             myCmd.CommandType = CommandType.StoredProcedure;
  291.             //添加参数
  292.             SqlParameter ClassID = new SqlParameter("@ClassID", SqlDbType.BigInt, 8);
  293.             ClassID.Value = P_Int_ClassID;
  294.             myCmd.Parameters.Add(ClassID);
  295.             //执行过程
  296.             myConn.Open();
  297.             try
  298.             {
  299.                 myCmd.ExecuteNonQuery();
  300.             }
  301.             catch (Exception ex)
  302.             {
  303.                 throw (ex);
  304.             }
  305.             finally
  306.             {
  307.                 myCmd.Dispose();
  308.                 myConn.Close();
  309.             }
  310.             SqlDataAdapter da = new SqlDataAdapter(myCmd);
  311.             DataSet ds = new DataSet();
  312.             da.Fill(ds, P_Str_srcTable);
  313.             DLName.DataSource = ds.Tables[P_Str_srcTable].DefaultView;
  314.             DLName.DataBind();
  315.         }
  316.     }
  317. }