コード例 #1
0
            public static Tu getTu(string name)
            {
                Tu tu = null;

                if (name == "San")
                {
                    Console.WriteLine("请依次输入三边长:");
                    try
                    {
                        int a = Int32.Parse(Console.ReadLine());
                        int b = Int32.Parse(Console.ReadLine());
                        int c = Int32.Parse(Console.ReadLine());
                        tu = new San(a, b, c);
                    }
                    catch (Exception a) {
                        Console.WriteLine("输入错误:" + a.Message);
                    }
                }
                else if (name == "Yuan")
                {
                    Console.WriteLine("请输入半径:");
                    try
                    {
                        int a = Int32.Parse(Console.ReadLine());
                        tu = new Yuan(a);
                    }
                    catch (Exception a)
                    {
                        Console.WriteLine("输入错误:" + a.Message);
                    }
                }
                else if (name == "Zhe")
                {
                    Console.WriteLine("请输入边长:");
                    try
                    {
                        int a = Int32.Parse(Console.ReadLine());
                        tu = new Zhe(a);
                    }
                    catch (Exception a)
                    {
                        Console.WriteLine("输入错误:" + a.Message);
                    }
                }
                else if (name == "Cha")
                {
                    Console.WriteLine("请依次输入两边长:");
                    try
                    {
                        int a = Int32.Parse(Console.ReadLine());
                        int b = Int32.Parse(Console.ReadLine());
                        tu = new Cha(a, b);
                    }
                    catch (Exception a)
                    {
                        Console.WriteLine("输入错误:" + a.Message);
                    }
                }
                return(tu);
            }
コード例 #2
0
 public ActionResult Create([Bind(Include = "MaSan, TenSan,DonGia,Image,MetaTitle,IDLoai,Hot,MaKM,SoLuong,ThongTin")] San model)
 {
     if (ModelState.IsValid)
     {
         db.Sans.Add(model);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaSan = new SelectList(db.Sans, "MaSan, TenSan,DonGia,Image,MetaTitle,IDLoai,Hot,MaKM,SoLuong,ThongTin", model.MaSan);
     return(View(model));
 }
コード例 #3
0
        public IActionResult NuevoSan(HomeViewModel viewModel)
        {
            var sanToSave = new San
            {
                Descripcion   = viewModel.SanDescripcion,
                Monto         = viewModel.Monto,
                FechaApertura = viewModel.FechaInicio,
                Cerrado       = false
            };

            _dbcontext.San.Add(sanToSave);
            _dbcontext.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
コード例 #4
0
ファイル: SanDao.cs プロジェクト: DatHuynh123/DatSanBongDa
 public bool Update(San entity)
 {
     try
     {
         var san = db.Sans.Find(entity.MaSan);
         san.TenSan  = entity.TenSan;
         san.DonGia  = entity.DonGia;
         san.IDLoai  = entity.IDLoai;
         san.MaKM    = entity.MaKM;
         san.SoLuong = entity.SoLuong;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         //logging
         return(false);
     }
 }
コード例 #5
0
 public ActionResult Edit(San san)
 {
     if (ModelState.IsValid)
     {
         var dao = new SanDao();
         if (!string.IsNullOrEmpty(san.TenSan))
         {
             san.TenSan = san.TenSan;
         }
         var result = dao.Update(san);
         if (result)
         {
             return(RedirectToAction("Index", "San"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật San không thành công");
         }
     }
     return(View("Index"));
 }
コード例 #6
0
ファイル: SanDao.cs プロジェクト: DatHuynh123/DatSanBongDa
 public string Insert(San san)
 {
     db.Sans.Add(san);
     db.SaveChanges();
     return(san.MaSan);
 }