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

            try
            {
                if (ModelState.IsValid)
                {
                    using (var dc = new db_ultramedicaDataContext(Helper.ConnectionString()))
                    {
                        var fo = new FO
                                     {
                                         LAB_ID = int.Parse(form["LAB_ID"] ?? "0"),
                                         EMPLOYEE_ID = form["EMPLOYEE_ID"],
                                         YEAR_CHECKUP = form["YEAR_CHECKUP"],
                                         DATE =
                                             new DateTime(int.Parse(form["DATE"].Substring(6, 4)),
                                                          int.Parse(form["DATE"].Substring(3, 2)),
                                                          int.Parse(form["DATE"].Substring(0, 2))),
                                         DISTRICT = form["DISTRICT"]
                                     };
                        dc.FOs.InsertOnSubmit(fo);
                        dc.SubmitChanges();
                    }
                    // TODO: Add insert logic here
                    return RedirectToAction("Index");
                }
                return View();
            }
            catch (Exception ex)
            {
                ViewData["ErrorMessage"] = ex.Message;
                return View(new FO());
            }
        }
 partial void DeleteFO(FO instance);
 partial void UpdateFO(FO instance);
 partial void InsertFO(FO instance);
		private void detach_FOs(FO entity)
		{
			this.SendPropertyChanging();
			entity.EMPLOYEE = null;
		}
		private void attach_FOs(FO entity)
		{
			this.SendPropertyChanging();
			entity.EMPLOYEE = this;
		}
Beispiel #7
0
        public ActionResult Edit(string EMPLOYEE_ID, string YEAR_CHECKUP)
        {
            if (Session["user"] != null)
            {
                InitializeSession();
                ViewData["Action"] = "Edit";
                FO fo = new FO();
                try
                {
                    ViewData["ErrorMessage"] = "";

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