예제 #1
0
        public int tieneViajes(int id_recorrido)
        {
            Conexion conn = new Conexion();
            SqlCommand sp_recorrido_alta;
            Funciones func = new Funciones();

            sp_recorrido_alta = new SqlCommand("SASHAILO.sp_tiene_viajes_recorrido", conn.miConexion); // Lo inicializo
            sp_recorrido_alta.CommandType = CommandType.StoredProcedure; // Defino que tipo de comando es
            SqlParameter ID_RECORRIDO = sp_recorrido_alta.Parameters.Add("@p_id_recorrido", SqlDbType.BigInt);
            SqlParameter FECHA = sp_recorrido_alta.Parameters.Add("@p_fecha", SqlDbType.DateTime);
            SqlParameter TIENE_VIAJES = sp_recorrido_alta.Parameters.Add("@tieneViajes", SqlDbType.Int);

            ID_RECORRIDO.Value = id_recorrido;
            FECHA.Value = func.getFechaActual();
            TIENE_VIAJES.Direction = ParameterDirection.Output;

            int tieneViajes = 0;

            try
            {
                sp_recorrido_alta.ExecuteNonQuery();
                tieneViajes = Convert.ToInt16(sp_recorrido_alta.Parameters["@tieneViajes"].Value.ToString());
            }
            catch (Exception error)
            {
                conn.desconectar();
            }
            conn.desconectar();

            return tieneViajes;
        }
예제 #2
0
        public int cancelarViajes(int id_recorrido)
        {
            Conexion conn = new Conexion();
            SqlCommand sp_recorrido_alta;
            Funciones func = new Funciones();

            sp_recorrido_alta = new SqlCommand("SASHAILO.reco_cancelar_viajes", conn.miConexion); // Lo inicializo
            sp_recorrido_alta.CommandType = CommandType.StoredProcedure; // Defino que tipo de comando es
            SqlParameter ID_RECORRIDO = sp_recorrido_alta.Parameters.Add("@p_id_recorrido", SqlDbType.BigInt);
            SqlParameter FECHA = sp_recorrido_alta.Parameters.Add("@p_f_actual", SqlDbType.DateTime);
            SqlParameter V_CANCELADOS = sp_recorrido_alta.Parameters.Add("@viajesCancelados", SqlDbType.Int);
            SqlParameter P_CANCELADOS = sp_recorrido_alta.Parameters.Add("@pasajesCancelados", SqlDbType.Int);
            SqlParameter E_CANCELADAS = sp_recorrido_alta.Parameters.Add("@encoCanceladas", SqlDbType.Int);

            ID_RECORRIDO.Value = id_recorrido;
            FECHA.Value = func.getFechaActual();
            V_CANCELADOS.Direction = ParameterDirection.Output;
            P_CANCELADOS.Direction = ParameterDirection.Output;
            E_CANCELADAS.Direction = ParameterDirection.Output;

            int cantViajes = 0;

            try
            {
                sp_recorrido_alta.ExecuteNonQuery();
                cantViajes = Convert.ToInt16(sp_recorrido_alta.Parameters["@viajesCancelados"].Value.ToString());
            }
            catch (Exception error)
            {
                conn.desconectar();
            }
            conn.desconectar();

            return cantViajes;
        }
예제 #3
0
        public void mostrarComprobante()
        {
            gb_compra.Visible = false;
            gb_cliente.Visible = false;
            gb_pago.Visible = false;
            b_guardar.Text = "Aceptar";
            this.mostroComprobante = true;
            this.Text = "Comprobante de la Compra";

            Label label_a = new System.Windows.Forms.Label();
            Label label_cod_compra = new System.Windows.Forms.Label();
            Label label_b = new System.Windows.Forms.Label();
            Label label_fecha_compra = new System.Windows.Forms.Label();
            Label label_c = new System.Windows.Forms.Label();
            Label label_cli_compra = new System.Windows.Forms.Label();
            Label label_d = new System.Windows.Forms.Label();
            Label label_importe_compra = new System.Windows.Forms.Label();
            GroupBox gb_detalle_compra = new System.Windows.Forms.GroupBox();
            Panel panel_pasajes = new System.Windows.Forms.Panel();
            Label label_e = new System.Windows.Forms.Label();
            Label label_f = new System.Windows.Forms.Label();
            Panel panel_encomiendas = new System.Windows.Forms.Panel();
            panel_pasajes.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            panel_encomiendas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            gb_detalle_compra.SuspendLayout();
            this.SuspendLayout();
            //
            // label_a
            //
            label_a.AutoSize = true;
            label_a.Location = new System.Drawing.Point(24, 27);
            label_a.Name = "label_a";
            label_a.Size = new System.Drawing.Size(97, 13);
            label_a.TabIndex = 4;
            label_a.Text = "Código de Compra:";
            //
            // label_cod_compra
            //
            label_cod_compra.AutoSize = true;
            label_cod_compra.ForeColor = System.Drawing.Color.Green;
            label_cod_compra.Location = new System.Drawing.Point(126, 27);
            label_cod_compra.Name = "label_cod_compra";
            label_cod_compra.Size = new System.Drawing.Size(10, 13);
            label_cod_compra.TabIndex = 5;
            label_cod_compra.Text = "-";
            //
            // label_b
            //
            label_b.AutoSize = true;
            label_b.Location = new System.Drawing.Point(265, 27);
            label_b.Name = "label_b";
            label_b.Size = new System.Drawing.Size(40, 13);
            label_b.TabIndex = 6;
            label_b.Text = "Fecha:";
            //
            // label_fecha_compra
            //
            label_fecha_compra.AutoSize = true;
            label_fecha_compra.ForeColor = System.Drawing.Color.Green;
            label_fecha_compra.Location = new System.Drawing.Point(308, 27);
            label_fecha_compra.Name = "label_fecha_compra";
            label_fecha_compra.Size = new System.Drawing.Size(10, 13);
            label_fecha_compra.TabIndex = 7;
            label_fecha_compra.Text = "-";
            //
            // label_c
            //
            label_c.AutoSize = true;
            label_c.Location = new System.Drawing.Point(412, 27);
            label_c.Name = "label_c";
            label_c.Size = new System.Drawing.Size(42, 13);
            label_c.TabIndex = 12;
            label_c.Text = "Cliente:";
            //
            // label_cli_compra
            //
            label_cli_compra.AutoSize = true;
            label_cli_compra.ForeColor = System.Drawing.Color.Green;
            label_cli_compra.Location = new System.Drawing.Point(460, 27);
            label_cli_compra.Name = "label_cli_compra";
            label_cli_compra.Size = new System.Drawing.Size(10, 13);
            label_cli_compra.TabIndex = 13;
            label_cli_compra.Text = "-";
            //
            // label_d
            //
            label_d.AutoSize = true;
            label_d.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label_d.Location = new System.Drawing.Point(24, 56);
            label_d.Name = "label_d";
            label_d.Size = new System.Drawing.Size(53, 13);
            label_d.TabIndex = 18;
            label_d.Text = "Importe:";
            //
            // label_importe_compra
            //
            label_importe_compra.AutoSize = true;
            label_importe_compra.ForeColor = System.Drawing.Color.Green;
            label_importe_compra.Location = new System.Drawing.Point(83, 56);
            label_importe_compra.Name = "label_importe_compra";
            label_importe_compra.Size = new System.Drawing.Size(10, 13);
            label_importe_compra.TabIndex = 19;
            label_importe_compra.Text = "-";
            //
            // gb_detalle_compra
            //
            gb_detalle_compra.Controls.Add(label_f);
            gb_detalle_compra.Controls.Add(panel_encomiendas);
            gb_detalle_compra.Controls.Add(label_e);
            gb_detalle_compra.Controls.Add(panel_pasajes);
            gb_detalle_compra.Controls.Add(label_importe_compra);
            gb_detalle_compra.Controls.Add(label_d);
            gb_detalle_compra.Controls.Add(label_cli_compra);
            gb_detalle_compra.Controls.Add(label_c);
            gb_detalle_compra.Controls.Add(label_fecha_compra);
            gb_detalle_compra.Controls.Add(label_b);
            gb_detalle_compra.Controls.Add(label_cod_compra);
            gb_detalle_compra.Controls.Add(label_a);
            gb_detalle_compra.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            gb_detalle_compra.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
            gb_detalle_compra.Location = new System.Drawing.Point(24, 12);
            gb_detalle_compra.Name = "gb_detalle_compra";
            gb_detalle_compra.Size = new System.Drawing.Size(669, 443);
            gb_detalle_compra.TabIndex = 9;
            gb_detalle_compra.TabStop = false;
            gb_detalle_compra.Text = "Detalle de la Compra";
            //
            // panel_pasajes
            //
            panel_pasajes.Location = new System.Drawing.Point(27, 122);
            panel_pasajes.Name = "panel_pasajes";
            panel_pasajes.Size = new System.Drawing.Size(612, 133);
            panel_pasajes.TabIndex = 20;
            //
            // label_e
            //
            label_e.AutoSize = true;
            label_e.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label_e.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
            label_e.Location = new System.Drawing.Point(26, 102);
            label_e.Name = "label_e";
            label_e.Size = new System.Drawing.Size(51, 13);
            label_e.TabIndex = 21;
            label_e.Text = "Pasajes";
            //
            // label_f
            //
            label_f.AutoSize = true;
            label_f.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label_f.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
            label_f.Location = new System.Drawing.Point(26, 265);
            label_f.Name = "label_f";
            label_f.Size = new System.Drawing.Size(82, 13);
            label_f.TabIndex = 23;
            label_f.Text = "Encomiendas";
            //
            // panel_encomiendas
            //
            panel_encomiendas.Location = new System.Drawing.Point(27, 285);
            panel_encomiendas.Name = "panel_encomiendas";
            panel_encomiendas.Size = new System.Drawing.Size(612, 133);
            panel_encomiendas.TabIndex = 22;
            //
            // Funciones
            //

            panel_pasajes.AutoScroll = true;
            panel_encomiendas.AutoScroll = true;

            /*inicio - pongo los datos en pantalla*/
            Funciones fun = new Funciones();
            label_cod_compra.Text = this.id_compra_generada.ToString(); ;
            label_fecha_compra.Text = fun.getFechaActual().Day.ToString() + "/" + fun.getFechaActual().Month.ToString() + "/" + fun.getFechaActual().Year.ToString();
            label_cli_compra.Text = this.cliente.nombre + " " + this.cliente.apellido + " (" + this.cliente.dni + ")";
            label_importe_compra.Text = "$" + this.precio_total.ToString();

            //cargo panel pasajes
            Label lab_head_cod = new System.Windows.Forms.Label();
            lab_head_cod.Location = new System.Drawing.Point(25, 1);
            lab_head_cod.Size = new System.Drawing.Size(46, 13);
            lab_head_cod.ForeColor = System.Drawing.Color.Indigo;
            lab_head_cod.Text = "Código";
            Label lab_head_pas = new System.Windows.Forms.Label();
            lab_head_pas.Location = new System.Drawing.Point(175, 1);
            lab_head_pas.Size = new System.Drawing.Size(50, 13);
            lab_head_pas.ForeColor = System.Drawing.Color.Indigo;
            lab_head_pas.Text = "Pasajero";
            Label lab_head_but = new System.Windows.Forms.Label();
            lab_head_but.Location = new System.Drawing.Point(400, 1);
            lab_head_but.Size = new System.Drawing.Size(50, 13);
            lab_head_but.ForeColor = System.Drawing.Color.Indigo;
            lab_head_but.Text = "Butaca";
            Label lab_head_precio = new System.Windows.Forms.Label();
            lab_head_precio.Location = new System.Drawing.Point(530, 1);
            lab_head_precio.Size = new System.Drawing.Size(50, 13);
            lab_head_precio.ForeColor = System.Drawing.Color.Indigo;
            lab_head_precio.Text = "Precio";

            panel_pasajes.Controls.Add(lab_head_cod);
            panel_pasajes.Controls.Add(lab_head_pas);
            panel_pasajes.Controls.Add(lab_head_but);
            panel_pasajes.Controls.Add(lab_head_precio);

            int heig = 20;
            foreach (Nuevo_Pasaje.Pasaje pas in this.lista_pasajes)
            {
                Label label_cod_pasaje = new System.Windows.Forms.Label();
                label_cod_pasaje.Location = new System.Drawing.Point(20, heig);
                label_cod_pasaje.Size = new System.Drawing.Size(55, 13);
                label_cod_pasaje.Text = pas.id_pasaje_gen.ToString();
                panel_pasajes.Controls.Add(label_cod_pasaje);

                Label label_pasajero_pasaje = new System.Windows.Forms.Label();
                label_pasajero_pasaje.Location = new System.Drawing.Point(115, heig);
                label_pasajero_pasaje.Size = new System.Drawing.Size(230, 13);
                label_pasajero_pasaje.Text = pas.cliente.nombre + " " + pas.cliente.apellido + " (" + pas.cliente.dni + ")";

                Label label_butaca_pasaje = new System.Windows.Forms.Label();
                label_butaca_pasaje.Location = new System.Drawing.Point(355, heig);
                label_butaca_pasaje.Name = "label_butaca_pasaje";
                label_butaca_pasaje.Size = new System.Drawing.Size(150, 13);
                label_butaca_pasaje.Text = "Nro: " + pas.butaca.nro_butaca + " - " + pas.butaca.tipo_butaca + " - Piso: " + pas.butaca.piso_butaca;

                Label label_precio_pasaje = new System.Windows.Forms.Label();
                label_precio_pasaje.Location = new System.Drawing.Point(528, heig);
                label_precio_pasaje.Size = new System.Drawing.Size(50, 13);
                label_precio_pasaje.Text = "$"+pas.precio.ToString();

                panel_pasajes.Controls.Add(label_cod_pasaje);
                panel_pasajes.Controls.Add(label_pasajero_pasaje);
                panel_pasajes.Controls.Add(label_butaca_pasaje);
                panel_pasajes.Controls.Add(label_precio_pasaje);

                heig = heig + 20;

            }

            //cargo panel encomiendas
            Label lab_head_cod_enco = new System.Windows.Forms.Label();
            lab_head_cod_enco.Location = new System.Drawing.Point(25, 1);
            lab_head_cod_enco.Size = new System.Drawing.Size(46, 13);
            lab_head_cod_enco.ForeColor = System.Drawing.Color.Indigo;
            lab_head_cod_enco.Text = "Código";
            Label lab_head_duenio = new System.Windows.Forms.Label();
            lab_head_duenio.Location = new System.Drawing.Point(175, 1);
            lab_head_duenio.Size = new System.Drawing.Size(75, 13);
            lab_head_duenio.ForeColor = System.Drawing.Color.Indigo;
            lab_head_duenio.Text = "Encomendero";
            Label lab_head_kg = new System.Windows.Forms.Label();
            lab_head_kg.Location = new System.Drawing.Point(400, 1);
            lab_head_kg.Size = new System.Drawing.Size(70, 13);
            lab_head_kg.ForeColor = System.Drawing.Color.Indigo;
            lab_head_kg.Text = "Cantidad Kg";
            Label lab_head_precio_enco = new System.Windows.Forms.Label();
            lab_head_precio_enco.Location = new System.Drawing.Point(530, 1);
            lab_head_precio_enco.Size = new System.Drawing.Size(50, 13);
            lab_head_precio_enco.ForeColor = System.Drawing.Color.Indigo;
            lab_head_precio_enco.Text = "Precio";

            panel_encomiendas.Controls.Add(lab_head_cod_enco);
            panel_encomiendas.Controls.Add(lab_head_duenio);
            panel_encomiendas.Controls.Add(lab_head_kg);
            panel_encomiendas.Controls.Add(lab_head_precio_enco);

            heig = 20;
            foreach (Nueva_Encomienda.Encomienda enco in this.lista_encomiendas)
            {
                Label label_cod_encomienda = new System.Windows.Forms.Label();
                label_cod_encomienda.Location = new System.Drawing.Point(20, heig);
                label_cod_encomienda.Size = new System.Drawing.Size(55, 13);
                label_cod_encomienda.Text = enco.id_encomienda_gen.ToString();

                Label label_pasajero_enco = new System.Windows.Forms.Label();
                label_pasajero_enco.Location = new System.Drawing.Point(115, heig);
                label_pasajero_enco.Size = new System.Drawing.Size(280, 13);
                label_pasajero_enco.Text = enco.cliente.nombre + " " + enco.cliente.apellido + " (" + enco.cliente.dni + ")";

                Label label_kg_enco = new System.Windows.Forms.Label();
                label_kg_enco.Location = new System.Drawing.Point(415, heig);
                label_kg_enco.Size = new System.Drawing.Size(50, 13);
                label_kg_enco.Text = enco.cant_kg.ToString();

                Label label_precio_enco = new System.Windows.Forms.Label();
                label_precio_enco.Location = new System.Drawing.Point(523, heig);
                label_precio_enco.Size = new System.Drawing.Size(50, 13);
                label_precio_enco.Text = "$"+enco.precio.ToString();

                panel_encomiendas.Controls.Add(label_cod_encomienda);
                panel_encomiendas.Controls.Add(label_pasajero_enco);
                panel_encomiendas.Controls.Add(label_kg_enco);
                panel_encomiendas.Controls.Add(label_precio_enco);

                heig = heig + 20;

            }

            /*fin - pongo los datos en pantalla*/

            this.Controls.Add(gb_detalle_compra);
            gb_detalle_compra.ResumeLayout(false);
            gb_detalle_compra.PerformLayout();
            this.ResumeLayout(false);

            MessageBox.Show("La Compra ha sido registrada", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
예제 #4
0
        public int grabaCompra(int id_cliente)
        {
            Conexion conn = new Conexion();
            SqlCommand sp_alta;
            int id_compra_generada;

            sp_alta = new SqlCommand("SASHAILO.sp_alta_compra", conn.miConexion); // Lo inicializo
            sp_alta.CommandType = CommandType.StoredProcedure; // Defino que tipo de comando es
            SqlParameter ID_CLIENTE = sp_alta.Parameters.Add("@p_id_cliente", SqlDbType.Int);
            SqlParameter F_COMPRA = sp_alta.Parameters.Add("@p_f_compra", SqlDbType.DateTime);
            SqlParameter IMPORTE = sp_alta.Parameters.Add("@p_importe", SqlDbType.Decimal);
            SqlParameter ID_MEDIO_PAGO = sp_alta.Parameters.Add("@p_id_medio_pago", SqlDbType.Int);
            SqlParameter NRO_TARJETA = sp_alta.Parameters.Add("@p_nro_tarjeta", SqlDbType.VarChar, 16);
            SqlParameter ID_COMPRA_GEN = sp_alta.Parameters.Add("@p_id_compra_gen", SqlDbType.Int);
            SqlParameter HAY_ERROR_USER = sp_alta.Parameters.Add("@hayErr", SqlDbType.Int);
            SqlParameter ERRORES_USER = sp_alta.Parameters.Add("@errores", SqlDbType.VarChar, 200);

            Funciones func = new Funciones();

            ID_CLIENTE.Value = id_cliente;
            F_COMPRA.Value = func.getFechaActual();
            IMPORTE.Value = this.precio_total;
            ID_MEDIO_PAGO.Value = ((ComboboxItem)c_tipo_pago.SelectedItem).Value;
            if (((ComboboxItem)c_tipo_pago.SelectedItem).Value == 1)
                NRO_TARJETA.Value = DBNull.Value;
            else
                NRO_TARJETA.Value = n_tarjeta.Text.Trim();

            ID_COMPRA_GEN.Direction = ParameterDirection.Output;
            HAY_ERROR_USER.Direction = ParameterDirection.Output;
            ERRORES_USER.Direction = ParameterDirection.Output;

            try
            {
                sp_alta.ExecuteNonQuery();
                int hayError = Convert.ToInt16(sp_alta.Parameters["@hayErr"].Value.ToString());
                if (hayError == 1)
                {
                    string errores = sp_alta.Parameters["@errores"].Value.ToString();
                    conn.desconectar();
                    return -1;
                }
                id_compra_generada = Convert.ToInt32(sp_alta.Parameters["@p_id_compra_gen"].Value.ToString());
            }
            catch (Exception error)
            {
                conn.desconectar();
                return -1;
            }
            conn.desconectar();

            return id_compra_generada;
        }
예제 #5
0
        private void listado_micros_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (false && e.ColumnIndex == 10)
            {
                Int32 id_micro = Convert.ToInt32(listado_micros.Rows[e.RowIndex].Cells["id_micro"].Value.ToString());
                String fin_vida_util = (listado_micros.Rows[e.RowIndex].Cells["fin_vida_util"].Value.ToString().Equals("N")) ? "S" : "N";
                Conexion conn = new Conexion();
                SqlCommand sp;
                Funciones func = new Funciones();
                sp = new SqlCommand("SASHAILO.fin_vida_util_micro", conn.miConexion); // Lo inicializo
                sp.CommandType = CommandType.StoredProcedure; // Defino que tipo de comando es
                SqlParameter ID_MICRO = sp.Parameters.Add("@p_id_micro", SqlDbType.Int);
                SqlParameter M_BAJA_DEFINITIVA = sp.Parameters.Add("@p_m_baja_definitiva", SqlDbType.Char, 1);
                SqlParameter F_BAJA_DEFINITIVA = sp.Parameters.Add("@p_f_baja_definitiva", SqlDbType.DateTime);
                SqlParameter FECHA = sp.Parameters.Add("@p_fecha", SqlDbType.DateTime);
                SqlParameter HAY_ERROR = sp.Parameters.Add("@hayErr", SqlDbType.Int);
                SqlParameter ERRORES = sp.Parameters.Add("@errores", SqlDbType.VarChar, 200);

                ID_MICRO.Value = id_micro;
                M_BAJA_DEFINITIVA.Value = fin_vida_util;
                FECHA.Value = func.getFechaActual();
                if (fin_vida_util.Equals("S"))
                    F_BAJA_DEFINITIVA.Value = Convert.ToDateTime(ConfigurationSettings.AppSettings["fechaActual"]);
                else
                    F_BAJA_DEFINITIVA.Value = DBNull.Value;

                HAY_ERROR.Direction = ParameterDirection.Output;
                ERRORES.Direction = ParameterDirection.Output;

                try
                {
                    sp.ExecuteNonQuery();

                    int hayError = Convert.ToInt16(sp.Parameters["@hayErr"].Value.ToString());
                    if (hayError == 1)
                    {
                        string errores = sp.Parameters["@errores"].Value.ToString();
                        MessageBox.Show("Error: \n" + errores, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        conn.desconectar();
                        return;
                    }
                    if(fin_vida_util.Equals("S"))
                        MessageBox.Show("El fin de la vida útil del Micro ha sido registrado", "", MessageBoxButtons.OK);
                    else
                        MessageBox.Show("El micro aún posee vida útil", "", MessageBoxButtons.OK);
                    conn.desconectar();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al guardar los datos: " + error.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    conn.desconectar();
                    return;
                }

                b_buscar_Click(null, null);

            }

            if (e.ColumnIndex == 10)
            {
                Modif_Micro modificacion = new Modif_Micro();
                Int32 id_micro = Convert.ToInt32(listado_micros.Rows[e.RowIndex].Cells["id_micro"].Value.ToString());
                modificacion.cargarDatos(id_micro);
                modificacion.Text = "Modificacion de Micro";
                modificacion.Tag = this;
                modificacion.ShowDialog();
                b_buscar_Click(null, null);
            }
        }
예제 #6
0
        private void b_guardar_Click(object sender, EventArgs e)
        {
            string str_errores = "";
            string error_fechas = "";
            if (!validarPatente())
                str_errores = "La patente debe tener el formato ABC-123\n";
            if (patenteDuplicada())
                str_errores = "La patente ingresada ya existe en el sistema\n";
            if (((ComboboxItem)combo_marca.SelectedItem) == null)
                str_errores = str_errores + "Debe seleccionar una marca\n";
            if (modelo.Text.Trim().Equals(""))
                str_errores = str_errores + "Debe ingresar un modelo\n";
            if (((ComboboxItem)combo_servicio.SelectedItem) == null)
                str_errores = str_errores + "Debe seleccionar un tipo de servicio\n";
            if (cant_kg.Text.Trim().Equals(""))
                str_errores = str_errores + "Debe ingresar la cantidad de kg\n";
            if (fuera_servicio.Checked){
                error_fechas = fechasFueraServicioValidas();
                str_errores = str_errores + error_fechas;
            }
            if (baja_definitiva.Checked){
                error_fechas = fechaBajaDefinitivaValida();
                str_errores = str_errores + error_fechas;
            }
            if (!str_errores.Equals(""))
            {
                MessageBox.Show(str_errores, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            //no confirma el popup
            if ((baja_definitiva.Checked || fuera_servicio.Checked) && !evaluarMicroFServicio())
                return;

            Conexion conn = new Conexion();
            SqlCommand sp_modif;
            Funciones func = new Funciones();

            string msj = "";

            sp_modif = new SqlCommand("SASHAILO.modif_micro", conn.miConexion); // Lo inicializo
            sp_modif.CommandType = CommandType.StoredProcedure; // Defino que tipo de comando es
            SqlParameter ID_MICRO = sp_modif.Parameters.Add("@p_id_micro", SqlDbType.Int);
            SqlParameter PATENTE = sp_modif.Parameters.Add("@p_patente", SqlDbType.VarChar, 7);
            SqlParameter ID_MARCA = sp_modif.Parameters.Add("@p_id_marca", SqlDbType.Int);
            SqlParameter MODELO = sp_modif.Parameters.Add("@p_modelo", SqlDbType.VarChar, 25);
            SqlParameter ID_TIPO_SERVICIO = sp_modif.Parameters.Add("@p_id_tipo_servicio", SqlDbType.Int);
            SqlParameter M_FUERA_SERVICIO = sp_modif.Parameters.Add("@p_m_fuera_servicio", SqlDbType.Char, 1);
            SqlParameter F_FUERA_SERVICIO = sp_modif.Parameters.Add("@p_f_fuera_servicio", SqlDbType.DateTime);
            SqlParameter FECHA = sp_modif.Parameters.Add("@p_fecha", SqlDbType.DateTime);
            SqlParameter F_REINICIO_SERVICIO = sp_modif.Parameters.Add("@p_f_reinicio_servicio", SqlDbType.DateTime);
            SqlParameter M_BAJA_DEFINITIVA = sp_modif.Parameters.Add("@p_m_baja_definitiva", SqlDbType.Char, 1);
            SqlParameter F_BAJA_DEFINITIVA = sp_modif.Parameters.Add("@p_f_baja_definitiva", SqlDbType.DateTime);
            SqlParameter CANT_KG = sp_modif.Parameters.Add("@p_cant_kg", SqlDbType.BigInt);
            SqlParameter HAY_ERROR_USER = sp_modif.Parameters.Add("@hayErr", SqlDbType.Int);
            SqlParameter ERRORES_USER = sp_modif.Parameters.Add("@errores", SqlDbType.VarChar, 200);

            ID_MICRO.Value = this.id_micro;
            PATENTE.Value = patente.Text.Trim().ToUpper();
            ID_MARCA.Value = ((ComboboxItem)combo_marca.SelectedItem).Value;
            MODELO.Value = modelo.Text.Trim();
            ID_TIPO_SERVICIO.Value = ((ComboboxItem)combo_servicio.SelectedItem).Value;
            M_FUERA_SERVICIO.Value = (fuera_servicio.Checked) ? 'S' : 'N';
            FECHA.Value = func.getFechaActual();
            if (fuera_servicio.Checked){
                F_FUERA_SERVICIO.Value = f_fuera_servicio.Value.Date;
                F_REINICIO_SERVICIO.Value = f_reinicio_servicio.Value.Date;
            }else{
                F_FUERA_SERVICIO.Value = DBNull.Value;
                F_REINICIO_SERVICIO.Value = DBNull.Value;
            }
            M_BAJA_DEFINITIVA.Value = (baja_definitiva.Checked) ? 'S' : 'N';
            if (baja_definitiva.Checked){
                F_BAJA_DEFINITIVA.Value = f_baja_def.Value.Date;
            }else{
                F_BAJA_DEFINITIVA.Value = DBNull.Value;
            }
            CANT_KG.Value = cant_kg.Text.Trim();
            HAY_ERROR_USER.Direction = ParameterDirection.Output;
            ERRORES_USER.Direction = ParameterDirection.Output;

            try
            {
                sp_modif.ExecuteNonQuery();

                int hayError = Convert.ToInt16(sp_modif.Parameters["@hayErr"].Value.ToString());
                if (hayError == 1)
                {
                    string errores = sp_modif.Parameters["@errores"].Value.ToString();
                    MessageBox.Show("Error: \n" + errores, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    conn.desconectar();
                    return;
                }

                conn.desconectar();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error en la modificacion del micro. Error: " + error.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                conn.desconectar();
                return;
            }

            if (!fuera_servicio.Checked && !baja_definitiva.Checked)
            {
                MessageBox.Show("Los datos del Micro han sido modificados", null, MessageBoxButtons.OK);
                Modif_Micro.ActiveForm.Close();
                return;
            }

            //cancelacion de viajes, pasajes y encomiendas
            Conexion conn2 = new Conexion();
            SqlCommand sp_modif2;

            sp_modif2 = new SqlCommand("SASHAILO.mic_fs_reemplazar_cancelar", conn2.miConexion); // Lo inicializo
            sp_modif2.CommandType = CommandType.StoredProcedure; // Defino que tipo de comando es
            SqlParameter ID_MICRO2 = sp_modif2.Parameters.Add("@p_id_micro", SqlDbType.Int);
            SqlParameter F_ACTUAL = sp_modif2.Parameters.Add("@p_f_actual", SqlDbType.DateTime);
            SqlParameter F_DESDE = sp_modif2.Parameters.Add("@p_f_desde", SqlDbType.DateTime);
            SqlParameter F_HASTA = sp_modif2.Parameters.Add("@p_f_hasta", SqlDbType.DateTime);
            SqlParameter VIAJES_CAN = sp_modif2.Parameters.Add("@viajesCancelados", SqlDbType.Int);
            SqlParameter PASAJES_CAN = sp_modif2.Parameters.Add("@pasajesCancelados", SqlDbType.Int);
            SqlParameter ENCO_CAN = sp_modif2.Parameters.Add("@encoCanceladas", SqlDbType.Int);

            ID_MICRO2.Value = this.id_micro;
            F_ACTUAL.Value = func.getFechaActual();
            if (fuera_servicio.Checked)
            {
                F_DESDE.Value = f_fuera_servicio.Value.Date;
                F_HASTA.Value = f_reinicio_servicio.Value.Date;
            }
            else if (baja_definitiva.Checked)
            {
                F_DESDE.Value = f_baja_def.Value.Date;
                F_HASTA.Value = Convert.ToDateTime("20/12/2100");
            }
            VIAJES_CAN.Direction = ParameterDirection.Output;
            PASAJES_CAN.Direction = ParameterDirection.Output;
            ENCO_CAN.Direction = ParameterDirection.Output;

            try
            {
                sp_modif2.ExecuteNonQuery();

                int viajesCan = Convert.ToInt16(sp_modif2.Parameters["@viajesCancelados"].Value.ToString());
                int pasajesCan = Convert.ToInt16(sp_modif2.Parameters["@pasajesCancelados"].Value.ToString());
                int encoCan = Convert.ToInt16(sp_modif2.Parameters["@encoCanceladas"].Value.ToString());
                if (viajesCan > 0)
                {
                    msj = "Los datos del micro han sido modificados.\n";
                    msj = msj + "Cantidad de viajes cancelados: " + viajesCan + ".\n";
                    msj = msj + "Cantidad de pasajes cancelados: " + pasajesCan + ".\n";
                    msj = msj + "Cantidad de encomiendas canceladas: " + encoCan + ".\n";
                    MessageBox.Show(msj, null, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                conn2.desconectar();
            }
            catch (Exception error)
            {
                conn2.desconectar();
                return;
            }

            Modif_Micro.ActiveForm.Close();
        }
예제 #7
0
        private void b_guardar_Click(object sender, EventArgs e)
        {
            string str_error = "";
            if (compra.Text.Trim().Equals("") || compra.Text.Trim().Equals(""))
                str_error = str_error + "Debe ingresar el Código de Compra.\n";
            if (!pasaje.Text.Trim().Equals("") && !encomienda.Text.Trim().Equals(""))
                str_error = str_error + "No puede cancelar dos cosas a la vez. \nBorre el Código de Pasaje o el de Encomienda.\n";

            if (!str_error.Equals(""))
            {
                MessageBox.Show(str_error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Conexion conn = new Conexion();
            SqlCommand sp;

            Funciones func = new Funciones();

            sp = new SqlCommand("SASHAILO.sp_devolver_compra", conn.miConexion); // Lo inicializo
            sp.CommandType = CommandType.StoredProcedure; // Defino que tipo de comando es
            SqlParameter ID_COMPRA = sp.Parameters.Add("@p_id_compra", SqlDbType.Int);
            SqlParameter ID_PASAJE = sp.Parameters.Add("@p_id_pasaje", SqlDbType.BigInt);
            SqlParameter ID_ENCOMIENDA = sp.Parameters.Add("@p_id_encomienda", SqlDbType.BigInt);
            SqlParameter F_DEVOLUCION = sp.Parameters.Add("@p_f_devolucion", SqlDbType.DateTime);
            SqlParameter MOTIVO = sp.Parameters.Add("@p_motivo", SqlDbType.VarChar, 255);
            SqlParameter HAY_ERROR_USER = sp.Parameters.Add("@hayErr", SqlDbType.Int);
            SqlParameter ERRORES_USER = sp.Parameters.Add("@errores", SqlDbType.VarChar, 200);

            ID_COMPRA.Value = compra.Text.Trim();
            if (!pasaje.Text.Trim().Equals(""))
            {
                ID_PASAJE.Value = pasaje.Text.Trim();
            }
            else {
                ID_PASAJE.Value = DBNull.Value;
            }
            if (!encomienda.Text.Trim().Equals(""))
            {
                ID_ENCOMIENDA.Value = encomienda.Text.Trim();
            }
            else
            {
                ID_ENCOMIENDA.Value = DBNull.Value;
            }
            F_DEVOLUCION.Value = func.getFechaActual();
            MOTIVO.Value = motivo.Text.Trim();
            HAY_ERROR_USER.Direction = ParameterDirection.Output;
            ERRORES_USER.Direction = ParameterDirection.Output;

            try
            {
                sp.ExecuteNonQuery();

                int hayError = Convert.ToInt16(sp.Parameters["@hayErr"].Value.ToString());
                if (hayError == 1)
                {
                    string errores = sp.Parameters["@errores"].Value.ToString();
                    MessageBox.Show(errores, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    conn.desconectar();
                    return;
                }
                if (!pasaje.Text.Trim().Equals(""))
                    MessageBox.Show("El Pasaje ha sido cancelado", "", MessageBoxButtons.OK);
                else if (!encomienda.Text.Trim().Equals(""))
                    MessageBox.Show("La Encomienda ha sido cancelada", "", MessageBoxButtons.OK);
                else
                    MessageBox.Show("La Compra ha sido cancelada", "", MessageBoxButtons.OK);
            }
            catch (Exception error)
            {
                MessageBox.Show("Error en la base de datos. Error: " + error.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                conn.desconectar();
                return;
            }

            //Cancelar_Viaje.ActiveForm.Close();
        }
예제 #8
0
        private void canjear_Click(object sender, EventArgs e)
        {
            string str_error = "";
            if (dni.Text.Trim().Equals(""))
                str_error = str_error + "El DNI ingresado no es válido.\n";
            if (!dni.Text.Trim().Equals("") && !existeCliente())
                str_error = str_error + "El DNI ingresado no es válido.\n";
            if (((ComboboxItem)producto.SelectedItem) == null)
                str_error = str_error + "Debe seleccionar el producto.\n";
            if (cantidad.Text.Trim().Equals(""))
                str_error = str_error + "La cantidad ingresada no es válida.\n";

            if (!str_error.Equals(""))
            {
                MessageBox.Show(str_error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Conexion conn = new Conexion();
            SqlCommand sp_recorrido_alta;
            Funciones func = new Funciones();

            sp_recorrido_alta = new SqlCommand("SASHAILO.sp_canjear_producto", conn.miConexion); // Lo inicializo
            sp_recorrido_alta.CommandType = CommandType.StoredProcedure; // Defino que tipo de comando es
            SqlParameter ID_CLIENTE = sp_recorrido_alta.Parameters.Add("@p_id_cliente", SqlDbType.Int);
            SqlParameter ID_PRODUCTO = sp_recorrido_alta.Parameters.Add("@p_id_producto", SqlDbType.Int);
            SqlParameter CANTIDAD = sp_recorrido_alta.Parameters.Add("@p_cantidad", SqlDbType.Int);
            SqlParameter FECHA = sp_recorrido_alta.Parameters.Add("@p_fecha", SqlDbType.DateTime);
            SqlParameter HAY_ERROR_USER = sp_recorrido_alta.Parameters.Add("@hayErr", SqlDbType.Int);
            SqlParameter ERRORES_USER = sp_recorrido_alta.Parameters.Add("@errores", SqlDbType.VarChar, 200);

            ID_CLIENTE.Value = this.id_cliente;
            ID_PRODUCTO.Value = ((ComboboxItem)producto.SelectedItem).Value;
            CANTIDAD.Value = cantidad.Text.Trim();
            FECHA.Value = func.getFechaActual();
            HAY_ERROR_USER.Direction = ParameterDirection.Output;
            ERRORES_USER.Direction = ParameterDirection.Output;

            try
            {
                sp_recorrido_alta.ExecuteNonQuery();

                int hayError = Convert.ToInt16(sp_recorrido_alta.Parameters["@hayErr"].Value.ToString());
                if (hayError == 1)
                {
                    string errores = sp_recorrido_alta.Parameters["@errores"].Value.ToString();
                    MessageBox.Show(errores, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    conn.desconectar();
                    return;
                }
                MessageBox.Show("El canje ha sido realizado", "", MessageBoxButtons.OK);
            }
            catch (Exception error)
            {
                MessageBox.Show("Error en el canje. Error: " + error.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                conn.desconectar();
                return;
            }

            pasaje_Leave(null, null);
            llenaComboProducto();
            cantidad.Text = "";
        }