Пример #1
0
        private void dgvAllocation_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvAllocation.SelectedCells.Count > 0)
            {
                int selectedrowindex = dgvAllocation.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = dgvAllocation.Rows[selectedrowindex];

                doorID      = Convert.ToInt32(selectedRow.Cells["id"].Value);
                operation   = selectedRow.Cells["section"].Value.ToString();
                timeStarted = selectedRow.Cells["Started Op"].Value.ToString();
            }



            if (e.ColumnIndex == dgvAllocation.Columns["Take Job"].Index)
            {
                UpdateDepartments ud = new UpdateDepartments(doorID, operation);

                if (string.IsNullOrWhiteSpace(timeStarted))
                {
                    ud.updateStarted(false);
                }
                else
                {
                    ud.updateStarted(true);
                }


                fillGrid();
            }


            if (e.ColumnIndex == dgvAllocation.Columns["Print Label"].Index)
            {
                PackingLabel pl = new PackingLabel();

                pl.printSmallPackingLabel(doorID.ToString());
                pl.printLargePackingLabel(doorID.ToString());
            }
        }
Пример #2
0
        private void btnComplete_Click(object sender, EventArgs e)
        {
            UpdateDepartments ud = new UpdateDepartments(_doorID, _dept);

            double n;
            bool   isNumeric = Double.TryParse(txtPercentage.Text, out n);

            if (cmbStaffID.SelectedIndex > -1)
            {
                if (isNumeric == true)
                {
                    if (n <= 100)
                    {
                        if (ud._SectionCompleteAmount < (n / 100))
                        {
                            //try
                            //{
                            double percentageToInsert = (n / 100) - ud._SectionCompleteAmount;
                            double valueTimeToInsert  = percentageToInsert * ud._SectionTime;
                            double valueToUpdateDoor  = percentageToInsert * ud._SectionTimeSingular;

                            SqlConnection conn = new SqlConnection(SqlStatements.ConnectionString);
                            conn.Open();
                            SqlCommand cmd = new SqlCommand();
                            cmd.Connection  = conn;
                            cmd.CommandText = "INSERT INTO dbo.door_part_completion_log(door_id, part_complete_date,time_for_part,part,part_status,staff_id,op,part_percent_complete)" +
                                              "values (@doorID,@completeDate,@timeForPart,@part,'Complete',@staffID,@op,@partPercentComplete)";
                            cmd.Parameters.AddWithValue("@doorID", _doorID);
                            cmd.Parameters.AddWithValue("@completeDate", DateTime.Now);
                            cmd.Parameters.AddWithValue("@timeForPart", valueTimeToInsert);
                            cmd.Parameters.AddWithValue("@part", "Part " + _dept);
                            cmd.Parameters.AddWithValue("@staffID", cmbStaffID.SelectedValue);
                            cmd.Parameters.AddWithValue("@op", _dept);
                            cmd.Parameters.AddWithValue("@partPercentComplete", percentageToInsert);

                            cmd.ExecuteNonQuery();
                            conn.Close();


                            ud.updateDoor(valueToUpdateDoor, n);
                            ud.calibrate();
                            MessageBox.Show("Section successfully Updated", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            if (n == 100 && _dept == "SL_Pack")
                            {
                                frmLooseItems frmLI = new frmLooseItems(_doorID);
                                frmLI.ShowDialog();
                            }

                            this.Close();
                            //}
                            //catch
                            //{
                            //MessageBox.Show("Ann error has occured. Please contact IT.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //}
                        }
                        else
                        {
                            MessageBox.Show("The value you have entered is less or equal to the current progress on the job (" + ud._SectionCompleteAmount * 100 + "%)", "Value lower than current progress", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Value must be less than or equal to 100!", "Value too high!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Only whole number percentages 1-100 can be used. No decimals allowed!", "Whole numbers", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please select a staff member before attempting to continue", "Select staff member", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }