예제 #1
0
        public ActionResult Create(FormCollection form)
        {
            ViewData["Action"] = "Create";

            RONTGEN rontgen = new RONTGEN();
            try
            {
                if (ModelState.IsValid)
                {
                    USER user = (USER)Session["user"];
                    using (var dc = new db_ultramedicaDataContext(Helper.ConnectionString()))
                    {
                        rontgen = new RONTGEN()
                        {
                            EMPLOYEE_ID = form["EMPLOYEE_ID"],
                            YEAR_CHECKUP = form["YEAR_CHECKUP"],
                            RONTGEN_RESULT = form["RONTGEN_RESULT"],
                            CHECKED_BY = user.NIK
                        };

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

                        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);

                            rontgen.RONTGEN_FILE_NAME = Path.GetFileName(file.FileName);
                        }
                        dc.RONTGENs.InsertOnSubmit(rontgen);
                        dc.SubmitChanges();
                    }
                    // TODO: Add insert logic here
                    return RedirectToAction("Index");
                }
                return View();
            }
            catch (Exception ex)
            {
                ViewData["ErrorMessage"] = ex.Message;
                return View(rontgen);
            }
        }
예제 #2
0
        public ActionResult Create(string EMPLOYEE_ID, string YEAR_CHECKUP)
        {
            if (Session["user"] != null)
            {
                InitializeSession();
                ViewData["Action"] = "Create";
                ViewData["ErrorMessage"] = "";

                var Objreturn = new RONTGEN();
                Objreturn.YEAR_CHECKUP = YEAR_CHECKUP;
                Objreturn.EMPLOYEE_ID = EMPLOYEE_ID;

                return View(Objreturn);
            }
            return RedirectToAction("LogOut", "Account");
        }
		private void detach_RONTGENs(RONTGEN entity)
		{
			this.SendPropertyChanging();
			entity.FO = null;
		}
		private void attach_RONTGENs(RONTGEN entity)
		{
			this.SendPropertyChanging();
			entity.FO = this;
		}
 partial void DeleteRONTGEN(RONTGEN instance);
 partial void UpdateRONTGEN(RONTGEN instance);
 partial void InsertRONTGEN(RONTGEN instance);
예제 #8
0
        public ActionResult Edit(FormCollection form)
        {
            ViewData["Action"] = "Edit";
            var EMPLOYEE_ID = form["EMPLOYEE_ID"];
            var YEAR_CHECKUP = form["YEAR_CHECKUP"];
            RONTGEN rontgen = new RONTGEN();
            using (var dc = new db_ultramedicaDataContext(Helper.ConnectionString()))
            {
                rontgen = dc.RONTGENs.SingleOrDefault(o => o.EMPLOYEE_ID.Equals(EMPLOYEE_ID) && o.YEAR_CHECKUP == YEAR_CHECKUP);
                try
                {
                    if (rontgen != null)
                    {
                        if (ModelState.IsValid)
                        {
                            HttpPostedFileBase file = Request.Files["FileRontgen"];

                            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"], EMPLOYEE_ID.ToString(), YEAR_CHECKUP);
                                string filePath = string.Format("{0}\\{1}", fileDir, Path.GetFileName(file.FileName));
                                if (!Directory.Exists(fileDir))
                                    Directory.CreateDirectory(fileDir);

                                file.SaveAs(filePath);

                                rontgen.RONTGEN_FILE_NAME = Path.GetFileName(file.FileName);
                            }

                            rontgen.RONTGEN_FILE_NAME = form["RONTGEN_FILE_NAME"];
                            rontgen.RONTGEN_RESULT = form["RONTGEN_RESULT"];
                            rontgen.CHECKED_BY = "";

                            dc.SubmitChanges();
                        }
                    }

                    return RedirectToAction("Index");
                }
                catch (Exception ex)
                {
                    ViewData["ErrorMessage"] = ex.Message;
                    return View(rontgen);
                }
            }
        }
예제 #9
0
        public ActionResult Edit(string EMPLOYEE_ID, string YEAR_CHECKUP)
        {
            if (Session["user"] != null)
            {
                InitializeSession();
                ViewData["Action"] = "Edit";
                RONTGEN rontgen = new RONTGEN();
                try
                {

                    ViewData["ErrorMessage"] = "";

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