Пример #1
0
        /// <summary>
        /// 商标选择框变动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LB_Brand_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (LB_Brand.SelectedIndex < 0 || !Mark)
            {
                return;
            }
            String    BrandName  = LB_Brand.SelectedItem.ToString();
            Car_Brand Temp_Brand = List_Brand.Where(P => P.Brand_Name == BrandName).Single();

            TB_BrandName.Text = Temp_Brand.Brand_Name;
            TB_BrandInfo.Text = Temp_Brand.Brand_Info;
            imgString         = null;
            try
            {
                string[] imgArr = Temp_Brand.Brand_IMG.ToString().Split(new char[] { ',' });

                byte[] bty = Array.ConvertAll <string, byte>(imgArr, delegate(string s) { return(byte.Parse(s)); });

                Bitmap bmp = new Bitmap(bty.FromBytes(null, null));
                PB_Pic.Image = bmp;
                imgString    = Temp_Brand.Brand_IMG;
            }
            catch
            {
                MessageBox.Show("载入图片出现错误,请重新上传图片更新数据库或联系管理员!", "错误!!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Пример #2
0
        /// <summary>
        /// 更改品牌信息
        /// </summary>
        /// <param name="New_Brand">新的品牌实体</param>
        /// <returns></returns>
        public bool UpdateBrand(Car_Brand TempBrand)
        {
            Car_Brand OldBrand = DB_Brand.Select(P => P.Brand_ID == TempBrand.Brand_ID).Single();
            Car_Brand NewBrand = OldBrand;

            NewBrand.Brand_IMG  = TempBrand.Brand_IMG;
            NewBrand.Brand_Info = TempBrand.Brand_Info;
            NewBrand.Brand_Name = TempBrand.Brand_Name;
            return(DB_Brand.Update(OldBrand, NewBrand));
        }
Пример #3
0
 private void Select_Brand(object sender, SelectionChangedEventArgs e)
 {
     if (Brand.SelectedIndex == -1)
     {
         return;
     }
     using (CONTEXT db = new CONTEXT())
     {
         if (tmp == "Moto")
         {
             Moto_Brand b   = new Moto_Brand();
             string     str = (Brand.SelectedItem as Moto_Brand).Brand;
             b = db.Moto_Brand.First(x => x.Brand == str);
             Model.ItemsSource = b._Moto_Model;
         }
         else if (tmp == "Car")
         {
             Car_Brand b   = new Car_Brand();
             string    str = (Brand.SelectedItem as Car_Brand).Brand;
             b = db.Car_Brand.First(x => x.Brand == str);
             Model.ItemsSource = b._Car_Model;
         }
         else if (tmp == "Truck")
         {
             Trucks_Brand b   = new Trucks_Brand();
             string       str = (Brand.SelectedItem as Trucks_Brand).Brand;
             b = db.Trucks_Brand.First(x => x.Brand == str);
             Model.ItemsSource = b._Trucs_Model;
         }
         else if (tmp == "Bus")
         {
             Bus_Brand b   = new Bus_Brand();
             string    str = (Brand.SelectedItem as Bus_Brand).Brand;
             b = db.Bus_Brand.First(x => x.Brand == str);
             Model.ItemsSource = b._Bus_Model;
         }
     }
 }
Пример #4
0
        public bool update_brand(Car_Brand brand)
        {
            Car_Brand old_Brand = DB_Brand.Select(P => P.Brand_ID == brand.Brand_ID).Single();

            return(DB_Brand.Update(old_Brand, brand));
        }
Пример #5
0
 public bool save_brand(Car_Brand brand)
 {
     return(DB_Brand.Insert(brand));
 }
Пример #6
0
        /// <summary>
        /// 删除品牌信息
        /// </summary>
        /// <param name="Brand">要删除的品牌实体</param>
        /// <returns></returns>
        public bool DeleteBrand(int BrandID)
        {
            Car_Brand Bra = DB_Brand.Select(P => P.Brand_ID == BrandID).Single();

            return(DB_Brand.Delete(Bra));
        }
Пример #7
0
 /// <summary>
 /// 新增品牌信息
 /// </summary>
 /// <param name="Brand">要增加的品牌实体</param>
 /// <returns></returns>
 public bool AddBrand(Car_Brand Brand)
 {
     return(DB_Brand.Insert(Brand));
 }