Exemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "Id, FirstName, LastName, FatherName, MotherName, BirthDate, ExpectedEndDate, CersStartDate, CfStartDate, LeaveDate, LeaveReason, EmployeeStatus, Department, Notes, Category")] Employee employee)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    EmployeeServices.Update(CurrentUser.Id, employee, db);
                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "UpdateConfirmed");
                    return(RedirectToAction("Index"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

            ViewBag.CategoryList       = new SelectList(CategoryServices.List(db), "Id", "Name", employee.Category);
            ViewBag.DepartmentList     = new SelectList(DepartmentServices.List(db), "Id", "Name", employee.Department);
            ViewBag.EmployeeStatusList = new SelectList(EmployeeStatusServices.List(db), "Id", "Name", employee.EmployeeStatus);
            return(View(employee));
        }
Exemplo n.º 2
0
        public ActionResult Create()
        {
            Db db = new Db(DbServices.ConnectionString);

            ViewBag.CategoryList       = new SelectList(CategoryServices.List(db), "Id", "Name");
            ViewBag.DepartmentList     = new SelectList(DepartmentServices.List(db), "Id", "Name");
            ViewBag.EmployeeStatusList = new SelectList(EmployeeStatusServices.List(db), "Id", "Name");
            return(View());
        }
Exemplo n.º 3
0
        // GET: EmployeeStatus/Delete/5
        public ActionResult Delete(Nullable <byte> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Db             db             = new Db(DbServices.ConnectionString);
            EmployeeStatus employeeStatus = EmployeeStatusServices.Get(id.Value, db);

            if (employeeStatus == null)
            {
                return(HttpNotFound());
            }
            return(View(employeeStatus));
        }
Exemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Db db = new Db(@"Data Source = (local); Initial Catalog = Cf; Integrated Security = True");
            // comboBox1.DataSource = db.EmployeeStatusList();

            // EmployeeStatusMapper esm = new EmployeeStatusMapper(@"Data Source = (local); Initial Catalog = Cf; Integrated Security = True");
            // comboBox1.DataSource = esm.List();
            // comboBox1.DisplayMember = "Name";

            // EmployeeStatusVwMapper esvm = new EmployeeStatusVwMapper(@"Data Source = (local); Initial Catalog = Cf; Integrated Security = True");
            // comboBox1.DataSource = esvm.List();
            // comboBox1.DisplayMember = "Name";


            comboBox1.DataSource    = EmployeeStatusServices.List();
            comboBox1.DisplayMember = "Name";
            comboBox1.ValueMember   = "Id";
        }
Exemplo n.º 5
0
 public ActionResult DeleteConfirmed(byte id)
 {
     try
     {
         Db db = new Db(DbServices.ConnectionString);
         EmployeeStatusServices.Delete(CurrentUser.Id, id, db);
         TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "DeleteConfirmed");
         // return RedirectToAction("Index");
     }
     catch (CfException cfex)
     {
         TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
     }
     catch (Exception ex)
     {
         TempData["Failure"] = ex.Message;
     }
     // return View(employeeStatus);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 6
0
        // GET: Employee/Edit/5
        public ActionResult Edit(Nullable <int> id)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employee employee = EmployeeServices.Get(id.Value, db);

            if (employee == null)
            {
                return(HttpNotFound());
            }

            ViewBag.CategoryList       = new SelectList(CategoryServices.List(db), "Id", "Name", employee.Category);
            ViewBag.DepartmentList     = new SelectList(DepartmentServices.List(db), "Id", "Name", employee.Department);
            ViewBag.EmployeeStatusList = new SelectList(EmployeeStatusServices.List(db), "Id", "Name", employee.EmployeeStatus);
            return(View(employee));
        }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "Id, Name, IsActive")] EmployeeStatus employeeStatus)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    EmployeeStatusServices.Insert(CurrentUser.Id, employeeStatus, db);
                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                    return(RedirectToAction("Index"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

            return(View(employeeStatus));
        }