public ActionResult Add_Post() { string filename = Request.Form["Image"]; string src = Request.Form["src"]; if (UploadFileService.UploadFileToServerBase64(filename, Constants.MAINBOARD_PATH, src)) { var mainboard = _MainboardService.CreateMainboard(); try { mainboard.Name = Request.Form["Name"]; } catch (Exception e) { } try { mainboard.Description = Request.Form["Description"]; } catch (Exception e) { } try { mainboard.TradeMark = Request.Form["TradeMark"]; } catch (Exception e) { } try { mainboard.Type = Request.Form["Type"]; } catch (Exception e) { } try { mainboard.Model = Request.Form["Model"]; } catch (Exception e) { } try { mainboard.Chipset = Request.Form["Chipset"]; } catch (Exception e) { } try { mainboard.MaxRamMemory = Request.Form["MaxRamMemory"]; } catch (Exception e) { } try { mainboard.RamType = Request.Form["RamType"]; } catch (Exception e) { } try { mainboard.HDMINum = Request.Form["HDMINum"]; } catch (Exception e) { } try { mainboard.Price = Request.Form["Price"]; } catch (Exception e) { } try { mainboard.RamNum = Int32.Parse(Request.Form["RamNum"]); } catch (Exception e) { } try { mainboard.WarrantyPeriod = Int32.Parse(Request.Form["WarrantyPeriod"]); } catch (Exception e) { } mainboard.IsDeleted = false; mainboard.Image = filename; int num = 0; string price = mainboard.Price.Replace(".", "").Replace("đ", ""); if (int.TryParse(price, out num) == false) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Giá phải nhập số</p>"; return(RedirectToAction("Add")); } else { if (num < 0) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Nhập giá lớn hơn 0</p>"; return(RedirectToAction("Add")); } } if (_MainboardService.InsertMainboard(mainboard)) { Session["submit_message"] = null; return(RedirectToAction("Index")); } else { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #dd0808!important;font-weight: bold;'>Add keyboard failed</p>"; return(View()); } } else { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #dd0808!important;font-weight: bold;'>Add keyboard failed</p>"; return(View()); } }
public ActionResult Add_Post() { try { // upload image of computer string filename = Request.Form["Image"]; string src = Request.Form["src"]; if (UploadFileService.UploadFileToServerBase64(filename, Constants.RAM_PATH, src)) { var ram = _RAMService.CreateRAM(); #region get properties try { ram.Name = Request.Form["Name"]; } catch (Exception e) { } try { ram.Description = Request.Form["Description"]; } catch (Exception e) { } try { ram.TradeMark = Request.Form["TradeMark"]; } catch (Exception e) { } try { ram.Color = Request.Form["Color"]; } catch (Exception e) { } try { ram.RamType = Request.Form["RamType"]; } catch (Exception e) { } try { ram.Memory = Request.Form["Memory"]; } catch (Exception e) { } try { ram.BusSpeed = Request.Form["BusSpeed"]; } catch (Exception e) { } try { ram.Price = Request.Form["Price"]; } catch (Exception e) { } try { ram.WarrantyPeriod = Int32.Parse(Request.Form["WarrantyPeriod"]); } catch (Exception e) { } ram.Image = filename; ram.IsDeleted = false; #endregion int num = 0; string price = ram.Price.Replace(".", "").Replace("đ", ""); if (int.TryParse(price, out num) == false) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Giá phải nhập số</p>"; return(RedirectToAction("Add")); } else { if (num < 0) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Nhập giá lớn hơn 0</p>"; return(RedirectToAction("Add")); } } if (_RAMService.InsertRAM(ram)) { return(RedirectToAction("Index")); } else { return(View()); } } else { return(View()); } } catch (Exception e) { } return(View()); }
public ActionResult Add_Post() { // upload image of computer string filename = Request.Form["Image"]; string src = Request.Form["src"]; if (UploadFileService.UploadFileToServerBase64(filename, Constants.VGA_PATH, src)) { var vga = _VGAService.CreateVGA(); #region Get properties try { vga.Name = Request.Form["name"]; } catch (Exception e) { } try { vga.TradeMark = Request.Form["TradeMark"]; } catch (Exception e) { } try { vga.Label = Request.Form["Label"]; } catch (Exception e) { } try { vga.ChipsetManufacturer = Request.Form["ChipsetManufacturer"]; } catch (Exception e) { } try { vga.Model = Request.Form["Model"]; } catch (Exception e) { } try { vga.VGA1 = Request.Form["VGA"]; } catch (Exception e) { } try { vga.BoostClock = Request.Form["BoostClock"]; } catch (Exception e) { } try { vga.VGAMemory = Request.Form["VGAMemory"]; } catch (Exception e) { } try { vga.RamType = Request.Form["RamType"]; } catch (Exception e) { } try { vga.MaxResolution = Request.Form["MaxResolution"]; } catch (Exception e) { } try { vga.Directx = Request.Form["Directx"]; } catch (Exception e) { } try { vga.Size = Request.Form["Size"]; } catch (Exception e) { } try { vga.WarrantyPeriod = Int32.Parse(Request.Form["WarrantyPeriod"]); } catch (Exception e) { } try { vga.Description = Request.Form["Description"]; } catch (Exception e) { } vga.Image = filename; vga.IsDeleted = false; #endregion int num = 0; string price = vga.Price.Replace(".", "").Replace("đ", ""); if (int.TryParse(price, out num) == false) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Giá phải nhập số</p>"; return(RedirectToAction("Add")); } else { if (num < 0) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Nhập giá lớn hơn 0</p>"; return(RedirectToAction("Add")); } } if (_VGAService.InsertVGA(vga)) { return(RedirectToAction("Index")); } } else { return(View()); } return(View()); }
public ActionResult Add_Post() { // upload image of computer string filename = Request.Form["Image"]; string src = Request.Form["src"]; if (UploadFileService.UploadFileToServerBase64(filename, Constants.CASE_PATH, src)) { var Case = _CaseService.CreateCase(); #region get properties try { Case.Name = Request.Form["Name"]; } catch (Exception e) { } try { Case.WarrantyPeriod = Int32.Parse(Request.Form["WarrantyPeriod"]); } catch (Exception e) { } try { Case.TradeMark = Request.Form["TradeMark"]; } catch (Exception e) { } try { Case.Model = Request.Form["Model"]; } catch (Exception e) { } try { Case.Color = Request.Form["Color"]; } catch (Exception e) { } try { Case.Size = Request.Form["Size"]; } catch (Exception e) { } try { Case.MainSupport = Request.Form["MainSupport"]; } catch (Exception e) { } try { Case.USB = Request.Form["USB"]; } catch (Exception e) { } try { Case.DriverBays = Request.Form["DriverBays"]; } catch (Exception e) { } try { Case.Slots = Request.Form["Slots"]; } catch (Exception e) { } try { Case.Price = Request.Form["Price"]; } catch (Exception e) { } try { Case.Description = Request.Form["Description"]; } catch (Exception e) { } Case.IsDelete = false; Case.Image = filename; #endregion string price = Case.Price.Replace(".", "").Replace("đ", ""); if (int.TryParse(price, out int num) == false) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Giá phải nhập số</p>"; return(RedirectToAction("Add")); } else { if (num < 0) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Nhập giá lớn hơn 0</p>"; return(RedirectToAction("Add")); } } if (_CaseService.InsertCase(Case)) { return(RedirectToAction("Index")); } else { return(View()); } } else { return(View()); } }
public ActionResult Add_Post() { // upload image of computer string filename = Request.Form["Image"]; string src = Request.Form["src"]; if (UploadFileService.UploadFileToServerBase64(filename, Constants.KEYBOARD_PATH, src)) { var keyboard = _KeyboardService.CreateKeyboard(); #region update properties try { keyboard.Name = Request.Form["Name"]; } catch (Exception e) { } try { keyboard.Description = Request.Form["Description"]; } catch (Exception e) { } try { keyboard.TradeMark = Request.Form["TradeMark"]; } catch (Exception e) { } try { keyboard.WarrantyPeriod = Int32.Parse(Request.Form["WarrantyPeriod"]); } catch (Exception e) { } try { keyboard.Price = Request.Form["Price"]; } catch (Exception e) { } keyboard.IsDeleted = false; keyboard.Image = filename; #endregion int num = 0; string price = keyboard.Price.Replace(".", "").Replace("đ", ""); if (int.TryParse(price, out num) == false) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Giá phải nhập số</p>"; return(RedirectToAction("Add")); } else { if (num < 0) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Nhập giá lớn hơn 0</p>"; return(RedirectToAction("Add")); } } if (_KeyboardService.InsertKeyboard(keyboard)) { Session["submit_message"] = null; return(RedirectToAction("Index")); } else { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #dd0808!important;font-weight: bold;'>Add keyboard failed</p>"; return(View()); } } else { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #dd0808!important;font-weight: bold;'>Add keyboard failed</p>"; return(View()); } }
public ActionResult Add_Post() { try { // upload image of computer string filename = Request.Form["Image"]; string src = Request.Form["src"]; if (UploadFileService.UploadFileToServerBase64(filename, Constants.RADIATOR_PATH, src)) { var radiator = _RadiatorService.CreateRadiator(); #region Get properties try { radiator.Name = Request.Form["Name"]; } catch (Exception e) { } try { radiator.Description = Request.Form["Description"]; } catch (Exception e) { } try { radiator.TradeMark = Request.Form["TradeMark"]; } catch (Exception e) { } try { radiator.Label = Request.Form["Label"]; } catch (Exception e) { } try { radiator.Material = Request.Form["Material"]; } catch (Exception e) { } try { radiator.Speed = Request.Form["Speed"]; } catch (Exception e) { } try { radiator.Size = Request.Form["Size"]; } catch (Exception e) { } try { radiator.FanSize = Request.Form["FanSize"]; } catch (Exception e) { } try { radiator.Socket = Request.Form["Socket"]; } catch (Exception e) { } try { radiator.Price = Request.Form["Price"]; } catch (Exception e) { } radiator.Image = filename; radiator.IsDeleted = false; #endregion int num = 0; string price = radiator.Price.Replace(".", "").Replace("đ", ""); if (int.TryParse(price, out num) == false) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Giá phải nhập số</p>"; return(RedirectToAction("Add")); } else { if (num < 0) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Nhập giá lớn hơn 0</p>"; return(RedirectToAction("Add")); } } if (_RadiatorService.InsertRadiator(radiator)) { return(RedirectToAction("Index")); } } } catch (Exception e) { } return(View()); }
public ActionResult Add_Post() { // upload image of computer string filename = Request.Form["Image"]; string src = Request.Form["src"]; if (UploadFileService.UploadFileToServerBase64(filename, Constants.HARDWARE_PATH, src)) { var hardware = _HardwareService.CreateHardware(); #region get properties try { hardware.Name = Request.Form["Name"]; } catch (Exception e) { } try { hardware.Description = Request.Form["Description"]; } catch (Exception e) { } try { hardware.WarrantyPeriod = Int32.Parse(Request.Form["WarrantyPeriod"]); } catch (Exception e) { } try { hardware.TradeMark = Request.Form["TradeMark"]; } catch (Exception e) { } try { hardware.Memory = Request.Form["Memory"]; } catch (Exception e) { } try { hardware.Label = Request.Form["Label"]; } catch (Exception e) { } try { hardware.ReadSpeed = Request.Form["ReadSpeed"]; } catch (Exception e) { } try { hardware.WriteSpeed = Request.Form["WriteSpeed"]; } catch (Exception e) { } try { hardware.Size = Request.Form["Size"]; } catch (Exception e) { } try { hardware.Price = Request.Form["Price"]; } catch (Exception e) { } hardware.Image = filename; hardware.IsDeleted = false; #endregion int num = 0; string price = hardware.Price.Replace(".", "").Replace("đ", ""); if (int.TryParse(price, out num) == false) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Giá phải nhập số</p>"; return(RedirectToAction("Add")); } else { if (num < 0) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Nhập giá lớn hơn 0</p>"; return(RedirectToAction("Add")); } } if (_HardwareService.InsertHardware(hardware)) { return(RedirectToAction("Index")); } } return(View()); }
public ActionResult Add_Post() { // upload image of computer string filename = Request.Form["Image"]; string src = Request.Form["src"]; try { if (UploadFileService.UploadFileToServerBase64(filename, Constants.COMPUTER_PATH, src)) { var computer = _ComputerService.CreateComputer(); #region add properties try { computer.Name = Request.Form["Name"]; } catch (Exception e) { } try { computer.CPU = Request.Form["CPU"]; } catch (Exception e) { } try { computer.RAM = Request.Form["RAM"]; } catch (Exception e) { } try { computer.VideoCard = Request.Form["VideoCard"]; } catch (Exception e) { } try { computer.Hardware = Request.Form["Hardware"]; } catch (Exception e) { } try { computer.SlotSupport = Request.Form["SlotSupport"]; } catch (Exception e) { } try { computer.Display = Request.Form["Display"]; } catch (Exception e) { } try { computer.OS = Request.Form["OS"]; } catch (Exception e) { } try { computer.Type = Request.Form["Type"]; } catch (Exception e) { } try { computer.Trademark = Request.Form["Trademark"]; } catch (Exception e) { } try { computer.Feature = Request.Form["Feature"]; } catch (Exception e) { } try { computer.Color = Request.Form["Color"]; } catch (Exception e) { } try { computer.CPUSeries = Request.Form["CPUSeries"]; } catch (Exception e) { } try { computer.Resolution = Request.Form["Resolution"]; } catch (Exception e) { } try { computer.StandardOfScreen = Request.Form["StandardOfScreen"]; } catch (Exception e) { } try { computer.Size = Request.Form["Size"]; } catch (Exception e) { } try { computer.Mass = Request.Form["Mass"]; } catch (Exception e) { } try { computer.WarrantyPeriod = Int32.Parse(Request.Form["WarrantyPeriod"]); } catch (Exception e) { } try { computer.Price = Request.Form["Price"]; } catch (Exception e) { } try { computer.Description = Request.Form["Description"]; } catch (Exception e) { } try { computer.IsDeleted = false; } catch (Exception e) { } computer.Image = filename; #endregion int num = 0; string price = computer.Price.Replace(".", "").Replace("đ", ""); if (int.TryParse(price, out num) == false) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #f44242!important;font-weight: bold;'>Price phải nhập số</p>"; return(RedirectToAction("Update", new { Id = computer.Id })); } else { if (num < 0) { Session["submit_message"] = "<p class='font-green-sharp' style='font-size: 20px;color: #000000!important;font-weight: bold;'>Nhập giá lớn hơn 0</p>"; return(RedirectToAction("Add")); } } if (_ComputerService.InsertComputer(computer)) { return(RedirectToAction("Index")); } } // create computer } catch (Exception e) { } return(View()); }