public ActionResult <Employee> AddEmployee(ProductionWorker empl) { //Employee em = new ProductionWorker(); //ProductionWorker prod = new ProductionWorker(); if (!_service.AddEmployee(empl)) { return(BadRequest(new ReturnMessage("User with this login already exist"))); } return(Ok(empl)); }
private void displayButton_Click(object sender, EventArgs e) { string name = empNameTextBox.Text; int id = Convert.ToInt32(empIdTextBox.Text); int shift = Convert.ToInt32(shiftNumTextBox.Text); decimal pay = Convert.ToDecimal(hourlyPayTextBox.Text); ProductionWorker worker = new ProductionWorker(name, id, shift, pay); outputTextBox.Text = worker.ToString(); }
public void StartWorker() { if (HasStarted) { return; } HasStarted = true; worker = new ProductionWorker(this); worker.SuccessEvent += OnProductionSuccess; workerThread = new Thread(worker.Work); LogText("NEW THREAD ID: " + workerThread.ManagedThreadId); workerThread.Start(); }
public ActionResult <Employee> UpdateEmployee(ProductionWorker empl) { Employee returnedObj = _service.UpdateEmployee(empl); if (returnedObj != null) { return(Ok(empl)); } else { return(BadRequest()); } }
private void btnAccept_Click(object sender, EventArgs e) { if (ValidateFields()) { ProductionWorker productionWorker = new ProductionWorker { Name = txtName.Text, EmpNumber = Int32.Parse(txtNumber.Text), Shift = Int32.Parse(txtShift.Text), HourlyRate = Double.Parse(txtPayRate.Text) }; txtNameInfo.Text = productionWorker.Name; txtNumberInfo.Text = productionWorker.EmpNumber.ToString(); txtShiftInfo.Text = productionWorker.Shift.ToString(); txtPayRateInfo.Text = productionWorker.HourlyRate.ToString("$#.00"); } }
private void BtnAddProdWorker_Click(object sender, EventArgs e) { using (frmEmployee addEmployeeForm = new frmEmployee(1)) { addEmployeeForm.ShowDialog(); if (addEmployeeForm.DialogResult == DialogResult.OK) { string name = addEmployeeForm.txtName.Text; int shift; int.TryParse(addEmployeeForm.txtInput1.Text, out shift); decimal pay; decimal.TryParse(addEmployeeForm.txtInput2.Text, out pay); ProductionWorker employee = new ProductionWorker(name, counter, shift, pay); lstEmployeeList.Items.Add(employee); counter++; } } }
static void Main(string[] args) { ProductionWorker employee = new ProductionWorker(GetEmployeeName(), GetEmployeeNumber(), GetShift(), GetPayRate()); string shift = " "; switch (employee.ShiftNumber) { case 1: shift = "Day Shift"; break; case 2: shift = "Night Shift"; break; } Console.WriteLine($"\nEmployee name: {employee.Name}\nEmployee#: {employee.Number}\nShift: {shift}\nPay Rate: {employee.PayRate.ToString("C2")}"); Console.ReadLine(); }
public bool AddEmployee(ProductionWorker empl) { int RowCount=0; bool success = false; connection.Open(); var createTableCmd = connection.CreateCommand(); createTableCmd.CommandText = "Select Count(*) from Employee where login='******'"; createTableCmd.CommandType = CommandType.Text; RowCount = Convert.ToInt32(createTableCmd.ExecuteScalar()); if (RowCount != 0) { connection.Close(); return success; } var insertCmd = connection.CreateCommand(); System.Guid guid = System.Guid.NewGuid(); insertCmd.CommandText = "insert into Employee (GUID ,dtcreated ,dtmodified ,dtdeleted , firstname ,lastname ,login ,password ,department ,role ,type,rate ) "+ "values(@guid, @dtcreated,@dtmodified,@dtdeleted,@firstname,@lastname,@login,@password,@department,@role,@type,@rate)"; insertCmd.CommandType = CommandType.Text; insertCmd.Parameters.AddWithValue("guid", guid.ToString()); insertCmd.Parameters.AddWithValue("dtcreated", "" + DateTime.Now.Ticks); insertCmd.Parameters.AddWithValue("dtmodified", "" + DateTime.Now.Ticks); insertCmd.Parameters.AddWithValue("dtdeleted", "" + DateTime.MaxValue.Ticks); insertCmd.Parameters.AddWithValue("firstname", empl.FirstName); insertCmd.Parameters.AddWithValue("lastname", empl.LastName); insertCmd.Parameters.AddWithValue("login", empl.Login); insertCmd.Parameters.AddWithValue("password", "" + empl.Password); insertCmd.Parameters.AddWithValue("department", "" + empl.Department); insertCmd.Parameters.AddWithValue("role", "" + empl.Role); insertCmd.Parameters.AddWithValue("type", ""+empl.Type); insertCmd.Parameters.AddWithValue("rate", "" + empl.Rate); if (insertCmd.ExecuteNonQuery() > 0) success = true; connection.Close(); return success; }
/// <summary> /// Creates an instance of a ProcessWorker and /// asks the user for information regarding the process worker /// </summary> static void CreateWorker() { ProductionWorker pw = new ProductionWorker { EmployeeId = 101 }; Console.WriteLine("Please enter your first name"); pw.FirstName = Console.ReadLine(); Console.WriteLine("Please enter your last name"); pw.LastName = Console.ReadLine(); Console.WriteLine($"Your name is: {pw.GetName()}"); pw.Shift = GetShiftInfo(); Console.WriteLine($"{pw.WorkingShift()}"); Console.ReadLine(); }
static void CreateProductionEmployee() { ProductionWorker employee = new ProductionWorker(GetEmployeeName(), GetEmployeeNumber(), GetShift(), GetPayRate()); string shift = " "; //Depending on the number entered for shift, determines Day or Night shift. switch (employee.ShiftNumber) { case 1: shift = "Day Shift"; break; case 2: shift = "Night Shift"; break; } //Displays Employee information Console.WriteLine($"\nEmployee name: {employee.Name}\nEmployee#: {employee.Number}\nShift: {shift}\nPay Rate: {employee.PayRate.ToString("C2")}"); Console.ReadLine(); }
public Employee UpdateEmployee(ProductionWorker empl) { connection.Open(); var getTotalRecords = connection.CreateCommand(); getTotalRecords.CommandText = "update Employee set dtmodified =@dtmodified, firstname=@firstname ,lastname =@lastname , department=@department ,role=@role ,type =@type, rate=@rate " + " where login=@login"; getTotalRecords.CommandType = CommandType.Text; getTotalRecords.Parameters.AddWithValue("dtmodified", "" + DateTime.Now.Ticks); getTotalRecords.Parameters.AddWithValue("firstname", empl.FirstName); getTotalRecords.Parameters.AddWithValue("lastname", empl.LastName); getTotalRecords.Parameters.AddWithValue("login", empl.Login); getTotalRecords.Parameters.AddWithValue("department", "" + empl.Department); getTotalRecords.Parameters.AddWithValue("role", "" + empl.Role); getTotalRecords.Parameters.AddWithValue("rate", "" + empl.Rate); getTotalRecords.Parameters.AddWithValue("type", "" + empl.Type); getTotalRecords.ExecuteNonQuery(); connection.Close(); return empl; }
private void BtnEdit_Click(object sender, EventArgs e) { //Check for if TeamLeader before ProductionWorker //Because TeamLeader objs are ProductionWorker if (lstEmployeeList.SelectedItem is TeamLeader) { TeamLeader employee = (TeamLeader)lstEmployeeList.SelectedItem; using (frmEmployee editEmployeeForm = new frmEmployee(2)) { //Set form feilds to employees values editEmployeeForm.txtName.Text = employee.EmpName; editEmployeeForm.txtInput1.Text = employee.ShiftNumber.ToString(); editEmployeeForm.txtInput2.Text = employee.PayRate.ToString(); editEmployeeForm.txtReqTrainHrs.Text = employee.RequiredTrainingHours.ToString(); editEmployeeForm.txtActTrainHrs.Text = employee.ActualTrainingHours.ToString(); editEmployeeForm.txtMonthlyBonus.Text = employee.MonthlyBonus.ToString(); editEmployeeForm.ShowDialog(); if (editEmployeeForm.DialogResult == DialogResult.OK) { //Update employee information string name = editEmployeeForm.txtName.Text; int shift, reqHrs, actHrs; int.TryParse(editEmployeeForm.txtInput1.Text, out shift); int.TryParse(editEmployeeForm.txtReqTrainHrs.Text, out reqHrs); int.TryParse(editEmployeeForm.txtActTrainHrs.Text, out actHrs); decimal pay, bonus; decimal.TryParse(editEmployeeForm.txtInput2.Text, out pay); decimal.TryParse(editEmployeeForm.txtMonthlyBonus.Text, out bonus); lstEmployeeList.Items.Remove(employee); lstEmployeeList.Items.Add(employee); } } } else if (lstEmployeeList.SelectedItem is ProductionWorker) { ProductionWorker employee = (ProductionWorker)lstEmployeeList.SelectedItem; using (frmEmployee editEmployeeForm = new frmEmployee(1)) { //Set form feilds to employees values editEmployeeForm.txtName.Text = employee.EmpName; editEmployeeForm.txtInput1.Text = employee.ShiftNumber.ToString(); editEmployeeForm.txtInput2.Text = employee.PayRate.ToString(); editEmployeeForm.ShowDialog(); if (editEmployeeForm.DialogResult == DialogResult.OK) { //Update employee information string name = editEmployeeForm.txtName.Text; int shift; int.TryParse(editEmployeeForm.txtInput1.Text, out shift); decimal pay; decimal.TryParse(editEmployeeForm.txtInput2.Text, out pay); employee.EmpName = name; employee.ShiftNumber = shift; employee.PayRate = pay; lstEmployeeList.Items.Remove(employee); lstEmployeeList.Items.Add(employee); } } } else if (lstEmployeeList.SelectedItem is ShiftSupervisor) { ShiftSupervisor employee = (ShiftSupervisor)lstEmployeeList.SelectedItem; using (frmEmployee editEmployeeForm = new frmEmployee(2)) { //Set form feilds to employees values editEmployeeForm.txtName.Text = employee.EmpName; editEmployeeForm.txtInput1.Text = employee.AnnualSalary.ToString(); editEmployeeForm.txtInput2.Text = employee.AnnualProductionBonus.ToString(); editEmployeeForm.ShowDialog(); if (editEmployeeForm.DialogResult == DialogResult.OK) { //Update employee information string name = editEmployeeForm.txtName.Text; decimal salary; decimal.TryParse(editEmployeeForm.txtInput1.Text, out salary); decimal bonus; decimal.TryParse(editEmployeeForm.txtInput2.Text, out bonus); lstEmployeeList.Items.Remove(employee); lstEmployeeList.Items.Add(employee); } } } }