예제 #1
0
        private static void BrandAdd()
        {
            BrandManager brandManager = new BrandManager(new EfBrandDal());
            List <Brand> brands       = new List <Brand> {
                new Brand {
                    Id = 1, BrandName = "Toyota"
                },
                new Brand {
                    Id = 2, BrandName = "Tofaş"
                },
                new Brand {
                    Id = 3, BrandName = "Mitsubishi"
                },
                new Brand {
                    Id = 4, BrandName = "Ford"
                },
                new Brand {
                    Id = 5, BrandName = "Mercedes"
                }
            };

            foreach (var item in brands)
            {
                brandManager.AddBrand(item);
            }
            Console.WriteLine("işlem tamam");
        }
        //插入
        protected void dvBrand_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            TextBox txtBrandName = (TextBox)dvBrand.FindControl("txtAddBrandName");

            try
            {
                Brand b = new Brand();
                b.BrandName = txtBrandName.Text;

                bm.AddBrand(b);

                if (b.BrandId == -1)
                {
                    lblInfo.Text = "新增失败,品牌名称已存在";
                    return;
                }

                lblInfo.Text = "新增成功,新增的编号:" + b.BrandId;

                dvBrand.ChangeMode(DetailsViewMode.ReadOnly);
                bindBrandById(b.BrandId);
            }
            catch (Exception ex)
            {
                lblInfo.Text = "新增失败,异常:" + ex.Message;
            }
        }
예제 #3
0
        private static void AddBrandTest()
        {
            BrandManager brandManager = new BrandManager(new EfBrandDal());

            brandManager.AddBrand(new Brand {
                BrandName = "Honda"
            });
        }
예제 #4
0
        private static void markaEkle(BrandManager brandManager)
        {
            Brand brand1 = new Brand {
                BrandID = 1, BrandName = "Audi"
            };

            brandManager.AddBrand(brand1);
            Console.WriteLine("Marka eklendi {0}", brand1.BrandName);
        }
예제 #5
0
        private static Brand AddBrand(BrandManager brandManager)
        {
            Brand brand1 = new Brand
            {
                AddedDate = DateTime.Now,
                Name      = "Hyundai"
            };

            brandManager.AddBrand(brand1);
            return(brand1);
        }
예제 #6
0
        public IHttpActionResult AddBrand(BrandDto brand)
        {
            BrandManager brandManager = new BrandManager();
            string       message;

            if (brandManager.IsValid(MethodTypes.Post, brand, out message))
            {
                var newBrand = brandManager.AddBrand(brand, out message);
                if (newBrand != null)
                {
                    return(Ok(newBrand));
                }
            }

            return(BadRequest(message));
        }
예제 #7
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                Brand b = new Brand()
                {
                    BrandName = txtName.Text
                };
                bm.AddBrand(b);

                if (b.BrandId == -1)
                {
                    lblInfo.Text = "增加失败,品牌名称已存在,请勿重复添加";
                }
                else
                {
                    lblInfo.Text = "增加成功,新增品牌编号是:" + b.BrandId;
                }
            }
            catch (Exception ex)
            {
                lblInfo.Text = "增加失败,出现异常,异常信息:" + ex.Message;
            }
        }
예제 #8
0
        private static void AddBrand(Brand brand)
        {
            BrandManager brandManager = new BrandManager(new EfBrandDal());

            brandManager.AddBrand(brand);
        }