Exemplo n.º 1
0
        public ActionResult Create(FormCollection form)
        {
            ViewData["Action"] = "Create";
            AUDIO audio = new AUDIO();
            try
            {
                if (ModelState.IsValid)
                {
                    USER user = (USER)Session["user"];
                    using (var dc = new db_ultramedicaDataContext(Helper.ConnectionString()))
                    {
                        audio = new AUDIO()
                        {
                            EMPLOYEE_ID = form["EMPLOYEE_ID"],
                            YEAR_CHECKUP = form["YEAR_CHECKUP"],
                            AUDIOMETRY_RESULT = form["AUDIOMETRY_RESULT"],
                            CHECKED_BY = user.NIK
                        };

                        HttpPostedFileBase file = Request.Files["FileAUDIO"];

                        if (Request.ContentLength > Helper.MaxRequestLength() * 1024)
                        {
                            throw new Exception("Maximum request length exceeded. File allowed to be upload are " + (Helper.MaxRequestLength() / 1024).ToString() + " MB");
                        }

                        if (file.ContentLength > 0)
                        {
                            string fileDir = string.Format("{0}\\{1}_{2}", ConfigurationManager.AppSettings["FileUpload"], form["EMPLOYEE_ID"].ToString(), form["YEAR_CHECKUP"]);
                            string filePath = string.Format("{0}\\{1}", fileDir, Path.GetFileName(file.FileName));
                            if (!Directory.Exists(fileDir))
                                Directory.CreateDirectory(fileDir);

                            file.SaveAs(filePath);

                            audio.AUDIOMETRY_FILE_NAME = Path.GetFileName(file.FileName);
                        }

                        dc.AUDIOs.InsertOnSubmit(audio);
                        dc.SubmitChanges();
                    }
                    // TODO: Add insert logic here
                    return RedirectToAction("Index");
                }
                return View();
            }
            catch (Exception ex)
            {
                ViewData["ErrorMessage"] = ex.Message;
                return View(audio);
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(string EMPLOYEE_ID, string YEAR_CHECKUP)
        {
            if (Session["user"] != null)
            {
                InitializeSession();
                ViewData["Action"] = "Create";
                ViewData["ErrorMessage"] = "";

                var Objreturn = new AUDIO();

                Objreturn.YEAR_CHECKUP = YEAR_CHECKUP;
                Objreturn.EMPLOYEE_ID = EMPLOYEE_ID;

                return View(Objreturn);
            }
            return RedirectToAction("LogOut", "Account");
        }
		private void detach_AUDIOs(AUDIO entity)
		{
			this.SendPropertyChanging();
			entity.FO = null;
		}
		private void attach_AUDIOs(AUDIO entity)
		{
			this.SendPropertyChanging();
			entity.FO = this;
		}
 partial void DeleteAUDIO(AUDIO instance);
 partial void UpdateAUDIO(AUDIO instance);
 partial void InsertAUDIO(AUDIO instance);
Exemplo n.º 8
0
        public ActionResult Edit(string EMPLOYEE_ID, string YEAR_CHECKUP)
        {
            if (Session["user"] != null)
            {
                InitializeSession();
                ViewData["Action"] = "Edit";
                AUDIO audio = new AUDIO();
                try
                {
                    ViewData["ErrorMessage"] = "";

                    // TODO: Add insert logic here
                    using (var dc = new db_ultramedicaDataContext(Helper.ConnectionString()))
                    {
                        audio = dc.AUDIOs.SingleOrDefault(o => o.EMPLOYEE_ID.Equals(EMPLOYEE_ID) && o.YEAR_CHECKUP == YEAR_CHECKUP);
                    }
                    return View(audio);
                }
                catch (Exception ex)
                {
                    ViewData["ErrorMessage"] = ex.Message;
                    return View(audio);
                }
            }
            return RedirectToAction("LogOut", "Account");
        }