private void btnListOfEmployees_Click(object sender, EventArgs e) { Hide(); var employeesForm = new EmployeesForm(); employeesForm.ShowDialog(); Close(); }
// id와 path는 바인딩 안함 public ActionResult Create([Bind(Include = "LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate,Address,City,Region,PostalCode,Country,HomePhone,Extension,Photo,Notes,ReportsTo")] EmployeesForm employeesForm) { try { if (ModelState.IsValid) { ViewBag.ReportsTo = new SelectList(db.Employees, "ReportsTo", "LastName", employeesForm.ReportsTo); Employees employees = new Employees(); if (employeesForm.Photo != null && employeesForm.Photo.ContentLength > 0 && employeesForm.Photo.ContentType.Contains("image")) { MemoryStream target = new MemoryStream(); employeesForm.Photo.InputStream.CopyTo(target); byte[] data = target.ToArray(); employees.Photo = data; employees.PhotoPath = Path.Combine(Server.MapPath("~App_Data/photo"), employeesForm.Photo.FileName); } employees.Address = employeesForm.Address; if (employeesForm.BirthDate != null) { employees.BirthDate = Convert.ToDateTime(employeesForm.BirthDate); } employees.City = employeesForm.City; employees.Country = employeesForm.Country; employees.Extension = employeesForm.Extension; employees.FirstName = employeesForm.FirstName; if (employeesForm.HireDate != null) { employees.HireDate = Convert.ToDateTime(employeesForm.HireDate); } employees.HomePhone = employeesForm.HomePhone; employees.LastName = employeesForm.LastName; employees.Notes = employeesForm.Notes; employees.PostalCode = employeesForm.PostalCode; employees.Region = employeesForm.Region; employees.ReportsTo = employeesForm.ReportsTo; employees.Title = employeesForm.Title; employees.TitleOfCourtesy = employeesForm.TitleOfCourtesy; db.Employees.Add(employees); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException e) { System.Diagnostics.Trace.WriteLine("message:\n" + e.Message); if (e.GetBaseException() != null) { System.Diagnostics.Trace.WriteLine("inner exception message:\n" + e.GetBaseException().Message); } ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(employeesForm)); }
// GET: Employees/Edit public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employees employees = db.Employees.Find(id); if (employees == null) { return(HttpNotFound()); } EmployeesForm employeesForm = new EmployeesForm(); employeesForm.Address = employees.Address; // date formatting if (employees.BirthDate != null) { employeesForm.BirthDate = employees.BirthDate.ToString().Substring(0, 10); } employeesForm.City = employees.City; employeesForm.Country = employees.Country; employeesForm.Extension = employees.Extension; employeesForm.FirstName = employees.FirstName; // date formatting if (employees.HireDate != null) { employeesForm.HireDate = employees.HireDate.ToString().Substring(0, 10); } employeesForm.HomePhone = employees.HomePhone; employeesForm.LastName = employees.LastName; employeesForm.Notes = employees.Notes; employeesForm.PostalCode = employees.PostalCode; employeesForm.Region = employees.Region; employeesForm.ReportsTo = employees.ReportsTo; employeesForm.Title = employees.Title; employeesForm.TitleOfCourtesy = employees.TitleOfCourtesy; /* * if (employees.Photo != null) * employeesForm.Photo = (HttpPostedFileBase)new MemoryPostedFile(employees.Photo); */ ViewBag.ReportsTo = new SelectList(db.Employees, "ReportsTo", "LastName"); return(View(employeesForm)); }
private void TsmEmployeesClick(object sender, EventArgs e) { EmployeesForm.Execute(this); }
private void employeesButton_Click(object sender, EventArgs e) { EmployeesForm employeesForm = new EmployeesForm(_objectModel.Employees, _objectModel.Mans); employeesForm.ShowDialog(); }
private void eMPLOYEESToolStripMenuItem_Click(object sender, EventArgs e) { EmployeesForm employessForm = new EmployeesForm(); frmgecis.MainFormPass(employessForm, this); }