示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Desea guardar el tiempo total del codigo?", "Guardar Codigo de trabajo", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                timerTotal.Stop();
                FinTotal    = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;
                tiempoTotal = horaTotal + ":";
                if (minTotal < 10)
                {
                    tiempoTotal += "0" + minTotal + ":";
                }
                else
                {
                    tiempoTotal += minTotal + ":";
                }
                if (segTotal < 10)
                {
                    tiempoTotal += "0" + segTotal;
                }
                else
                {
                    tiempoTotal += segTotal;
                }
                if (con.AñadirTiempoTotal(Iniciototal, FinTotal, tiempoTotal, codigodetrabajo, op.Codigo, bandejasmalas))
                {
                    segTotal      = 0;
                    minTotal      = 0;
                    horaTotal     = 0;
                    bandejasmalas = 0;
                    MessageBox.Show("Se ha guardado correctamente el tiempo total del codigo " + codigodetrabajo, "Guardar ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Error en la base de datos", "Guardar Atasco", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }


                comboBoxCodigoTrabajo.Enabled = true;
                btnFinParada.Enabled          = false;
                btnInicioParada.Enabled       = false;
                btnInicioAtasco.Enabled       = false;
                btnfinatasco.Enabled          = false;
                btnGuaradarParada.Enabled     = false;
                btnGuardarAtasco.Enabled      = false;
            }
            else if (result == DialogResult.No)
            {
                timerTotal.Stop();
                segTotal  = 0;
                minTotal  = 0;
                horaTotal = 0;
                comboBoxCodigoTrabajo.Enabled = true;
                btnFinParada.Enabled          = false;
                btnInicioParada.Enabled       = false;
                btnInicioAtasco.Enabled       = false;
                btnfinatasco.Enabled          = false;
                btnGuaradarParada.Enabled     = false;
                btnGuardarAtasco.Enabled      = false;
                btnAñadirbandeja.Enabled      = false;
                btnquitarBandeja.Enabled      = false;
            }
            tiempoTotal = "";
        }