/// <summary>
 /// FrmAddEmployee()
 /// Constructor
 /// </summary>
 /// <param name="bus"></param>
 public FrmAddEmployee(Business bus)
 {
     InitializeComponent();
     business = bus;
     newEmployee = new Employee();
     updateEmployee = new Employee();
     clerks = business.Employees;
 }
 /// <summary>
 /// The constructor for the confirmation form.
 /// </summary>
 /// <param name="b"></param>
 /// <param name="orderDetailList"></param>
 /// <param name="c"></param>
 /// <param name="emp"></param>
 public FrmConfirmation(Business businessArg, Order order, List<OrderDetail> orderDetailList, Customer cust, Employee emp)
 {
     InitializeComponent();
     currentOrder = order;
     business = businessArg;
     orderDetails = orderDetailList;
     currentCustomer = cust;
     currentEmp = emp;
 }
Example #3
0
 public override void addReportedBy(Employee e)
 {
     if(e != null)
     {
         e.ReportsTo = this;
         m_ReportedBy.Add(e);
         this.markDirty();
     }
     else
     {
         throw new ApplicationException();
     }
 }
Example #4
0
 public abstract void addReportedBy(Employee e);
 /// <summary>
 /// loadConfirmation
 /// loads confirmation form after order is placed
 /// </summary>
 /// <param name="o"></param>
 /// <param name="od"></param>
 /// <param name="c"></param>
 /// <param name="emp"></param>
 private void loadConfirmation(Order o, List<OrderDetail> od, Customer c, Employee emp)
 {
     FrmConfirmation frmConfirmation = new FrmConfirmation(business, o, od, c, emp);
     frmConfirmation.Text = "Confirmation Window ";
     frmConfirmation.ShowDialog();
 }
 /// <summary>
 /// cmbClerks_SelectedIndexChanged()
 /// When clerk is selected clear error and set clerk equal to employee selected - passed to confirmation form
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmbClerks_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbClerks.SelectedIndex != -1)
     {
         errorProvider.SetError(cmbClerks, "");
         clerkSelected = (Employee)cmbClerks.SelectedItem;
     }
 }
        //add employee to DB and call delegate
        public string UpdateEmployee(Employee emp)
        {
            String updateQuery = "UPDATE Employees "
                + "SET LastName = " + ((String.IsNullOrEmpty(emp.LastName)) ? "null" : "\"" + emp.LastName + "\"")
                + ", FirstName = " + ((String.IsNullOrEmpty(emp.FirstName)) ? "null" : "\"" + emp.FirstName + "\"")
                + ", Title = " + ((String.IsNullOrEmpty(emp.Title)) ? "null" : "'" + emp.Title + "'")
                + ", TitleOfCourtesy = " + ((String.IsNullOrEmpty(emp.TitleOfCourtesy)) ? "null" : "\"" + emp.TitleOfCourtesy + "\"")
                + ", BirthDate = " + ((emp.BirthDate == null) ? "null" :  "#" + emp.BirthDate.ToShortDateString()) + "#"
                + ", HireDate = " + ((emp.HireDate == null) ? "null" :  "#" + emp.HireDate.ToShortDateString()) + "#"
                + ", Address = " + ((String.IsNullOrEmpty(emp.Address)) ? "null" : "'" + emp.Address + "'")
                + ", City = " + ((String.IsNullOrEmpty(emp.City)) ? "null" : "\"" + emp.City + "\"")
                + ", Region = " + ((String.IsNullOrEmpty(emp.Region)) ? "null" : "\"" + emp.Region + "\"")
                + ", PostalCode = " + ((String.IsNullOrEmpty(emp.PostalCode)) ? "null" : "'" + emp.PostalCode + "'")
                + ", Country = " + ((String.IsNullOrEmpty(emp.Country)) ? "null" : "\"" + emp.Country + "\"")
                + ", HomePhone = " + ((String.IsNullOrEmpty(emp.HomePhone)) ? "null" : "'" + emp.HomePhone + "'")
                + ", Extension = " + ((String.IsNullOrEmpty(emp.Extension)) ? "null" : "'" + emp.Extension + "'")
                + ", Photo = " + ((String.IsNullOrEmpty(emp.Photo)) ? "null" : "'" + emp.Photo + "'")
                + ", Notes = " + ((String.IsNullOrEmpty(emp.Notes)) ? "null" : "\"" + emp.Notes + "\"")
                + ", ReportsTo = " + ((emp.ReportsTo == 0) ? "null" : emp.ReportsTo.ToString())
                + " WHERE EmployeeID = " + emp.EmployeeID;

            OleDbCommand cmUpdate = new OleDbCommand(updateQuery, con);
            try
            {
                con.Open();
                cmUpdate.ExecuteNonQuery();
            }
            catch (Exception)
            {
                //can't display any error feedback in data access layer
                return "Employee Updated failed";
            }
            finally
            {
                con.Close();
            }

            //raise event
            if (employeeAdded_Changed != null)//check to makes sure at least one handler registered
            {
                employeeAdded_Changed();
            }

            return "Employee Updated";
        }
        //add employee to DB and call delegate
        /// <summary>
        /// InsertEmployee()
        /// Takes a Employee object and adds a new record to the database table Employees
        /// </summary>
        /// <param name="p">Object of type Employee</param>
        public string InsertEmployee(Employee emp)
        {
            String insertQuery = "INSERT INTO Employees (LastName, FirstName, Title, TitleOfCourtesy, "
                + "BirthDate, HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, "
                + "Photo, Notes, ReportsTo) VALUES ("
                + ((String.IsNullOrEmpty(emp.LastName)) ? "null" : "\"" + emp.LastName + "\"") + ","
                + ((String.IsNullOrEmpty(emp.FirstName)) ? "null" : "\"" + emp.FirstName + "\"") + ","
                + ((String.IsNullOrEmpty(emp.Title)) ? "null" : "'" + emp.Title + "'") + ","
                + ((String.IsNullOrEmpty(emp.TitleOfCourtesy)) ? "null" : "\"" + emp.TitleOfCourtesy + "\"") + ","
                + ((emp.BirthDate == null) ? "null" : "#" + emp.BirthDate.ToShortDateString()) + "#" + ","
                + ((emp.HireDate == null) ? "null" : "#" + emp.HireDate.ToShortDateString()) + "#" + ","
                + ((String.IsNullOrEmpty(emp.Address)) ? "null" : "\"" + emp.Address + "\"") + ","
                + ((String.IsNullOrEmpty(emp.City)) ? "null" : "\"" + emp.City + "\"") + ","
                + ((String.IsNullOrEmpty(emp.Region)) ? "null" : "\"" + emp.Region + "\"") + ","
                + ((String.IsNullOrEmpty(emp.PostalCode)) ? "null" : "'" + emp.PostalCode + "'") + ","
                + ((String.IsNullOrEmpty(emp.Country)) ? "null" : "\"" + emp.Country + "\"") + ","
                + ((String.IsNullOrEmpty(emp.HomePhone)) ? "null" : "'" + emp.HomePhone + "'") + ","
                + ((String.IsNullOrEmpty(emp.Extension)) ? "null" : "'" + emp.Extension + "'") + ","
                + ((String.IsNullOrEmpty(emp.Photo)) ? "null" : "'" + emp.Photo + "'") + ","
                + ((String.IsNullOrEmpty(emp.Notes)) ? "null" : "\"" + emp.Notes + "\"") + ","
                + ((emp.ReportsTo == 0) ? "null" : emp.ReportsTo.ToString()) + ")";

            OleDbCommand cmInsert = new OleDbCommand(insertQuery, con);
            try
            {
                con.Open();
                cmInsert.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                //can't display any error feedback in data access layer
                MessageBox.Show(e.Message);
                return "Employee Added Failed";

            }
            finally
            {
                con.Close();
            }

            //raise event
            if (employeeAdded_Changed != null)//check to makes sure at least one handler registered
            {
                employeeAdded_Changed();
            }
            return "Employee Added";
        }
 /// <summary>
 /// updateEmployee()
 /// Updates a record in Employees Table
 /// </summary>
 /// <param name="_product">takes and object of type Employee</param>
 public string updateEmployee(Employee _employee)
 {
     string confirmation = database.UpdateEmployee(_employee);
     return confirmation;
 }
        /// <summary>
        /// fetchEmployees()
        /// Gets Employee records from database and returns a copy of it
        /// </summary>
        /// <returns>List of type Employee</returns>
        public void loadEmployeeData()
        {
            employees = database.FetchEmployees();

                List<Employee> copyEmployees = new List<Employee>();
                Employee copy;

                foreach (Employee e in employees)
                {
                    copy = new Employee();//create new object

                    //add properties
                    copy.EmployeeID = e.EmployeeID;
                    copy.LastName = e.LastName;
                    copy.FirstName = e.FirstName;
                    copy.Title = e.Title;
                    copy.TitleOfCourtesy = e.TitleOfCourtesy;
                    copy.BirthDate = e.BirthDate;
                    copy.HireDate = e.HireDate;
                    copy.Address = e.Address;
                    copy.City = e.City;
                    copy.Region = e.Region;
                    copy.PostalCode = e.PostalCode;
                    copy.Country = e.Country;
                    copy.HomePhone = e.HomePhone;
                    copy.Extension = e.Extension;
                    copy.Photo = e.Photo;
                    copy.Notes = e.Notes;
                    copy.ReportsTo = e.ReportsTo;

                    copyEmployees.Add(copy);//add to new list
                    employees = copyEmployees;

                }
        }
 /// <summary>
 /// addEmployee()
 /// Adds new record to Employees Table
 /// </summary>
 /// <param name="_product">takes and object of type Employee</param>
 public string addEmployee(Employee _employee)
 {
     string confirmation = database.InsertEmployee(_employee);
     return confirmation;
 }