public void UpdateDoor(int door_id, float time_remaining, string op_short, int staff_no1, int staff_no2, int staff_no3) { TimeSplit ts = new TimeSplit(); SqlConnection myConnection = new SqlConnection(ConnectionString); myConnection.Open(); string sb; string sb1; if (op_short == "up") { sb = string.Format("UPDATE dbo.door SET up_complete_paint = -1 WHERE id={0}", door_id); SqlCommand myCommand = new SqlCommand(sb.ToString(), myConnection); myCommand.ExecuteNonQuery(); } if (op_short == "oven") { sb1 = string.Format("UPDATE dbo.door SET {2}_complete_by_id = " + staff_no1 + ",{2}_complete_by_id2 = " + staff_no2 + ",{2}_complete_by_id3 = " + staff_no3 + ", {2}_complete_date2 ='" + time.ToString(format) + "', time_remaining_paint = time_remaining_paint - {0} WHERE id={1}", time_remaining, door_id, op_short); } else { sb1 = string.Format("UPDATE dbo.door SET {2}_complete_by_id = " + staff_no1 + ",{2}_complete_by_id2 = " + staff_no2 + ",{2}_complete_by_id3 = " + staff_no3 + ", {2}_complete_date ='" + time.ToString(format) + "', time_remaining_paint = time_remaining_paint - {0} WHERE id={1}", time_remaining, door_id, op_short); } SqlCommand myCommand1 = new SqlCommand(sb1.ToString(), myConnection); myCommand1.ExecuteNonQuery(); }
public void AddToDoor(int door_id, float time_remaining, string op_short) { TimeSplit ts = new TimeSplit(); SqlConnection myConnection = new SqlConnection(ConnectionString); myConnection.Open(); string sb; if (op_short == "up") { sb = string.Format("UPDATE dbo.door SET up_complete_paint = 0 WHERE id={0}", door_id); SqlCommand myCommand = new SqlCommand(sb.ToString(), myConnection); myCommand.ExecuteNonQuery(); } if (op_short == "oven") { sb = string.Format("UPDATE dbo.door SET {2}_complete_by_id = null,{2}_complete_by_id2 = null,{2}_complete_by_id3 = null, {2}_complete_date2 =null, time_remaining_paint = time_remaining_paint + {0} WHERE id={1}", time_remaining, door_id, op_short); } else { sb = string.Format("UPDATE dbo.door SET {2}_complete_by_id = null,{2}_complete_by_id2 = null,{2}_complete_by_id3 = null, {2}_complete_date =null, time_remaining_paint = time_remaining_paint + {0} WHERE id={1}", time_remaining, door_id, op_short); } SqlCommand myCommand1 = new SqlCommand(sb.ToString(), myConnection); myCommand1.ExecuteNonQuery(); }
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(); } }