Example #1
0
        public static void addNewChofer(ChoferDTO chofer)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("chof_nombre", chofer.nombre);
            parameters.Add("chof_apellido", chofer.apellido);
            parameters.Add("chof_dni", chofer.dni);
            parameters.Add("chof_mail", chofer.mail);
            parameters.Add("chof_telefono", chofer.telefono);
            parameters.Add("chof_direccion", chofer.direccion);
            parameters.Add("chof_fecha_nacimiento", chofer.fechaNacimiento);

            // El estado se habilita por defecto en 1.

            try
            {
                SQLManager.executePorcedure("altaChofer", parameters);
            }
            catch (SqlException exception)
            {
                if (exception.Number == 50000 || exception.Number == 70000)
                {
                    throw new ApplicationException(exception.Message);
                }
                else
                {
                    throw exception;
                }
            }
        }
Example #2
0
        public static void updateChofer(ChoferDTO chofer)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("chof_id", chofer.id);
            parameters.Add("chof_nombre", chofer.nombre);
            parameters.Add("chof_apellido", chofer.apellido);
            parameters.Add("chof_dni", chofer.dni);
            parameters.Add("chof_mail", chofer.mail);
            parameters.Add("chof_telefono", chofer.telefono);
            parameters.Add("chof_direccion", chofer.direccion);
            parameters.Add("chof_fecha_nacimiento", chofer.fechaNacimiento);
            parameters.Add("chof_activo", chofer.estado);

            // Usuario no se updetea

            try
            {
                SQLManager.executePorcedure("updateChofer", parameters);
            }
            catch (SqlException exception)
            {
                if (exception.Number == 50000)
                {
                    throw new ApplicationException(exception.Message);
                }
                else
                {
                    throw exception;
                }
            }
        }
Example #3
0
        public static List <ChoferDTO> ReaderToListChofer(SqlDataReader dataReader)
        {
            List <ChoferDTO> choferes = new List <ChoferDTO>();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    ChoferDTO chofer = new ChoferDTO();
                    chofer.id              = Convert.ToInt32(dataReader["chof_id"]);
                    chofer.dni             = Convert.ToInt64(dataReader["chof_dni"]);
                    chofer.nombre          = Convert.ToString(dataReader["chof_nombre"]);
                    chofer.apellido        = Convert.ToString(dataReader["chof_apellido"]);
                    chofer.mail            = Convert.ToString(dataReader["chof_mail"]);
                    chofer.direccion       = Convert.ToString(dataReader["chof_direccion"]);
                    chofer.telefono        = Convert.ToInt64(dataReader["chof_telefono"]);
                    chofer.fechaNacimiento = Convert.ToDateTime(dataReader["chof_fecha_nacimiento"]);
                    chofer.estado          = Convert.ToBoolean(dataReader["chof_activo"]);

                    choferes.Add(chofer);
                }
            }
            dataReader.Close();
            dataReader.Dispose();
            return(choferes);
        }
Example #4
0
        internal static void generarRendicion(ChoferDTO chofer, TurnoDTO turno, DateTime dateTime,
                                              double importeTotal, List <int> viajesParaRendirList)
        {
            try
            {
                DataTable table = new DataTable();
                table.Columns.Add("viaje_id", typeof(int));
                foreach (int viajeId in viajesParaRendirList)
                {
                    table.Rows.Add(viajeId);
                }

                Dictionary <string, object> parametros = new Dictionary <string, object>();
                parametros.Add("chof_id", chofer.id);
                parametros.Add("turno_id", turno.id);
                parametros.Add("fecha", dateTime);
                parametros.Add("importe_total", importeTotal);
                parametros.Add("viajes", table);

                SQLManager.executePorcedure("generarRendicion", parametros);
            }
            catch (SqlException exception)
            {
                if (exception.Number == 50000)
                {
                    throw new ApplicationException(exception.Message);
                }
                else
                {
                    throw exception;
                }
            }
        }
Example #5
0
        public static List <TurnoDTO> getTurnosViajesByChofer(ChoferDTO chofer)
        {
            SqlDataReader reader = SQLManager.executeProcedureList("getTurnosViajesByChofer",
                                                                   SQLManager.getSingleParams("chof_id", chofer.id));

            return(TurnoDAO.getTurnos(reader));
        }
Example #6
0
        private void agregarEditarChofer(ChoferDTO choferActivo)
        {
            if (this.edicion)
            {
                // Edicion
                try
                {
                    choferActivo.id = this.choferEdicion.id;

                    ChoferDAO.updateChofer(choferActivo);
                    MessageBox.Show("Se edito el chofer correctamente");
                    this.Close();
                    listener.onOperationFinish();
                }
                catch (ApplicationException ex)
                {
                    Utility.ShowError("Error al editar el chofer", ex);
                }
            }
            else
            {
                // Alta
                try
                {
                    ChoferDAO.addNewChofer(choferActivo);
                    MessageBox.Show("Se agrego el chofer correctamente");
                    this.Close();
                    listener.onOperationFinish();
                }
                catch (ApplicationException ex)
                {
                    Utility.ShowError("Error al agregar el turno", ex);
                }
            }
        }
Example #7
0
        public void onOperationFinishChofer(ChoferDTO chofer)
        {
            this.chofer                     = chofer;
            this.dniTextBox.Text            = chofer.dni.ToString();
            this.nombreApellidoTextBox.Text = chofer.nombre + " " + chofer.apellido;

            turnosChoferComboBox.DataSource = RendicionDAO.getTurnosViajesByChofer(chofer);
        }
Example #8
0
        public void onOperationFinishChofer(ChoferDTO chofer)
        {
            choferGlobal = chofer;

            txtNombreChofer.Text = chofer.nombre + " " + chofer.apellido;
            txtDNIChofer.Text    = chofer.dni.ToString();

            cargarAutomovilDisponible();
        }
Example #9
0
        public static SqlDataReader getViajesNoRendidos(ChoferDTO chofer, TurnoDTO turno, DateTime dateTime)
        {
            Dictionary <string, object> parametros = new Dictionary <string, object>();

            parametros.Add("chof_id", chofer.id);
            parametros.Add("turno_id", turno.id);
            parametros.Add("fecha", dateTime);
            parametros.Add("porcentaje_rendicion", Config.newInstance.porcentajeRendicion);

            return(SQLManager.executeProcedureList("getViajesNoRendidos", parametros));
        }
Example #10
0
 private bool setearVariables()
 {
     chofer = new ChoferDTO(txtNombre.Text
                            , txtApellido.Text
                            , Convert.ToInt64(txtDNI.Text)
                            , txtDireccion.Text
                            , Convert.ToInt64(txtTelefono.Text)
                            , txtMail.Text
                            , Convert.ToDateTime(dateFechaNac.Value)
                            , checkHabilitado.Checked);
     return(true);
 }
Example #11
0
        private void cargarDatosEdicion(int choferModificableID)
        {
            //Cargar todos los datos de los choferes
            choferEdicion = ChoferDAO.getChoferById(choferModificableID);

            this.choferEdicion.id = choferModificableID;

            this.txtNombre.Text     = choferEdicion.nombre;
            this.txtApellido.Text   = choferEdicion.apellido;
            this.txtDNI.Text        = choferEdicion.dni.ToString();
            this.txtDireccion.Text  = choferEdicion.direccion;
            this.txtTelefono.Text   = choferEdicion.telefono.ToString();
            this.dateFechaNac.Value = choferEdicion.fechaNacimiento;
            //this.checkHabilitado.Checked = Convert.ToBoolean(choferEdicion.estado);
            this.checkHabilitado.Checked = choferEdicion.estado;
            this.txtMail.Text            = choferEdicion.mail;
        }
Example #12
0
        private void cleanFields()
        {
            this.fechaRendicionDateTimePicker.Value = Config.newInstance.date;

            this.chofer                     = null;
            this.dniTextBox.Text            = "";
            this.nombreApellidoTextBox.Text = "";

            turnosChoferComboBox.DataSource = null;

            this.turno = null;
            inicioTurnoTextBox.Text = "";
            finTurnoTextBox.Text    = "";

            viajesParaRendirDataGridView.DataSource = null;

            viajesParaRendirList.Clear();

            importeTotal = 0;
            totalRendicionMontoLabel.Text = "";
        }
Example #13
0
        private void CargarDatosDeAutomovilAModificar()
        {
            cmbMarca.Text   = AutomovilAModificar.marca_nombre;
            cmbModelo.Text  = AutomovilAModificar.modelo_nombre;
            txtPatente.Text = AutomovilAModificar.patente;

            choferGlobal = ChoferDAO.getChoferByAutomovilId(AutomovilAModificar.id);


            txtChoferDni.Text            = choferGlobal.dni.ToString();
            txtChoferNombreCompleto.Text = choferGlobal.nombre + " " + choferGlobal.apellido;

            turnos = TurnoDAO.getTurnosByAutomovilId(AutomovilAModificar.id);

            foreach (TurnoDTO turno in turnos)
            {
                dgvTurnos.Rows.Add(turno.descripcion, turno.horaInicial, turno.horaFinal);
            }
            chkAutoActivo.Checked = AutomovilAModificar.activo;

            txtLicencia.Text   = AutomovilAModificar.licencia;
            txtAutoRodado.Text = AutomovilAModificar.rodado;
        }
Example #14
0
 public void onOperationFinishChofer(ChoferDTO chofer)
 {
     choferGlobal                 = chofer;
     txtChoferDni.Text            = chofer.dni.ToString();
     txtChoferNombreCompleto.Text = chofer.nombre + " " + chofer.apellido;
 }
 public void onOperationFinishChofer(ChoferDTO chofer)
 {
     //Do nothing
 }