private void btnDelete_Click(object sender, EventArgs e) { int id = 0; int.TryParse(tbId.Text, out id); if (id != 0) { Project_Workers currentProject_Workers = BLProject_Workers.GetProject_WorkersById(APCContext, id); if (currentProject_Workers != null) { APCContext.DeleteObject(currentProject_Workers); APCContext.SaveChanges(); MessageBox.Show("Delete Successfully"); ClearContent(); } else { MessageBox.Show("Project_Workers Id not found"); } } else { MessageBox.Show("Project_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"); } }
public static bool insertProject_Workers(APCEntities APCContext, Project project, Workers worker, DateTime startDate, DateTime endDate, decimal totalHours, decimal salary) { Project_Workers project_workers = new Project_Workers(); project_workers.Project = project; project_workers.Workers = worker; project_workers.StartDate = startDate; project_workers.EndDate = endDate; project_workers.TotalHours = totalHours; project_workers.Salary = salary; project_workers.TotalSalary = salary * totalHours; project_workers.Invoiced = false; APCContext.AddToProject_Workers(project_workers); APCContext.SaveChanges(); return(true); }
public static bool insertProject_Workers(APCEntities APCContext, Project project, Workers worker, DateTime startDate, DateTime endDate, decimal totalHours, decimal salary) { Project_Workers project_workers = new Project_Workers(); project_workers.Project = project; project_workers.Workers = worker; project_workers.StartDate = startDate; project_workers.EndDate = endDate; project_workers.TotalHours = totalHours; project_workers.Salary = salary; project_workers.TotalSalary = salary * totalHours; project_workers.Invoiced = false; APCContext.AddToProject_Workers(project_workers); APCContext.SaveChanges(); return true; }
/// <summary> /// There are no comments for Project_Workers in the schema. /// </summary> public void AddToProject_Workers(Project_Workers project_Workers) { base.AddObject("Project_Workers", project_Workers); }
/// <summary> /// Create a new Project_Workers object. /// </summary> /// <param name="id">Initial value of Id.</param> public static Project_Workers CreateProject_Workers(int id) { Project_Workers project_Workers = new Project_Workers(); project_Workers.Id = id; return project_Workers; }