private void btnUpdate_Click(object sender, EventArgs e) { if (cmdOp.SelectedIndex > -1) { Operations op = new Operations(); SqlStatements sqlUpdate = new SqlStatements(); Boolean checkGrid = GridCheck(cmdOp.Text); //NEEDS TO CHECK CELL VALUE if (checkGrid == false) { MessageBox.Show("This operation has already been completed!", "Already Complete", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //WORK OUT THE TIME SPLIT TimeSplit ts = new TimeSplit(); int SplitTime = ts.GetTimeSplit(cmdOp.Text.ToString()); int staff_no1 = 0; int staff_no2 = 0; int staff_no3 = 0; int menIn = 0; int staffDynamic; int finishType = Int32.Parse(this.txtFinishID.Text); //UPDATE DOOR PART COMPLETION LOG if (SplitTime == 1) { frmTimeAllocation ta = new frmTimeAllocation(cmdOp.Text.ToString()); ta.ShowDialog(); sqlUpdate.InsertPartCompletion(Int32.Parse(txtSearch.Text), cmdOp.Text.ToString(), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), cmdOp.Text.ToString(), finishType), ta.ReturnStaffId); staff_no1 = ta.ReturnStaffId; staff_no2 = 0; staff_no3 = 0; } else { var allStaff = ts.GetAllInDept(cmdOp.Text.ToString()); staff_no1 = allStaff.Item1; staff_no2 = allStaff.Item2; staff_no3 = allStaff.Item3; //Works out the amount of men in the department if (staff_no3 == 195) { if (staff_no2 == 195) { menIn = 1; } else { menIn = 2; } } else { menIn = 3; } staffDynamic = 0; for (int i = 1; i <= menIn; ++i) { switch (i) { case 1: staffDynamic = staff_no1; break; case 2: staffDynamic = staff_no2; break; case 3: staffDynamic = staff_no3; break; } sqlUpdate.InsertPartCompletion(Int32.Parse(txtSearch.Text), cmdOp.Text.ToString(), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), cmdOp.Text.ToString(), finishType, menIn), staffDynamic, i); } } //UPDATE DailyGoals sqlUpdate.UpdateDailyGoals(op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), cmdOp.Text.ToString(), finishType)); switch (cmdOp.SelectedItem) { case "Up": //UPDATE DOOR sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Up", finishType) / int.Parse(txtQuantitySame.Text), "up", staff_no1, staff_no2, staff_no3); frmTrolleyOrTrack frmtot = new frmTrolleyOrTrack(Int32.Parse(txtSearch.Text)); frmtot.ShowDialog(); break; case "Wash/Wipe": //UPDATE DOOR sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Wash/Wipe", finishType) / int.Parse(txtQuantitySame.Text), "ww", staff_no1, staff_no2, staff_no3); break; case "Etch": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Etch", finishType) / int.Parse(txtQuantitySame.Text), "etch", staff_no1, staff_no2, staff_no3); break; case "Sand": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Sand", finishType) / int.Parse(txtQuantitySame.Text), "sand", staff_no1, staff_no2, staff_no3); break; case "Powder Prime": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Powder Prime", finishType) / int.Parse(txtQuantitySame.Text), "pp", staff_no1, staff_no2, staff_no3); break; case "Powder Coat": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Powder Coat", finishType) / int.Parse(txtQuantitySame.Text), "pc", staff_no1, staff_no2, staff_no3); break; case "Oven": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Oven", finishType) / int.Parse(txtQuantitySame.Text), "oven", staff_no1, staff_no2, staff_no3); break; case "Wet Prep": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Wet Prep", finishType) / int.Parse(txtQuantitySame.Text), "wp", staff_no1, staff_no2, staff_no3); break; case "Wet Paint": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Wet Paint", finishType) / int.Parse(txtQuantitySame.Text), "wet", staff_no1, staff_no2, staff_no3); break; case "Oven 2": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Oven 2", finishType) / int.Parse(txtQuantitySame.Text), "oven1", staff_no1, staff_no2, staff_no3); break; default: MessageBox.Show("No operation has been selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } //btnSearch_Click(sender,e); SqlStatements sqlCheck100 = new SqlStatements(); sqlCheck100.timeStamp100(); //REFRESH THE DATAGRID RefreshMainGrid(); } } else { MessageBox.Show("You must select an operation to continue!", "No operation", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void updateAll(string oper) { Operations op = new Operations(); SqlStatements sqlUpdate = new SqlStatements(); Boolean checkGrid = GridCheck(oper); //NEEDS TO CHECK CELL VALUE if (checkGrid == false) { //MessageBox.Show("This operation has already been completed!", "Already Complete", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //WORK OUT THE TIME SPLIT TimeSplit ts = new TimeSplit(); int SplitTime = ts.GetTimeSplit(oper); int staff_no1 = 0; int staff_no2 = 0; int staff_no3 = 0; int menIn = 0; int staffDynamic; int finishType = Int32.Parse(this.txtFinishID.Text); var allStaff = ts.GetAllInDept(oper); staff_no1 = allStaff.Item1; staff_no2 = allStaff.Item2; staff_no3 = allStaff.Item3; //Works out the amount of men in the department if (staff_no3 == 195) { if (staff_no2 == 195) { menIn = 1; } else { menIn = 2; } } else { menIn = 3; } staffDynamic = 0; for (int i = 1; i <= menIn; ++i) { switch (i) { case 1: staffDynamic = staff_no1; break; case 2: staffDynamic = staff_no2; break; case 3: staffDynamic = staff_no3; break; } sqlUpdate.InsertPartCompletion(Int32.Parse(txtSearch.Text), oper, op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), oper, finishType, menIn), staffDynamic, i); } //UPDATE DailyGoals sqlUpdate.UpdateDailyGoals(op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), oper, finishType)); switch (oper) { case "Up": //UPDATE DOOR sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Up", finishType) / int.Parse(txtQuantitySame.Text), "up", staff_no1, staff_no2, staff_no3); //Opens the palletizer to take the jobs off the pallet //palletize(true); break; case "Wash/Wipe": //UPDATE DOOR sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Wash/Wipe", finishType) / int.Parse(txtQuantitySame.Text), "ww", staff_no1, staff_no2, staff_no3); break; case "Etch": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Etch", finishType) / int.Parse(txtQuantitySame.Text), "etch", staff_no1, staff_no2, staff_no3); break; case "Sand": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Sand", finishType) / int.Parse(txtQuantitySame.Text), "sand", staff_no1, staff_no2, staff_no3); break; case "Powder Prime": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Powder Prime", finishType) / int.Parse(txtQuantitySame.Text), "pp", staff_no1, staff_no2, staff_no3); break; case "Powder Coat": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Powder Coat", finishType) / int.Parse(txtQuantitySame.Text), "pc", staff_no1, staff_no2, staff_no3); break; case "Oven": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Oven", finishType) / int.Parse(txtQuantitySame.Text), "oven", staff_no1, staff_no2, staff_no3); break; case "Wet Prep": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Wet Prep", finishType) / int.Parse(txtQuantitySame.Text), "wp", staff_no1, staff_no2, staff_no3); break; case "Wet Paint": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Wet Paint", finishType) / int.Parse(txtQuantitySame.Text), "wet", staff_no1, staff_no2, staff_no3); break; case "Oven 2": sqlUpdate.UpdateDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), "Oven 2", finishType) / int.Parse(txtQuantitySame.Text), "oven1", staff_no1, staff_no2, staff_no3); break; default: MessageBox.Show("No operation has been selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } SqlStatements sqlCheck100 = new SqlStatements(); sqlCheck100.timeStamp100(); //REFRESH THE DATAGRID RefreshMainGrid(); } }