protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HumanResourcesDepartment.Menu menu = new HumanResourcesDepartment.Menu(); this.company = menu.LoadObject("Google", Server.MapPath(@"~\App_Data")); ArrayList positions = new ArrayList(); positions.Add("Product owner"); positions.Add("Developer"); positions.Add("QA"); positions.Add("Project manager"); positions.Add("Business analyst"); Position.DataSource = positions; Position.DataBind(); Employeer.DataSource = this.ReturnEmployerList(this.company); Employeer.DataValueField = "Key"; Employeer.DataTextField = "Value"; Employeer.DataBind(); Subdivision.DataSource = this.ReturnSubdivisions(this.company); Subdivision.DataBind(); if (!string.IsNullOrEmpty(Request.QueryString["id"])) { this.id = int.Parse(Request.QueryString["id"]); this.SetDataOnForm(id); this.ChangeButtons(); } } else { HumanResourcesDepartment.Menu menu = new HumanResourcesDepartment.Menu(); this.company = menu.LoadObject("Google", Server.MapPath(@"~\App_Data")); } }
/// <summary> /// This method adds new subdivision. /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> protected void AddSubdivision(object sender, EventArgs e) { company.AddSubdivision(NameOfSubdivision.Text); HumanResourcesDepartment.Menu menu = new HumanResourcesDepartment.Menu(); menu.SaveObject(this.company, Server.MapPath(@"~\App_Data")); Response.Redirect(Request.RawUrl); }
/// <summary> /// This method loads all data from file. /// </summary> /// <param name="sender">EventArgs</param> /// <param name="e">object</param> protected void Page_Load(object sender, EventArgs e) { HumanResourcesDepartment.Menu menu = new HumanResourcesDepartment.Menu(); this.company = menu.LoadObject("Google", Server.MapPath(@"~\App_Data")); if (!IsPostBack) { SubdivisionDropList.DataSource = this.ReturnSubdivisions(this.company); SubdivisionDropList.DataBind(); } }
/// <summary> /// This method delete subdivision. /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> protected void DeleteSubdivision(object sender, EventArgs e) { string nameOfSubdivision = SubdivisionDropList.SelectedValue; if (nameOfSubdivision != "All") { this.company.RemoveSubdivision(nameOfSubdivision); } else { subdivision = company.FindSubdivisionByName(nameOfSubdivision); } HumanResourcesDepartment.Menu menu = new HumanResourcesDepartment.Menu(); menu.SaveObject(this.company, Server.MapPath(@"~\App_Data")); Response.Redirect(Request.RawUrl); }
/// <summary> /// This method adds employee. /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> protected void AddEmployee(object sender, EventArgs e) { this.SelectedPosition = Position.SelectedValue; this.SelectedSubdivision = Subdivision.SelectedValue; if (Employeer.SelectedValue == "None") { this.company.AddEmployee(FirstName.Text, LastName.Text, ContactDetails.Text, this.SelectedPosition, this.SelectedSubdivision); } else { this.SelectedEmployerId = int.Parse(Employeer.SelectedValue); this.company.AddEmployee(FirstName.Text, LastName.Text, ContactDetails.Text, this.SelectedPosition, this.SelectedSubdivision, this.SelectedEmployerId); } HumanResourcesDepartment.Menu menu = new HumanResourcesDepartment.Menu(); menu.SaveObject(this.company, Server.MapPath(@"~\App_Data")); Response.Redirect("Default"); }
/// <summary> /// This method change employee's information. /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> protected void ChangeEmployee(object sender, EventArgs e) { this.SelectedPosition = Position.SelectedValue; this.SelectedSubdivision = Subdivision.SelectedValue; Employee emp = this.company.FindById(int.Parse(Emp_id.Text)); if (Employeer.SelectedValue == "None") { emp.ChangeAllData(FirstName.Text, LastName.Text, ContactDetails.Text, this.SelectedPosition, this.company.FindSubdivisionByName(this.SelectedSubdivision), null); } else { this.SelectedEmployerId = int.Parse(Employeer.SelectedValue); emp.ChangeAllData(FirstName.Text, LastName.Text, ContactDetails.Text, this.SelectedPosition, this.company.FindSubdivisionByName(this.SelectedSubdivision), this.company.FindById(SelectedEmployerId)); } HumanResourcesDepartment.Menu menu = new HumanResourcesDepartment.Menu(); menu.SaveObject(this.company, Server.MapPath(@"~\App_Data")); Response.Redirect("Default"); }
protected void Page_Load(object sender, EventArgs e) { HumanResourcesDepartment.Menu menu = new HumanResourcesDepartment.Menu(); this.company = menu.LoadObject("Google", Server.MapPath(@"~\App_Data")); menu.SaveObject(this.company, Server.MapPath(@"~\App_Data")); try { int int_id = int.Parse(Request.QueryString["id"]); Employee emp = this.company.FindById(int_id); this.company.RemoveEmloyee(emp); menu.SaveObject(this.company, Server.MapPath(@"~\App_Data")); } catch (NullReferenceException) { } catch (ArgumentNullException) { } Response.Redirect("Default"); }
/// <summary> /// This method saves object and redirect on AddEmployeeForm. /// </summary> /// <param name="sender">EventArgs</param> /// <param name="e">object</param> protected void AddEmployee(object sender, EventArgs e) { HumanResourcesDepartment.Menu menu = new HumanResourcesDepartment.Menu(); menu.SaveObject(this.company, Server.MapPath(@"~\App_Data")); Response.Redirect("AddEmployeeForm"); }