private void button1_Click(object sender, EventArgs e) { var isNumeric = int.TryParse(txtSearch.Text, out int n); if (isNumeric == true) { foreach (object o in cmdOp.Items) { updateAll(o.ToString()); } //NEEDS TO MARK THE DOOR AS COMPLETE SqlStatements sqlUpdate = new SqlStatements(); frmLooseItems fli = new frmLooseItems(int.Parse(this.txtSearch.Text)); fli.ShowDialog(); sqlUpdate.CompleteDoor(Int32.Parse(txtSearch.Text), -1); RefreshDoorData(); } }
private void button1_Click_1(object sender, EventArgs e) { var isNumeric = int.TryParse(txtSearch.Text, out int n); if (isNumeric == true) { SqlStatements sqlUpdate = new SqlStatements(); sqlUpdate.CompleteDoor(Int32.Parse(txtSearch.Text), 0); RefreshDoorData(); } }
private void btnComplete_Click(object sender, EventArgs e) { if (this.ValidateChildren(ValidationConstraints.Enabled)) { Allocation a = new Allocation(cmbDepartmentResponsible.Text, Convert.ToInt32(txtDoorID.Text)); //UPDATE REPAINT INFORMATION SqlConnection myConnection = new SqlConnection(SqlStatements.ConnectionString); myConnection.Open(); var sb = string.Format("UPDATE dbo.repaints set painter_name = @responsibleStaff, [department] = @responsibleDept, repaint_checker_note = @reason, sanding_exposure_points = @sandingExposurePoints, sanding_time= @sandingTime,sanded_by_id = @sandedById, repaint_by= @repaint_by,paint_kg_used = @paint_kg_used, repaint_complete = @complete, date_painted = @date_painted WHERE id=@repaint_id"); SqlCommand command = new SqlCommand(sb, myConnection); command.Parameters.AddWithValue("@repaint_id", this.txtRepaintID.Text); command.Parameters.AddWithValue("@paint_kg_used", this.txtKgs.Text); command.Parameters.AddWithValue("@date_painted", DateTime.Now); command.Parameters.AddWithValue("@repaint_by", this.cmbRepaintBy.SelectedValue); command.Parameters.AddWithValue("@complete", -1); command.Parameters.AddWithValue("@reason", this.txtReason.Text); command.Parameters.AddWithValue("@responsibleStaff", a._allocatedTo); command.Parameters.AddWithValue("@responsibleDept", a._departmentOut); if (rdoYes.Checked == true) { command.Parameters.AddWithValue("@sandingTime", this.txtMins.Text); command.Parameters.AddWithValue("@sandedById", this.cmbSandBy.SelectedValue); command.Parameters.AddWithValue("@sandingExposurePoints", (Convert.ToDouble(this.txtMins.Text) / 60) * Convert.ToDouble(this.cmbTool.SelectedValue)); } else { command.Parameters.AddWithValue("@sandingTime", DBNull.Value); command.Parameters.AddWithValue("@sandedById", DBNull.Value); command.Parameters.AddWithValue("@sandingExposurePoints", DBNull.Value); } command.ExecuteNonQuery(); //UPDATE STOCK SqlStatements sql = new SqlStatements(); sql.UpdatePaintStock(int.Parse(txtPaintID.Text), int.Parse(txtKgs.Text)); MessageBox.Show("Repaint Completed Successfully.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("All fields must be filled in before completing the repaint!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnConfirm_Click(object sender, EventArgs e) { SqlStatements sql = new SqlStatements(); if (rdoStaff1.Checked == true) { this.ReturnStaffId = sql.GetStaffIDFromName(lblStaff1.Text.ToString()); } else if (rdoStaff2.Checked == true) { this.ReturnStaffId = sql.GetStaffIDFromName(lblStaff2.Text.ToString()); } else { this.ReturnStaffId = sql.GetStaffIDFromName(lblStaff3.Text.ToString()); } this.DialogResult = DialogResult.OK; this.Close(); }
private void btnSaveNote_Click(object sender, EventArgs e) { try { int problemVal; if (chkIsProblem.Checked == true) { problemVal = -1; } else { problemVal = 0; } SqlStatements sqlUpdateNote = new SqlStatements(); sqlUpdateNote.SaveNote(int.Parse(txtSearch.Text), this.txtPaintingNote.Text, problemVal); MessageBox.Show("Note saved successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { MessageBox.Show("Note error, did not save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSave_Click(object sender, EventArgs e) { //this.ValidateChildren(); if (this.ValidateChildren(ValidationConstraints.Enabled)) { String ConnectionString = SqlStatements.ConnectionString; //MessageBox.Show(this.cmbEmployee.SelectedValue.ToString()); int door_id = Int32.Parse(this.txtDoorId.Text.ToString()); int paint_id = get_paint_id(Int32.Parse(this.txtDoorId.Text.ToString())); SqlConnection myConnection = new SqlConnection(ConnectionString); myConnection.Open(); //INSERTS NEW RECORDS INTO DBO DOOR PART COMPLETION LOG var sb = string.Format("INSERT into dbo.repaints(sanding_exposure_points,paint_id, paint_kg_used, painter_name, department, door_id, repaint_checker_note,repaint_by, repaint_time,logged_by_id,repaint_complete,date_logged,repaint_from_dept,sanding_time,sanded_by_id) VALUES " + "(@sandingExposurePoints,@paint_id,@paint_kg_used,@painter_name,@department,@door_id,@reason,@repaint_by,@repaint_time,@logged_by,@complete,@date_logged,@repaint_from_dept,@sandingTime,@sandedById)"); SqlCommand command = new SqlCommand(sb, myConnection); command.Parameters.AddWithValue("@paint_id", paint_id); command.Parameters.AddWithValue("@paint_kg_used", this.txtKgs.Text); //command.Parameters.AddWithValue("@date_painted", DateTime.Now); command.Parameters.AddWithValue("@painter_name", this.cmbEmployee.SelectedValue); command.Parameters.AddWithValue("@department", this.cmbDepartment.SelectedValue); command.Parameters.AddWithValue("@door_id", door_id); command.Parameters.AddWithValue("@reason", this.txtReason.Text); command.Parameters.AddWithValue("@repaint_by", this.cmbRepaintBy.SelectedValue); command.Parameters.AddWithValue("@repaint_time", 0); command.Parameters.AddWithValue("@logged_by", this.cmbLoggedBy.SelectedValue); command.Parameters.AddWithValue("@complete", 0); command.Parameters.AddWithValue("@date_logged", DateTime.Now); if (rdoYes.Checked == true) { command.Parameters.AddWithValue("@sandingTime", this.txtMins.Text); command.Parameters.AddWithValue("@sandedById", this.cmbSandBy.SelectedValue); command.Parameters.AddWithValue("@sandingExposurePoints", (Convert.ToDouble(this.txtMins.Text) / 60) * Convert.ToDouble(this.cmbTool.SelectedValue)); } else { command.Parameters.AddWithValue("@sandingTime", DBNull.Value); command.Parameters.AddWithValue("@sandedById", DBNull.Value); command.Parameters.AddWithValue("@sandingExposurePoints", DBNull.Value); } command.Parameters.AddWithValue("@repaint_from_dept", string.Format("Painting")); command.ExecuteNonQuery(); SqlStatements sql = new SqlStatements(); sql.UpdatePaintStock(int.Parse(paint_id.ToString()), int.Parse(txtKgs.Text)); this.Close(); } else { MessageBox.Show("There are invalid entries on the form. Please fill out all input areas", "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnRemove_Click(object sender, EventArgs e) { if (cmdOp.SelectedIndex > -1) { Operations op = new Operations(); SqlStatements sqlUpdate = new SqlStatements(); //NEEDS TO CHECK CELL VALUE Boolean checkGrid = GridCheck(cmdOp.Text); if (checkGrid == true) { MessageBox.Show("This operation has not been completed so cannot be removed.", "Cannot Remove", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int finishType = Int32.Parse(this.txtFinishID.Text); string short_op = ""; //DELETE FROM COMPLETION LOG sqlUpdate.DeletePartCompletion(Int32.Parse(txtSearch.Text), cmdOp.Text.ToString()); //ADD BACK TO DOOR switch (cmdOp.SelectedItem) { case "Up": short_op = "up"; break; case "Wash/Wipe": short_op = "ww"; break; case "Etch": short_op = "etch"; break; case "Sand": short_op = "sand"; break; case "Powder Prime": short_op = "pp"; break; case "Powder Coat": short_op = "pc"; break; case "Oven": short_op = "oven"; break; case "Wet Prep": short_op = "wp"; break; case "Wet Paint": short_op = "wet"; break; case "Oven 2": short_op = "oven1"; break; default: MessageBox.Show("No operation has been selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } sqlUpdate.AddToDoor(Int32.Parse(txtSearch.Text), op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), cmdOp.Text.ToString(), finishType) / int.Parse(txtQuantitySame.Text), short_op); //Remove from daily goals sqlUpdate.DeductDailyGoals(op.CalcTimeRemaining(Int32.Parse(txtSearch.Text), cmdOp.Text.ToString(), finishType)); //btnSearch_Click(sender, e); //REFRESH THE MAIN DATAGRID RefreshMainGrid(); } } else { MessageBox.Show("You must select an operation to continue!", "No operation", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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(); } }
public Tuple <int, int, int> GetAllInDept(string op) { DataSet ds = new DataSet(); ds.ReadXml(@"\\designsvr1\apps\Design and Supply CSharp\ShopFloorApps\PaintShop\xml.xml"); DataTable xmlDt = ds.Tables["Table1"]; string expression; string Staff1; string Staff2; string Staff3; int staffId1; int staffId2; int staffId3; expression = "Column4='" + op + "'"; DataRow[] results = xmlDt.Select(expression); Staff1 = Convert.ToString(results[0]["Column1"]); Staff2 = Convert.ToString(results[0]["Column2"]); Staff3 = Convert.ToString(results[0]["Column3"]); SqlStatements sql = new SqlStatements(); try { staffId1 = sql.GetStaffIDFromName(Staff1); } catch { staffId1 = 0; } try { staffId2 = sql.GetStaffIDFromName(Staff2); } catch { staffId2 = 0; } try { staffId3 = sql.GetStaffIDFromName(Staff3); } catch { staffId3 = 0; } var tuple = new Tuple <int, int, int>(staffId1, staffId2, staffId3); return(tuple); }