Пример #1
0
        public override void Siguiente()
        {
            int     u;
            eCHOFER o = new eCHOFER();

            o.CHO_codigo = Int32.TryParse(this.txtCodigo.Text.Trim(), out u) ? Convert.ToInt32(this.txtCodigo.Text.Trim()) : -1;
            cargarDatos(balCHOFER.siguienteRegistro(o));
        }
Пример #2
0
        private void btnGoChofer_Click(object sender, EventArgs e)
        {
            eCHOFER o = new eCHOFER();

            o.CHO_codigo = this.cmbChofer.SelectedValue != null?Convert.ToInt32(this.cmbChofer.SelectedValue.ToString()) : -1;

            frmDM_Chofer o2 = new frmDM_Chofer(o);

            o2.MdiParent = this.MdiParent;
            o2.Show();
        }
Пример #3
0
        public frmDM_Chofer(eCHOFER o)
        {
            InitializeComponent();
            tabla = "CHOFER";

            this.cmbVehiculo.ValueMember   = "VEH_placa";
            this.cmbVehiculo.DisplayMember = "VEH_nombre";
            this.cmbVehiculo.DataSource    = balVEHICULO.poblar();

            this._o = o;
        }
Пример #4
0
        public override bool Actualizar()
        {
            int  u;
            bool rpta = false;

            try
            {
                eCHOFER o = new eCHOFER();
                o.CHO_codigo          = Int32.TryParse(this.txtCodigo.Text.Trim(), out u) ? Convert.ToInt32(this.txtCodigo.Text.Trim()) : -1;
                o.CHO_nombre_completo = this.txtNombreCompleto.Text.Trim();
                o.CHO_dni             = this.txtDNI.Text.Trim();
                o.VEH_placa           = this.cmbVehiculo.SelectedValue != null?this.cmbVehiculo.SelectedValue.ToString() : "";

                o.CHO_licencia_conducir = this.txtLicencia.Text.Trim();

                if (balCHOFER.actualizarRegistro(o))
                {
                    mensaje("actualizar", "");
                    //MessageBox.Show("El registro fue actualizado correctamente.", "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.txtCodigo.ReadOnly = true;
                    rpta = true;
                }
            }
            catch (CustomException ex)
            {
                if (ex.tupla != null)
                {
                    foreach (Control c in this.gpbInformacion.Controls)
                    {
                        foreach (var item in ex.tupla)
                        {
                            if (c.Tag != null && c.Tag.ToString() == item.name)
                            {
                                errValidacion.SetError(c, item.message.ToString());
                            }
                        }
                    }
                    mensaje("subsanar", "");
                }
                else
                {
                    mensaje("corregir", ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurrió un error inesperado:\r\n" + ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(rpta);
        }
Пример #5
0
        public bool eliminarRegistro(eCHOFER oeCHOFER)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_crud_CHOFER_eliminarRegistro";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cnn.Open();

                cmd.Parameters.Add(new SqlParameter("@CHO_CODIGO", oeCHOFER.CHO_codigo));

                return(cmd.ExecuteNonQuery() > 0);
            }
        }
Пример #6
0
        public override void Buscar()
        {
            int          u;
            eCHOFER      o         = new eCHOFER();
            balCHOFER    b         = new balCHOFER();
            _frmBusqueda ventana   = new _frmBusqueda(false, "buscarRegistro", b);
            DialogResult respuesta = ventana.ShowDialog();

            if (respuesta == DialogResult.OK)
            {
                o.CHO_codigo = Int32.TryParse(ventana.pk, out u) ? Convert.ToInt32(ventana.pk) : -1;
                DataTable dt = balCHOFER.obtenerRegistro(o);
                cargarDatos(dt);
            }
        }
Пример #7
0
        public DataTable obtenerRegistroDetallado(eCHOFER oeCHOFER)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_bf_CHOFER_informacionDirigida_Programacion";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter dad = new SqlDataAdapter(cmd);
                dad.SelectCommand.Parameters.Add(new SqlParameter("@CHO_CODIGO", oeCHOFER.CHO_codigo));

                DataTable dt = new DataTable();
                dad.Fill(dt);

                return(dt);
            }
        }
Пример #8
0
        public DataTable siguienteRegistro(eCHOFER oeCHOFER)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_list_CHOFER_siguienteRegistro";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter dad = new SqlDataAdapter(cmd);
                dad.SelectCommand.Parameters.Add(new SqlParameter("@CHO_CODIGO", oeCHOFER.CHO_codigo));

                DataTable dt = new DataTable();
                dad.Fill(dt);

                return(dt);
            }
        }
Пример #9
0
        public override bool Eliminar()
        {
            int  u;
            bool rpta = false;

            try
            {
                eCHOFER o = new eCHOFER();
                o.CHO_codigo = Int32.TryParse(this.txtCodigo.Text.Trim(), out u) ? Convert.ToInt32(this.txtCodigo.Text.Trim()) : -1;

                if (balCHOFER.eliminarRegistro(o))
                {
                    mensaje("eliminar", "");
                    //MessageBox.Show("El registro fue eliminado correctamente.", "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.txtCodigo.ReadOnly = true;
                    rpta = true;
                }
            }
            catch (CustomException ex)
            {
                if (ex.tupla != null)
                {
                    foreach (Control c in this.gpbInformacion.Controls)
                    {
                        foreach (var item in ex.tupla)
                        {
                            if (c.Tag != null && c.Tag.ToString() == item.name)
                            {
                                errValidacion.SetError(c, item.message.ToString());
                            }
                        }
                    }
                    mensaje("subsanar", "");
                }
                else
                {
                    mensaje("corregir", ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurrió un error inesperado:\r\n" + ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(rpta);
        }
Пример #10
0
        public bool insertarRegistro(eCHOFER oeCHOFER)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_crud_CHOFER_insertarRegistro";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cnn.Open();

                cmd.Parameters.Add(new SqlParameter("@CHO_NOMBRE_COMPLETO", oeCHOFER.CHO_nombre_completo));     //variable tipo:string
                cmd.Parameters.Add(new SqlParameter("@CHO_DNI", oeCHOFER.CHO_dni));                             //variable tipo:string
                cmd.Parameters.Add(new SqlParameter("@VEH_PLACA", oeCHOFER.VEH_placa));                         //variable tipo:string
                cmd.Parameters.Add(new SqlParameter("@CHO_LICENCIA_CONDUCIR", oeCHOFER.CHO_licencia_conducir)); //variable tipo:string

                return(cmd.ExecuteNonQuery() > 0);
            }
        }
Пример #11
0
        private void InsertarFilaGrilla(int indiceFila, string nombreColumna)
        {
            if (nombreColumna == "CHO_nombre_completo")
            {
                balCHOFER _obalCHOFER = new balCHOFER();

                _frmBusqueda ventana   = new _frmBusqueda(false, "buscarRegistro", _obalCHOFER);
                DialogResult respuesta = ventana.ShowDialog();
                if (respuesta == DialogResult.OK)
                {
                    eCHOFER oeCHOFER = new eCHOFER();
                    oeCHOFER.CHO_codigo = Convert.ToInt16(ventana.pk);
                    DataTable dt = balCHOFER.obtenerRegistroDetallado(oeCHOFER);

                    if (dt != null)
                    {
                        this.dgvDetalle["CHO_codigo", indiceFila].Value          = dt.Rows[0]["CHO_codigo"].ToString();
                        this.dgvDetalle["CHO_nombre_completo", indiceFila].Value = dt.Rows[0]["CHO_nombre_completo"].ToString();
                        this.dgvDetalle["VEH_placa", indiceFila].Value           = dt.Rows[0]["VEH_placa"].ToString();
                        this.dgvDetalle["VEH_tonelaje", indiceFila].Value        = dt.Rows[0]["VEH_tonelaje"].ToString();
                        calcularNumeroViaje(indiceFila);
                        this.dgvDetalle.NotifyCurrentCellDirty(true);
                        this.dgvDetalle.NotifyCurrentCellDirty(false);
                    }
                }
            }

            if (nombreColumna == "VEH_placa")
            {
                balVEHICULO _obalVEHICULO = new balVEHICULO();

                _frmBusqueda ventana   = new _frmBusqueda(false, "buscarRegistro", _obalVEHICULO);
                DialogResult respuesta = ventana.ShowDialog();
                if (respuesta == DialogResult.OK)
                {
                    eVEHICULO oeVEHICULO = new eVEHICULO();
                    oeVEHICULO.VEH_placa = ventana.pk;
                    DataTable dt = balVEHICULO.obtenerRegistro(oeVEHICULO);

                    if (dt != null)
                    {
                        this.dgvDetalle["VEH_placa", indiceFila].Value    = dt.Rows[0]["VEH_placa"].ToString();
                        this.dgvDetalle["VEH_tonelaje", indiceFila].Value = dt.Rows[0]["VEH_tonelaje"].ToString();
                    }
                }
            }

            if (nombreColumna == "DPR_zona_desde")
            {
                balZONA       _obalZONA      = new balZONA();
                ePROGRAMACION oePROGRAMACION = new ePROGRAMACION();
                oePROGRAMACION.PRG_fecha = Convert.ToDateTime(this.dtpfecha.Value.ToShortDateString());

                _frmBusqueda ventana   = new _frmBusqueda(false, "buscarRegistroP", _obalZONA, oePROGRAMACION);
                DialogResult respuesta = ventana.ShowDialog();
                if (respuesta == DialogResult.OK)
                {
                    eZONA oeZONA = new eZONA();
                    oeZONA.ZON_codigo = Convert.ToInt16(ventana.pk);
                    DataTable dt = balZONA.obtenerRegistro(oeZONA);

                    if (dt != null)
                    {
                        this.dgvDetalle["DPR_zona_desde", indiceFila].Value = dt.Rows[0]["ZON_codigo"].ToString();
                    }
                    //
                    if (this.dgvDetalle["DPR_zona_hasta", indiceFila].Value != null)
                    {
                        DataTable dtInfo = new DataTable();
                        DateTime  fecha  = Convert.ToDateTime(this.dtpfecha.Value.ToShortDateString());
                        int       desde  = Convert.ToInt16(this.dgvDetalle["DPR_zona_desde", indiceFila].Value.ToString());
                        int       hasta  = Convert.ToInt16(this.dgvDetalle["DPR_zona_hasta", indiceFila].Value.ToString());
                        dtInfo = CompletarInformacionDirigida(fecha, desde, hasta);

                        this.dgvDetalle["DPR_peso", indiceFila].Value              = dtInfo.Rows[0]["PESO"].ToString();
                        this.dgvDetalle["DPR_numero_pedidos", indiceFila].Value    = dtInfo.Rows[0]["NDOC"].ToString();
                        this.dgvDetalle["DPR_cantidad_producto", indiceFila].Value = dtInfo.Rows[0]["CANPROD"].ToString();
                    }
                }
            }

            if (nombreColumna == "DPR_zona_hasta")
            {
                balZONA       _obalZONA      = new balZONA();
                ePROGRAMACION oePROGRAMACION = new ePROGRAMACION();
                oePROGRAMACION.PRG_fecha = Convert.ToDateTime(this.dtpfecha.Value.ToShortDateString());

                _frmBusqueda ventana   = new _frmBusqueda(false, "buscarRegistroP", _obalZONA, oePROGRAMACION);
                DialogResult respuesta = ventana.ShowDialog();
                if (respuesta == DialogResult.OK)
                {
                    eZONA oeZONA = new eZONA();
                    oeZONA.ZON_codigo = Convert.ToInt16(ventana.pk);
                    DataTable dt = balZONA.obtenerRegistro(oeZONA);

                    if (dt != null)
                    {
                        this.dgvDetalle["DPR_zona_hasta", indiceFila].Value = dt.Rows[0]["ZON_codigo"].ToString();
                    }
                    //
                    DataTable dtInfo = new DataTable();
                    DateTime  fecha  = Convert.ToDateTime(this.dtpfecha.Value.ToShortDateString());
                    int       desde  = Convert.ToInt16(this.dgvDetalle["DPR_zona_desde", indiceFila].Value.ToString());
                    int       hasta  = Convert.ToInt16(this.dgvDetalle["DPR_zona_hasta", indiceFila].Value.ToString());
                    dtInfo = CompletarInformacionDirigida(fecha, desde, hasta);

                    this.dgvDetalle["DPR_peso", indiceFila].Value              = dtInfo.Rows[0]["PESO"].ToString();
                    this.dgvDetalle["DPR_numero_pedidos", indiceFila].Value    = dtInfo.Rows[0]["NDOC"].ToString();
                    this.dgvDetalle["DPR_cantidad_producto", indiceFila].Value = dtInfo.Rows[0]["CANPROD"].ToString();
                }
            }
        }