📄 brandadddal.cs
字号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Model;
namespace DAL.Goods
{
public class BrandAddDal
{
#region 添加商品品牌
public int AddBrand(string brand_Name, string brand_Explain)
{
string cmdtextm1 = "brand_insert";
SqlParameter name = new SqlParameter("@brand_Name",SqlDbType.VarChar,10);
name.Value = brand_Name;
SqlParameter exp = new SqlParameter("@brand_Explain",SqlDbType.VarChar,50);
exp.Value = brand_Explain;
return SqlHelper.ExecuteNonQuery(SqlHelper.conStr, CommandType.StoredProcedure, cmdtextm1, new SqlParameter[] { name, exp });
}
#endregion
#region 在DropDownList里显示所有商品表的品牌名称
public List<Model.Goods.BrandAdd> SelectbrandByName()
{
string commandtext = "brandByName_Select";
DataSet ds = new DataSet();
SqlHelper.FillDataSet(SqlHelper.conStr, CommandType.StoredProcedure, commandtext, ds, new string[] { }, null);
List<Model.Goods.BrandAdd> list = new List<Model.Goods.BrandAdd>();
foreach (DataRow dr in ds.Tables[0].Rows)
{
Model.Goods.BrandAdd inf = new Model.Goods.BrandAdd();
inf.brand_Name = dr["brand_Name"].ToString();
list.Add(inf);
}
return list;
}
#endregion
#region 通过品牌名称获得品牌ID
public int BrandById(string brand_Name)
{
string commandtext = "BrandById";
SqlParameter brna = new SqlParameter("@brand_Name",SqlDbType.VarChar,10);
brna.Value = brand_Name;
DataSet ds = new DataSet();
SqlHelper.FillDataSet(SqlHelper.conStr, CommandType.StoredProcedure, commandtext, ds, new string[] { }, brna);
Model.Goods.BrandAdd inf = new Model.Goods.BrandAdd();
foreach (DataRow dr in ds.Tables[0].Rows)
{
inf.brand_ID = (int)dr["brand_ID"];
}
int x = inf.brand_ID;
return x;
}
#endregion
#region 查询商品品牌
/// <summary>
/// 查询商品品牌
/// </summary>
/// <returns></returns>
public List<Model.Goods.BrandAdd> BrandSelect()
{
List<Model.Goods.BrandAdd> brand = new List<Model.Goods.BrandAdd>();
string commandtext = "Brand_Select";
DataSet ds = new DataSet();
SqlHelper.FillDataSet(SqlHelper.conStr, CommandType.StoredProcedure, commandtext, ds, new string[] { }, null);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Model.Goods.BrandAdd inf = new Model.Goods.BrandAdd();
inf.brand_ID = (int)dr["brand_ID"];
inf.brand_Name = dr["brand_Name"].ToString();
inf.brand_Explain = dr["brand_Explain"].ToString();
brand.Add(inf);
}
return brand;
}
#endregion
#region 商品品牌删除
/// <summary>
/// 品牌删除
/// </summary>
/// <param name="brand_id">品牌ID</param>
/// <returns>返回删除商品品牌影响的行数</returns>
public int BrandDelete(int brand_id)
{
string com = "Brand_Delete";
SqlParameter id = new SqlParameter("@brand_id", SqlDbType.Int);
id.Value = brand_id;
return SqlHelper.ExecuteNonQuery(SqlHelper.conStr, CommandType.StoredProcedure, com, new SqlParameter[] { id });
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -