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

📄 mangerclass.cs

📁 对网上购物进行管理的网站。采用SQLSERVER创建后台数据库。可以将购买的商品存入购物车、提交订单、信息查询等。
💻 CS
📖 第 1 页 / 共 4 页
字号:
    /// <returns>商品类别的数据集</returns>
    public DataSet GetCategory( string P_Str_srcTable)
    {
        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_GetCategory", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //执行过程
        myConn.Open();
        myCmd.ExecuteNonQuery();
        SqlDataAdapter da = new SqlDataAdapter(myCmd);
        DataSet ds = new DataSet();
        da.Fill(ds, P_Str_srcTable);
        myCmd.Dispose();
        myConn.Dispose();
        return ds;
    }
    /// <summary>
    /// 删除指定商品的类别名
    /// </summary>
    /// <param name="P_Int_ClassID">类别编号</param>
    public void  DeleteCategory(int P_Int_ClassID)
    {
        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_DeleteCategory", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //添加参数
        SqlParameter ClassID = new SqlParameter("@ClassID", SqlDbType.BigInt, 8);
        ClassID.Value = P_Int_ClassID;
        myCmd.Parameters.Add(ClassID);
        //执行过程
        myConn.Open();
        try
        {
            myCmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw (ex);
        }
        finally
        {
            myCmd.Dispose();
            myConn.Close();

        }
    }


    /// <summary>
    /// 绑定商品类别名
    /// </summary>
    /// <param name="ddlName">绑定控件名</param>
    public void ddlClassBind(DropDownList ddlName)
    { 
        string P_Str_SqlStr = "select * from tb_Class";
        SqlConnection myConn = dbObj.GetConnection();
        SqlDataAdapter da = new SqlDataAdapter(P_Str_SqlStr, myConn);
        DataSet ds = new DataSet();
        da.Fill(ds, "Class");
        ddlName.DataSource = ds.Tables["Class"].DefaultView;
        ddlName.DataTextField = ds.Tables["Class"].Columns[1].ToString();
        ddlName.DataValueField = ds.Tables["Class"].Columns[0].ToString();
        ddlName.DataBind();

    }
    //*************************************************************************************************
    /// <summary>
    /// 绑定商品图像
    /// </summary>
    /// <param name="ddlName">绑定控件名</param>
    public void ddlUrl(DropDownList ddlName)
    {
        string P_Str_SqlStr = "select * from tb_Image";
        SqlConnection myConn = dbObj.GetConnection();
        SqlDataAdapter da = new SqlDataAdapter(P_Str_SqlStr, myConn);
        DataSet ds = new DataSet();
        da.Fill(ds, "Url");
        ddlName.DataSource = ds.Tables["Url"].DefaultView;
        ddlName.DataTextField = ds.Tables["Url"].Columns[1].ToString();
        ddlName.DataValueField = ds.Tables["Url"].Columns[2].ToString();
        ddlName.DataBind();
    }
    /// <summary>
    /// 添加商品信息
    /// </summary>
    /// <param name="P_Int_ClassID">商品编号</param>
    /// <param name="P_Str_GoodsName">商品名称</param>
    /// <param name="P_Str_GoodsIntroduce">商品描述</param>
    /// <param name="P_Str_GoodsBrand">商品品牌</param>
    /// <param name="P_Str_GoodsUnit">商品单位</param>
    /// <param name="P_Fl_GoodsWeight">商品重量</param>
    /// <param name="P_Str_GoodsUrl">商品图像</param>
    /// <param name="P_Fl_MarketPrice">商品市场价</param>
    /// <param name="P_Fl_MemberPrice">商品会员价</param>
    /// <param name="P_Bl_Isrefinement">是否是精品</param>
    /// <param name="P_Bl_IsHot">是否是热销商品</param>
    /// <param name="P_Bl_IsDiscount">是否是打折商品</param>
    /// <returns>返回一个值,判断商品是否存在</returns>
    public int AddGInfo(int P_Int_ClassID, string P_Str_GoodsName, string P_Str_GoodsIntroduce, string P_Str_GoodsBrand, string P_Str_GoodsUnit, float P_Flt_GoodsWeight, string P_Str_GoodsUrl, float P_Flt_MarketPrice, float P_Flt_MemberPrice, bool P_Bl_Isrefinement, bool P_Bl_IsHot, bool P_Bl_IsDiscount)
    {

        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_AddGoodsInfo", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //添加参数
        SqlParameter ClassID = new SqlParameter("@ClassID", SqlDbType.BigInt,8);
        ClassID.Value = P_Int_ClassID;
        myCmd.Parameters.Add(ClassID);
        //添加参数
        SqlParameter GoodsName = new SqlParameter("@GoodsName", SqlDbType.VarChar, 50);
        GoodsName.Value = P_Str_GoodsName;
        myCmd.Parameters.Add(GoodsName);
        //添加参数
        SqlParameter GoodsIntroduce = new SqlParameter("@GoodsIntroduce", SqlDbType.NText, 16);
        GoodsIntroduce.Value = P_Str_GoodsIntroduce;
        myCmd.Parameters.Add(GoodsIntroduce);
        //添加参数
        SqlParameter GoodsBrand = new SqlParameter("@GoodsBrand", SqlDbType.VarChar, 50);
        GoodsBrand.Value = P_Str_GoodsBrand;
        myCmd.Parameters.Add(GoodsBrand);
        //添加参数
        SqlParameter GoodsUnit = new SqlParameter("@GoodsUnit", SqlDbType.VarChar, 10);
        GoodsUnit.Value = P_Str_GoodsUnit;
        myCmd.Parameters.Add(GoodsUnit);
        //添加参数
        SqlParameter GoodsWeight = new SqlParameter("@GoodsWeight", SqlDbType.Float , 8);
        GoodsWeight.Value = P_Flt_GoodsWeight;
        myCmd.Parameters.Add(GoodsWeight);
        //添加参数
        SqlParameter GoodsUrl = new SqlParameter("@GoodsUrl", SqlDbType.VarChar, 50);
        GoodsUrl.Value = P_Str_GoodsUrl;
        myCmd.Parameters.Add(GoodsUrl);
        //添加参数
        SqlParameter MarketPrice = new SqlParameter("@MarketPrice", SqlDbType.Float , 8);
        MarketPrice.Value = P_Flt_MarketPrice;
        myCmd.Parameters.Add(MarketPrice);
        //添加参数
        SqlParameter MemberPrice = new SqlParameter("@MemberPrice", SqlDbType.Float, 8);
        MemberPrice.Value = P_Flt_MemberPrice;
        myCmd.Parameters.Add(MemberPrice);
        //添加参数
        SqlParameter Isrefinement = new SqlParameter("@Isrefinement", SqlDbType.Bit, 1);
        Isrefinement.Value = P_Bl_Isrefinement;
        myCmd.Parameters.Add(Isrefinement);
        //添加参数
        SqlParameter IsHot = new SqlParameter("@IsHot", SqlDbType.Bit, 1);
        IsHot.Value = P_Bl_IsHot;
        myCmd.Parameters.Add(IsHot);
        //添加参数
        SqlParameter IsDiscount = new SqlParameter("@IsDiscount", SqlDbType.Bit, 1);
        IsDiscount.Value = P_Bl_IsDiscount;
        myCmd.Parameters.Add(IsDiscount);
        //添加参数
        SqlParameter returnValue = myCmd.Parameters.Add("returnValue",SqlDbType.Int,4);
        returnValue.Direction = ParameterDirection.ReturnValue;
        //执行过程
        myConn.Open();
        try
        {
            myCmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw (ex);

        }
        finally
        {
            myCmd.Dispose();
            myConn.Close();
        }
        return Convert.ToInt32(returnValue.Value.ToString());

    }
    /// <summary>
    /// 获取商品信息的数据集
    /// </summary>
    /// <param name="P_Str_srcTable">商品信息表</param>
    /// <returns>返回商品信息的数据集</returns>
    public DataSet GetGoodsInfoDs(string P_Str_srcTable)
    {
        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_GetGoodsInfo", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //执行过程
        myConn.Open();
        myCmd.ExecuteNonQuery();
        SqlDataAdapter da = new SqlDataAdapter(myCmd);
        DataSet ds = new DataSet();
        da.Fill(ds, P_Str_srcTable);
        myCmd.Dispose();
        myConn.Dispose();
        return ds;
    }
    /// <summary>
    /// 获取指定商品信息的数据集
    /// </summary>
    /// <param name="P_Int_GoodsID">指定商品的ID</param>
    /// <param name="P_Str_srcTable">商品信息表</param>
    /// <returns>返回指定商品信息的数据集</returns>
    public DataSet GetGoodsInfoByIDDs(int P_Int_GoodsID,string P_Str_srcTable)
    {
        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_GetGoodsInfoByID", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //添加参数
        SqlParameter GoodsID = new SqlParameter("@GoodsID", SqlDbType.BigInt, 8);
        GoodsID.Value = P_Int_GoodsID;
        myCmd.Parameters.Add(GoodsID);
        //执行过程
        myConn.Open();
        myCmd.ExecuteNonQuery();
        SqlDataAdapter da = new SqlDataAdapter(myCmd);
        DataSet ds = new DataSet();
        da.Fill(ds, P_Str_srcTable);
        myCmd.Dispose();
        myConn.Dispose();
        return ds;
    }
    /// <summary>
    /// 获取搜索商品信息的数据集
    /// </summary>
    /// <param name="P_Str_srcTable">商品信息表</param>
    /// <param name="P_Str_keywords">搜索的关键字</param>
    /// <returns>返回搜索商品信息的数据集</returns>
    public DataSet SearchGoodsInfoDs(string P_Str_srcTable, string P_Str_keywords)
    {
        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_SearchGoodsInfo", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //添加参数
        SqlParameter keywords = new SqlParameter("@keywords", SqlDbType.VarChar, 50);
        keywords.Value = P_Str_keywords;
        myCmd.Parameters.Add(keywords);

        //执行过程
        myConn.Open();
        myCmd.ExecuteNonQuery();
        SqlDataAdapter da = new SqlDataAdapter(myCmd);
        DataSet ds = new DataSet();
        da.Fill(ds, P_Str_srcTable);
        myCmd.Dispose();
        myConn.Dispose();
        return ds;
    }
    /// <summary>
    /// 删除指定的商品信息
    /// </summary>
    /// <param name="P_Int_GoodsID">指定商品的编号</param>
    public void DeleteGoodsInfo(int P_Int_GoodsID)
    {
        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_DeleteGoodsInfo", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //添加参数
        SqlParameter GoodsID = new SqlParameter("@GoodsID", SqlDbType.BigInt, 8);
        GoodsID.Value = P_Int_GoodsID;
        myCmd.Parameters.Add(GoodsID);
        //执行过程
        myConn.Open();
        try
        {
            myCmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw (ex);
        }
        finally
        {
            myCmd.Dispose();
            myConn.Close();

        }
    }
    public void UpdateGInfo(int P_Int_ClassID, string P_Str_GoodsName, string P_Str_GoodsIntroduce, string P_Str_GoodsBrand, string P_Str_GoodsUnit, float P_Flt_GoodsWeight, string P_Str_GoodsUrl, float P_Flt_MarketPrice, float P_Flt_MemberPrice, bool P_Bl_Isrefinement, bool P_Bl_IsHot, bool P_Bl_IsDiscount, int P_Int_GoodsID)
    {

        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_UpdateGoodsInfo", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //添加参数
        SqlParameter ClassID = new SqlParameter("@ClassID", SqlDbType.BigInt, 8);
        ClassID.Value = P_Int_ClassID;
        myCmd.Parameters.Add(ClassID);
        //添加参数
        SqlParameter GoodsName = new SqlParameter("@GoodsName", SqlDbType.VarChar, 50);
        GoodsName.Value = P_Str_GoodsName;
        myCmd.Parameters.Add(GoodsName);
        //添加参数
        SqlParameter GoodsIntroduce = new SqlParameter("@GoodsIntroduce", SqlDbType.NText, 16);
        GoodsIntroduce.Value = P_Str_GoodsIntroduce;
        myCmd.Parameters.Add(GoodsIntroduce);
        //添加参数
        SqlParameter GoodsBrand = new SqlParameter("@GoodsBrand", SqlDbType.VarChar, 50);
        GoodsBrand.Value = P_Str_GoodsBrand;
        myCmd.Parameters.Add(GoodsBrand);
        //添加参数
        SqlParameter GoodsUnit = new SqlParameter("@GoodsUnit", SqlDbType.VarChar, 10);
        GoodsUnit.Value = P_Str_GoodsUnit;
        myCmd.Parameters.Add(GoodsUnit);
        //添加参数
        SqlParameter GoodsWeight = new SqlParameter("@GoodsWeight", SqlDbType.Float , 8);
        GoodsWeight.Value = P_Flt_GoodsWeight;
        myCmd.Parameters.Add(GoodsWeight);
        //添加参数
        SqlParameter GoodsUrl = new SqlParameter("@GoodsUrl", SqlDbType.VarChar, 50);
        GoodsUrl.Value = P_Str_GoodsUrl;
        myCmd.Parameters.Add(GoodsUrl);
        //添加参数
        SqlParameter MarketPrice = new SqlParameter("@MarketPrice", SqlDbType.Float , 8);
        MarketPrice.Value = P_Flt_MarketPrice;
        myCmd.Parameters.Add(MarketPrice);
        //添加参数
        SqlParameter MemberPrice = new SqlParameter("@MemberPrice", SqlDbType.Float , 8);
        MemberPrice.Value = P_Flt_MemberPrice;
        myCmd.Parameters.Add(MemberPrice);
        //添加参数
        SqlParameter Isrefinement = new SqlParameter("@Isrefinement", SqlDbType.Bit, 1);
        Isrefinement.Value = P_Bl_Isrefinement;
        myCmd.Parameters.Add(Isrefinement);
        //添加参数
        SqlParameter IsHot = new SqlParameter("@IsHot", SqlDbType.Bit, 1);
        IsHot.Value = P_Bl_IsHot;
        myCmd.Parameters.Add(IsHot);
        //添加参数
        SqlParameter IsDiscount = new SqlParameter("@IsDiscount", SqlDbType.Bit, 1);
        IsDiscount.Value = P_Bl_IsDiscount;
        myCmd.Parameters.Add(IsDiscount);
        //添加参数
        SqlParameter GoodsID = new SqlParameter("@GoodsID", SqlDbType.BigInt, 8);
        GoodsID.Value = P_Int_GoodsID;
        myCmd.Parameters.Add(GoodsID);
        //执行过程
        myConn.Open();
        try
        {
            myCmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw (ex);

        }
        finally
        {
            myCmd.Dispose();
            myConn.Close();
        }
    }
    //*************************************************************************************************
    /// <summary>
    /// 添加管理员
    /// </summary>
    /// <param name="P_Str_Admin">管理员名</param>
    /// <returns></returns>
    public int AddAdmin(string P_Str_Admin,string P_Str_Password)
    {
        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_AddAdmin", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //添加参数
        SqlParameter Admin = new SqlParameter("@Admin", SqlDbType.VarChar, 50);
        Admin.Value = P_Str_Admin;
        myCmd.Parameters.Add(Admin);
        //添加参数
        SqlParameter Password = new SqlParameter("@Password", SqlDbType.VarChar, 50);
        Password.Value = P_Str_Password;
        myCmd.Parameters.Add(Password);
        //添加参数
        SqlParameter returnValue = myCmd.Parameters.Add("returnValue", SqlDbType.Int, 4);
        returnValue.Direction = ParameterDirection.ReturnValue;
        //执行过程
        myConn.Open();
        try
        {
            myCmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw (ex);
        }
        finally
        {
            myCmd.Dispose();
            myConn.Close();

        }
        int P_Int_returnValue = Convert.ToInt32(returnValue.Value.ToString());
        return P_Int_returnValue;
    }
    /// <summary>
    /// 判断管理员是否存在
    /// </summary>
    /// <param name="P_Str_Name">管理员名字</param>
    /// <param name="P_Str_Password">管理员密码</param>
    /// <returns></returns>
    public int AExists(string P_Str_Name, string P_Str_Password)
    {
        SqlConnection myConn = dbObj.GetConnection();
        SqlCommand myCmd = new SqlCommand("Proc_AdminExists", myConn);
        myCmd.CommandType = CommandType.StoredProcedure;
        //添加参数
        SqlParameter Name = new SqlParameter("@Name", SqlDbType.VarChar, 50);
        Name.Value = P_Str_Name;
        myCmd.Parameters.Add(Name);
        //添加参数
        SqlParameter Password = new SqlParameter("@Password", SqlDbType.VarChar, 50);
        Password.Value = P_Str_Password;
        myCmd.Parameters.Add(Password);
        //添加参数
        SqlParameter returnValue = myCmd.Parameters.Add("returnValue", SqlDbType.Int, 4);
        returnValue.Direction = ParameterDirection.ReturnValue;
        //执行过程
        myConn.Open();
        try
        {
            myCmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw (ex);
        }
        finally
        {
            myCmd.Dispose();
            myConn.Close();

        }
        int P_Int_returnValue = Convert.ToInt32(returnValue.Value.ToString());
        return P_Int_returnValue;

⌨️ 快捷键说明

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