Esempio 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));
        }
Esempio 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());
        }
Esempio n. 3
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";
        }
Esempio n. 4
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));
        }