Пример #1
0
        public ActionResult Edit(Timesheet Timesheet)
        {
            Timesheet oTimesheet = new Timesheet();

            oTimesheet.TimesheetID = System.Convert.ToInt32(Timesheet.TimesheetID);
            oTimesheet             = TimesheetData.Select_Record(Timesheet);

            if (ModelState.IsValid)
            {
                bool bSucess = false;
                bSucess = TimesheetData.Update(oTimesheet, Timesheet);
                if (bSucess == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Can Not Update");
                }
            }
            // ComboBox
            ViewData["EmployeeID"] = new SelectList(Timesheet_EmployeeData.List(), "EmployeeID", "FirstName", Timesheet.EmployeeID);
            ViewData["ProjectID"]  = new SelectList(Timesheet_ProjectData.List(), "ProjectID", "ProjectName", Timesheet.ProjectID);

            return(View(Timesheet));
        }
Пример #2
0
        // GET: /Timesheet/Edit/<id>
        public ActionResult Edit(
            Int32?TimesheetID
            )
        {
            if (
                TimesheetID == null
                )
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Timesheet Timesheet = new Timesheet();

            Timesheet.TimesheetID = System.Convert.ToInt32(TimesheetID);
            Timesheet             = TimesheetData.Select_Record(Timesheet);

            if (Timesheet == null)
            {
                return(HttpNotFound());
            }
            // ComboBox
            ViewData["EmployeeID"] = new SelectList(Timesheet_EmployeeData.List(), "EmployeeID", "FirstName", Timesheet.EmployeeID);
            ViewData["ProjectID"]  = new SelectList(Timesheet_ProjectData.List(), "ProjectID", "ProjectName", Timesheet.ProjectID);

            return(View(Timesheet));
        }
Пример #3
0
        public ActionResult DeleteConfirmed(
            Int32?TimesheetID
            )
        {
            Timesheet Timesheet = new Timesheet();

            Timesheet.TimesheetID = System.Convert.ToInt32(TimesheetID);
            Timesheet             = TimesheetData.Select_Record(Timesheet);

            bool bSucess = false;

            bSucess = TimesheetData.Delete(Timesheet);
            if (bSucess == true)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Can Not Delete");
            }
            return(null);
        }
Пример #4
0
        // GET: /Timesheet/Delete/<id>
        public ActionResult Delete(
            Int32?TimesheetID
            )
        {
            if (
                TimesheetID == null
                )
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            dtEmployee = Timesheet_EmployeeData.SelectAll();
            dtProject  = Timesheet_ProjectData.SelectAll();

            Timesheet Timesheet = new Timesheet();

            Timesheet.TimesheetID = System.Convert.ToInt32(TimesheetID);
            Timesheet             = TimesheetData.Select_Record(Timesheet);
            Timesheet.Employee    = new Employee()
            {
                EmployeeID  = (Int32)Timesheet.EmployeeID
                , FirstName = (from DataRow rowEmployee in dtEmployee.Rows
                               where Timesheet.EmployeeID == (int)rowEmployee["EmployeeID"]
                               select(String) rowEmployee["FirstName"]).FirstOrDefault()
            };
            Timesheet.Project = new Project()
            {
                ProjectID     = (Int32)Timesheet.ProjectID
                , ProjectName = (from DataRow rowProject in dtProject.Rows
                                 where Timesheet.ProjectID == (int)rowProject["ProjectID"]
                                 select(String) rowProject["ProjectName"]).FirstOrDefault()
            };

            if (Timesheet == null)
            {
                return(HttpNotFound());
            }
            return(View(Timesheet));
        }