protected void submit_Click(object sender, EventArgs e)
    {
        string strName  = BrandName_New.Text.ToString();
        string strState = State_new.Text.ToString();
        string strDesc  = Description_new.Text.ToString();

        ProductsBrand pb = new ProductsBrand();

        pb.BrandName   = strName;
        pb.Description = strDesc;
        pb.State       = strState;

        if (Leyp.SQLServerDAL.Factory.getProductsBrandDAL().insertNewProductsBrand(pb))
        {
            addSystemLog("新加商品品牌:" + strName);
            HyperLink1.Visible = true;
            viewPanel.Visible  = false;
        }
        else
        {
            HyperLink1.Text    = "添加失败!可能是名称重复了!你可以返回重新试试";
            HyperLink1.Visible = true;
            viewPanel.Visible  = false;
        }
    }
    protected void updateButton_Click(object sender, EventArgs e)
    {
        string strName  = BrandName_edit.Text.ToString();
        string strState = State_edit.Text.ToString();
        string strDesc  = Description_edit.Text.ToString();

        ProductsBrand pb = new ProductsBrand();

        pb.BrandName   = strName;
        pb.Description = strDesc;
        pb.State       = strState;
        pb.BrandID     = int.Parse(BrandID.Text.ToString());

        if (Leyp.SQLServerDAL.Factory.getProductsBrandDAL().updataProductsBrand(pb))
        {
            addSystemLog("成功修改商品品牌:" + strName);
            HyperLink1.Visible = true;
            editPanel.Visible  = false;
            viewPanel.Visible  = false;
        }
        else
        {
            HyperLink1.Text    = "添加失败!可能是名称重复了!你可以返回重新试试";
            HyperLink1.Visible = true;
            editPanel.Visible  = false;
            viewPanel.Visible  = false;
        }
    }
Example #3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (this.TextBox1.Text != null)
     {
         ProductsBrand s = new ProductsBrand();
         s.BrandName   = this.TextBox1.Text;
         s.Description = this.TextBox2.Text;
         //s.State = this.DropDownList2.Text;
         if (this.DropDownList1.Text == "正常")
         {
             s.State = "Y";
         }
         else
         {
             s.State = "N";
         }
         int rows = ProductsBrandManager.ProductsBrandInsert(s);
         if (rows > 0)
         {
             Response.Write("<script>alert('添加成功!');</script>");
             this.TextBox1.Text      = "";
             this.TextBox2.Text      = "";
             this.DropDownList1.Text = "正常";
         }
         else
         {
             Response.Write("<script>alert('添加失败!');</script>");
         }
     }
     else
     {
         Response.Write("<script>alert('品牌名称不能为空!');</script>");
     }
 }
Example #4
0
        public static int ProductsBrandInsert(ProductsBrand s)
        {
            Database db   = DatabaseFactory.CreateDatabase("Constr");
            string   sql  = string.Format("insert into t_ProductsBrand values('{0}','{1}','{2}')", s.BrandName, s.Description, s.State);
            int      rows = db.ExecuteNonQuery(CommandType.Text, sql);

            return(rows);
        }
Example #5
0
        public static int ProductsBrandUpdate(ProductsBrand s)
        {
            Database db   = DatabaseFactory.CreateDatabase("Constr");
            string   sql  = string.Format("update t_ProductsBrand set BrandName='{0}' ,  Description='{1}' ,  State='{2}' where BrandID='{3}'", s.BrandName, s.Description, s.State, s.BrandID);
            int      rows = db.ExecuteNonQuery(CommandType.Text, sql);

            return(rows);
        }
    /// <summary>
    /// 初始化
    /// </summary>
    public void DataBand()
    {
        string action = Request.QueryString["action"];

        if (action == null)
        {
            CollectionPager1.DataSource    = Leyp.SQLServerDAL.Factory.getProductsBrandDAL().getAllProductsBrand();//BLL项目中List数据源
            CollectionPager1.BindToControl = GridView1;
            GridView1.DataSource           = CollectionPager1.DataSourcePaged;
            editPanel.Visible = false;
        }
        else if (action.Equals("edit"))
        {
            int brandID = 0;
            try
            {
                brandID = int.Parse(Request.QueryString["BrandID"].ToString());
            }
            catch
            {
                Response.Write("参数有误");
                Response.End();
            }

            ProductsBrand pb = new ProductsBrand();
            pb = Leyp.SQLServerDAL.Factory.getProductsBrandDAL().getByBrandID(brandID);

            BrandName_edit.Text   = pb.BrandName;
            BrandID.Text          = pb.BrandID.ToString();//保存编辑ID
            Description_edit.Text = pb.Description;
            editPanel.Visible     = true;
            viewPanel.Visible     = false;
        }
        else if (action.Equals("del"))
        {
            int brandID = 0;
            try
            {
                brandID = int.Parse(Request.QueryString["BrandID"].ToString());
            }
            catch
            {
                Response.Write("参数有误");
                Response.End();
            }

            if (Leyp.SQLServerDAL.Factory.getProductsBrandDAL().deleteByBrandID(brandID))
            {
                Response.Write("删除成功!");
                Response.End();
            }
            else
            {
                Response.Write("失败!可能该品牌已经在使用中");
                Response.End();
            }
        }
    }
Example #7
0
        public bool insertNewProductsBrand(ProductsBrand pb)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@BrandName", SqlDbType.NVarChar), new SqlParameter("@State", SqlDbType.NVarChar), new SqlParameter("@Description", SqlDbType.NVarChar) };
            parameters[0].Value = pb.BrandName;
            parameters[1].Value = pb.State;
            parameters[2].Value = pb.Description;
            SQLHelper.RunProcedure("p_ProductsBrand_InsertNew", parameters, out rowsAffected);
            return(1 == rowsAffected);
        }
Example #8
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     if (context.Request["BrandName"] != null)
     {
         ProductsBrand s = new ProductsBrand();
         s.BrandID     = Convert.ToInt32(context.Request["BrandID"]);
         s.BrandName   = context.Request["BrandName"];
         s.State       = context.Request["State"];
         s.Description = context.Request["Description"];
         context.Response.Write(ProductsBrandManager.ProductsBrandUpdate(s) > 0);
     }
 }
Example #9
0
        public static List <ProductsBrand> ProductsBrandDrop()
        {
            Database             db  = DatabaseFactory.CreateDatabase("Constr");
            string               sql = string.Format("select * from t_ProductsBrand");
            DataSet              ds  = db.ExecuteDataSet(CommandType.Text, sql);
            List <ProductsBrand> ll  = new List <ProductsBrand>();

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ProductsBrand sh = new ProductsBrand();
                sh.BrandID   = Convert.ToInt32(item["BrandID"].ToString());
                sh.BrandName = item["BrandName"].ToString();
                ll.Add(sh);
            }
            return(ll);
        }
Example #10
0
        public ProductsBrand getByBrandID(int BrandID)
        {
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@BrandID", SqlDbType.Int) };
            parameters[0].Value = BrandID;
            ProductsBrand brand  = new ProductsBrand();
            SqlDataReader reader = SQLHelper.RunProcedure("p_ProductsBrand_GetByBrandID", parameters);

            if (reader.Read())
            {
                brand.BrandID     = reader.GetInt32(reader.GetOrdinal("BrandID"));
                brand.BrandName   = reader.GetString(reader.GetOrdinal("BrandName"));
                brand.Description = reader.GetString(reader.GetOrdinal("Description"));
                brand.State       = reader.GetString(reader.GetOrdinal("State"));
            }
            reader.Close();
            return(brand);
        }
Example #11
0
        public static List <ProductsBrand> ProductsBrandID(int id)
        {
            Database             db  = DatabaseFactory.CreateDatabase("Constr");
            string               sql = string.Format("select * from t_ProductsBrand where BrandID='{0}'", id);
            DataSet              ds  = db.ExecuteDataSet(CommandType.Text, sql);
            List <ProductsBrand> ll  = new List <ProductsBrand>();

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ProductsBrand sh = new ProductsBrand();
                sh.BrandName   = item["BrandName"].ToString();
                sh.State       = item["State"].ToString();
                sh.Description = item["Description"].ToString();
                ll.Add(sh);
            }
            return(ll);
        }
Example #12
0
        public static List <ProductsBrand> ProductsBrandALL(int index, int rows)
        {
            Database             db  = DatabaseFactory.CreateDatabase("Constr");
            string               sql = string.Format("select top {0} * from t_ProductsBrand where BrandID not in(select top {1} BrandID from t_ProductsBrand)", index, index * (rows - 1));
            DataSet              ds  = db.ExecuteDataSet(CommandType.Text, sql);
            List <ProductsBrand> ll  = new List <ProductsBrand>();

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ProductsBrand sh = new ProductsBrand();
                sh.BrandID     = Convert.ToInt32(item["BrandID"].ToString());
                sh.BrandName   = item["BrandName"].ToString();
                sh.State       = item["State"].ToString();
                sh.Description = item["Description"].ToString();
                ll.Add(sh);
            }
            return(ll);
        }
Example #13
0
        public List <ProductsBrand> getAllProductsBrand()
        {
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@sign", SqlDbType.Int) };
            parameters[0].Value = 0;
            List <ProductsBrand> list   = new List <ProductsBrand>();
            SqlDataReader        reader = SQLHelper.RunProcedure("p_ProductsBrand_GetAll", parameters);

            while (reader.Read())
            {
                ProductsBrand item = new ProductsBrand();
                item.BrandID     = reader.GetInt32(reader.GetOrdinal("BrandID"));
                item.BrandName   = reader.GetString(reader.GetOrdinal("BrandName"));
                item.Description = reader.GetString(reader.GetOrdinal("Description"));
                item.State       = reader.GetString(reader.GetOrdinal("State"));
                list.Add(item);
            }
            reader.Close();
            return(list);
        }
Example #14
0
 public void AddProductBrand(ProductsBrand productsBrand)
 {
     productsBrandRepo.Add(productsBrand);
 }
Example #15
0
 public static int ProductsBrandInsert(ProductsBrand s)
 {
     return(ProductsBrandService.ProductsBrandInsert(s));
 }
Example #16
0
 public static int ProductsBrandUpdate(ProductsBrand s)
 {
     return(ProductsBrandService.ProductsBrandUpdate(s));
 }
Example #17
0
 /// <summary>
 /// 添加一个实体
 /// </summary>
 /// <param name="pb"></param>
 /// <returns></returns>
 public bool insertNewProductsBrand(ProductsBrand pb)
 {
     return(productsBrandDAL.insertNewProductsBrand(pb));
 }
Example #18
0
 public void DeleteProductBrand(ProductsBrand productsBrand)
 {
     productsBrandRepo.Delete(productsBrand);
 }