コード例 #1
0
ファイル: BrandController.cs プロジェクト: myname88/myjobs
 public string Add(Brand model)
 {
     if (ModelState.IsValid) { }
     model.BIMG = model.BIMG.TrimEnd("_1".ToCharArray());
     model.AddTime = DateTime.Now;
    BrandBll bll = new BrandBll();
    return bll.Add(model, Request["CIds[]"]);
 }
コード例 #2
0
ファイル: BrandController.cs プロジェクト: myname88/myjobs
        public ActionResult Edit(Brand model)
        {
            //这样如果不行,还是写具体点更新那几个字段把
            if (model.BIMG!=null&&model.BIMG != "")
            {
                model.BIMG = model.BIMG.TrimEnd("_1".ToCharArray());
            }
           

            return Json(new BrandBll().UpdateBrand(model, Request["CIds[]"]));
        }
コード例 #3
0
        public Brand Get_Brand_By_Id(int ID)
        {
            Brand _Brand = new Brand();

            DataTable dt = Brand_DA.Get_Brand_By_Id(ID);

            foreach (DataRow row in dt.Rows)
            {
                _Brand.ID = ID;
                _Brand.Name = row["Name"].ToString();
                _Brand.Description = row["Description"].ToString();
            }
            return _Brand;
        }
コード例 #4
0
        /**
         *
         * 增加品牌
         *
         * */
        public bool addBrand(Brand brand)
        {
            try
            {
                string sql = "insert into brand (brand_name) values(@brandName)";

                Dictionary<string, Object> parameters = new Dictionary<string, Object>();

                parameters.Add("@brandName", brand.getBrandName());

                dbAccess.excute(sql, parameters);
                return true;
            }
            catch (Exception e)
            {
                throw new MyException(e.Message);
            }
        }
コード例 #5
0
 private void deleteButton_Click(object sender, EventArgs e)
 {
     ListViewItem item = this.brandListView.FocusedItem;
     if (null != item)
     {
         if((this.service.findIdByColomn("category","brand",int.Parse(item.SubItems[0].Text))) == -1)
         {
             Brand brand = new Brand(item.SubItems[1].Text);
             brand.Id = int.Parse(item.SubItems[0].Text);
             this.service.deleteBusinessModel("brand",brand);
             initListView();
         }
         else
             MessageBox.Show("请先删除与其相关的类别和产品!");
     }
     else
     {
         MessageBox.Show("请先选择品牌!");
     }
 }
コード例 #6
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            ListViewItem item = this.cutomerListView.FocusedItem;
            if (null != item)
            {
                BrandForm brandForm = new BrandForm();

                Model.Brand brand = new Brand(item.SubItems[1].Text);
                brand.Id  = Int32.Parse(item.SubItems[0].Text);

                brandForm.setBrand(brand);
                brandForm.init();

                brandForm.setFlag("update");

                if (brandForm.ShowDialog() == DialogResult.OK)
                {
                    initListView();
                }
            }
            else
            {
                MessageBox.Show("请先选择品牌!");
            }
        }
コード例 #7
0
ファイル: BrandForm.cs プロジェクト: lishengtao/Anli_Project
 public void setBrand(Brand brand)
 {
     this.brand = brand;
 }
コード例 #8
0
        public static string Insert(Brand _Brand)
        {
            DbCommand command = Catalog_Access.CreateCommand();
            //Have to wite the stored procedure
            command.CommandText = "sp_insert_Brand";

            DbParameter param;

            param = command.CreateParameter();
            param.ParameterName = "@Name";
            param.Value = _Brand.Name;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Description";
            param.Value = _Brand.Description;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@CreatedBy";
            param.Value = _Brand.CreatedBy;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Return";
            param.DbType = DbType.String;
            param.Size = 2;
            param.Direction = ParameterDirection.Output;
            command.Parameters.Add(param);

            Catalog_Access.ExecuteNonQuery(command);

            string Return = command.Parameters["@Return"].Value.ToString();

            return Return;
        }
コード例 #9
0
        public static string Update(Brand _Brand)
        {
            DbCommand command = Catalog_Access.CreateCommand();
            command.CommandText = "sp_Update_Brand";

            DbParameter param;

            param = command.CreateParameter();
            param.ParameterName = "@ID";
            param.Value = _Brand.ID;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Name";
            param.Value = _Brand.Name;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Description";
            param.Value = _Brand.Description;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@UpdatedBy";
            param.Value = _Brand.UpdatedBy;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Return";
            param.DbType = DbType.String;
            param.Size = 2;
            param.Direction = ParameterDirection.Output;
            command.Parameters.Add(param);
            Catalog_Access.ExecuteNonQuery(command);

            string Return = command.Parameters["@Return"].Value.ToString();

            return Return;
        }
コード例 #10
0
        /**
         *
         * 更新品牌
         *
         * */
        public bool updateBrand(Brand brand)
        {
            try
            {
                string sql = "update brand set brand_name = @brandName where id = @id";

                Dictionary<string, Object> parameters = new Dictionary<string, Object>();

                parameters.Add("@brandName", brand.getBrandName());
                parameters.Add("@id", brand.Id);

                dbAccess.excute(sql, parameters);
                return true;
            }
            catch (Exception e)
            {
                throw new MyException(e.Message);
            }
        }
コード例 #11
0
        /**
         *
         * 查询所有品牌
         *
         * */
        public List<Brand> findBrands()
        {
            SqlCeDataReader dr = null;

            List<Brand> brands = new List<Brand>();

            try
            {
                string sql = "select id, brand_name from brand";

                dr = dbAccess.excuteSqlCeQuery(sql);
                if (dr != null)
                {
                    while (dr.Read())
                    {
                       Brand brand = new Brand();

                       brand.Id = dr.GetInt32(0);

                       if (dr.IsDBNull(1))
                           brand.setBrandName("");
                       else
                           brand.setBrandName(dr.GetString(1));

                       brands.Add(brand);
                    }
                }
            }
            catch (Exception e)
            {
                throw new MyException(e.Message);
            }
            finally
            {
                if (null != dr)
                    dr.Close();
            }

            return brands;
        }
コード例 #12
0
        public string Insert(string Name, string Description)
        {
            Brand _Brand = new Brand();
            _Brand.Name = Name;
            _Brand.Description = Description;
            _Brand.CreatedBy = Session["User"].ToString();

            return Brand_DA.Insert(_Brand);
        }
コード例 #13
0
        public string Update(int ID, string Name, string Description)
        {
            Brand _Brand = new Brand();
            _Brand.ID = ID;
            _Brand.Name = Name;
            _Brand.Description = Description;
            _Brand.UpdatedBy = Session["User"].ToString();

            if (_Brand.UpdatedBy.ToString().ToUpper() == ("Mr. Asif").ToString().ToUpper() || _Brand.UpdatedBy.ToString().ToUpper() == ("Saud Piracha").ToString().ToUpper())
            {
                return Brand_DA.Update(_Brand);
            }
            else
            {
                return "-1";
            }
        }
コード例 #14
0
 /// <summary>
 /// 创建新的 Brand 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="brandName">BrandName 属性的初始值。</param>
 public static Brand CreateBrand(global::System.Int32 id, global::System.String brandName)
 {
     Brand brand = new Brand();
     brand.ID = id;
     brand.BrandName = brandName;
     return brand;
 }
コード例 #15
0
 /// <summary>
 /// 用于向 Brand EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToBrand(Brand brand)
 {
     base.AddObject("Brand", brand);
 }