private void btnDelete_Click(object sender, EventArgs e) { int id = 0; int.TryParse(tbId.Text, out id); if (id != 0) { Workers currentWorkers = BLWorkers.GetWorkersById(APCContext, id); if (currentWorkers != null) { APCContext.DeleteObject(currentWorkers); APCContext.SaveChanges(); MessageBox.Show("Delete Successfully"); ClearContent(); } else { MessageBox.Show("Workers Id not found"); } } else { MessageBox.Show("Workers Id not found"); } }
private void btnUpdate_Click(object sender, EventArgs e) { decimal salary = 0; int id = 0; int.TryParse(tbId.Text, out id); decimal.TryParse(tbSalary.Text, out salary); if (id != 0) { Workers currentWorkers = BLWorkers.GetWorkersById(APCContext, id); if (currentWorkers != null) { currentWorkers.Name = tbName.Text; currentWorkers.Salary = salary; APCContext.SaveChanges(); MessageBox.Show("Workers Details Successfully Updated"); ClearContent(); } else { MessageBox.Show("Workers Id not found"); } } else { MessageBox.Show("Workers Id not found"); } }
private void btnUpdate_Click(object sender, EventArgs e) { int id = 0; int currentWorkerId = 0; int currentProjectId = 0; decimal totalWorkingHours = 0; decimal salary = 0; int.TryParse(tbId.Text, out id); if (id != 0) { Project_Workers currentProject_Workers = BLProject_Workers.GetProject_WorkersById(APCContext, id); if (currentProject_Workers != null) { if (int.TryParse(ddlWorker.SelectedValue.ToString(), out currentWorkerId)) { if (int.TryParse(ddlProject.SelectedValue.ToString(), out currentProjectId)) { if (decimal.TryParse(tbWorkingHours.Text, out totalWorkingHours)) { if (decimal.TryParse(tbSalary.Text, out salary)) { Workers currentWorker = BLWorkers.GetWorkersById(APCContext, currentWorkerId); Project currentProject = BLProject.GetProjectById(APCContext, currentProjectId); currentProject_Workers.Project = currentProject; currentProject_Workers.Workers = currentWorker; currentProject_Workers.StartDate = calStartDate.Value; currentProject_Workers.EndDate = calEndDate.Value; currentProject_Workers.TotalHours = totalWorkingHours; currentProject_Workers.Salary = salary; currentProject_Workers.TotalSalary = totalWorkingHours * salary; APCContext.SaveChanges(); MessageBox.Show("Project Workers Details Successfully Updated"); ClearContent(); } else { MessageBox.Show("Salary has to be decimal"); } } else { MessageBox.Show("Working hours has to be decimal"); } } } } else { MessageBox.Show("Project_Workers Id not found"); } } else { MessageBox.Show("Project_Workers Id not found"); } }
private void btnInsert_Click(object sender, EventArgs e) { decimal salary = 0; decimal.TryParse(tbSalary.Text, out salary); if (BLWorkers.insertWorkers(APCContext, tbName.Text, salary)) { MessageBox.Show("Workers Successfully Added"); ClearContent(); } else { MessageBox.Show("Please check your input"); } }
private void btnInsert_Click(object sender, EventArgs e) { int currentWorkerId = 0; int currentProjectId = 0; decimal totalWorkingHours = 0; decimal salary = 0; if (int.TryParse(ddlWorker.SelectedValue.ToString(), out currentWorkerId)) { if (int.TryParse(ddlProject.SelectedValue.ToString(), out currentProjectId)) { if (decimal.TryParse(tbWorkingHours.Text, out totalWorkingHours)) { if (decimal.TryParse(tbSalary.Text, out salary)) { Workers currentWorker = BLWorkers.GetWorkersById(APCContext, currentWorkerId); Project currentProject = BLProject.GetProjectById(APCContext, currentProjectId); if (BLProject_Workers.insertProject_Workers(APCContext, currentProject, currentWorker, calStartDate.Value, calEndDate.Value, totalWorkingHours, salary)) { MessageBox.Show("Project_Workers Successfully Added"); ClearContent(); } else { MessageBox.Show("Please check your input"); } } else { MessageBox.Show("Salary has to be decimal"); } } else { MessageBox.Show("Working hours has to be decimal"); } } } }
public List <Workers> searchById(int id) { if (id != 0) { List <Workers> workersList = BLWorkers.GetWorkersListById(APCContext, id); if (workersList != null) { tbId.Text = workersList[0].Id.ToString(); tbName.Text = workersList[0].Name; return(workersList); } else { MessageBox.Show("Workers Id not found"); } } else { MessageBox.Show("Workers Id not found"); } return(null); }