Exemple #1
0
        public GenerarReserva(int id_usuario, string id_hotel)
        {
            InitializeComponent();
            UtilesSQL.inicializar();
            reserva.usuario          = id_usuario;
            reserva.hotel.ID         = Convert.ToInt32(id_hotel);
            btn_cargar_opciones.Text = "Cargar opciones";
            DateTime fecha = Convert.ToDateTime(Main.fecha());

            //DateTime fecha = DateTime.ParseExact(Main.fecha(), "yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture);
            reserva.fecha_que_se_realizo_reserva = fecha;
            reserva.fecha_desde           = fecha;
            reserva.fecha_hasta           = fecha;
            date_desde.Value              = date_desde.MinDate = fecha;
            date_hasta.Value              = date_hasta.MinDate = fecha;
            lbl_error_fecha.Visible       = false;
            lbl_error_personas.Visible    = false;
            lbl_error_carga_hotel.Visible = false;
            reserva.personas              = 0;
            //Inicializaciones
            cbox_regimenes.Enabled           = false;
            btn_reservar.Enabled             = false;
            lbl_falta_habitaciones_2.Visible = false;
            lbl_falta_habitaciones_1.Visible = false;
            //Inicializacion de intefaz
            lbl_noches.Text = precio_base.Text = recarga_por_estrellas.Text = String.Empty;
            //Cambio de estructura
            SetearRecargaEstrella();
        }
Exemple #2
0
        private void enviar_Click(object sender, EventArgs e)
        {
            //txtbox_motivo tiene MaxLength = 255, así que no hay que verificar eso
            labelMotivo.Visible = false;
            if (!String.IsNullOrWhiteSpace(txtbox_motivo.Text))
            {
                SqlCommand command = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.CancelacionReserva (canc_reserva, canc_motivo, canc_fechaDeCancelacion, canc_usuario) VALUES (@reserva, @motivo, CONVERT(DATETIME, @fecha, 121), @user)");
                command.Parameters.AddWithValue("@reserva", Convert.ToInt64(codigo));
                command.Parameters.AddWithValue("@motivo", txtbox_motivo.Text);
                command.Parameters.AddWithValue("@fecha", Main.fecha());
                command.Parameters.AddWithValue("@user", usuario);
                UtilesSQL.ejecutarComandoNonQuery(command);

                SqlCommand command2 = UtilesSQL.crearCommand("UPDATE DERROCHADORES_DE_PAPEL.Reserva SET rese_estado = @estado WHERE rese_codigo = @reserva");
                command2.Parameters.AddWithValue("@reserva", Convert.ToInt64(codigo));
                command2.Parameters.AddWithValue("@estado", getEstadosDeReserva(tipo_cancelacion));
                UtilesSQL.ejecutarComandoNonQuery(command2);
                MessageBox.Show("Se canceló la reserva " + codigo);
                Close();
            }
            else
            {
                labelMotivo.Visible = true;
            }
        }
        public void AgregarLineaProducto(LineaProducto lp)
        {
            db.cmd.CommandText = "INSERT INTO LineaProducto (nombre,abreviatura) values (@nombre,@abreviatura)";
            db.cmd.Parameters.AddWithValue("@nombre", lp.Nombre);
            db.cmd.Parameters.AddWithValue("@abreviatura", lp.Abreviatura);

            try
            {
                db.conn.Open();
                db.cmd.ExecuteNonQuery();
                db.conn.Close();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace.ToString());
            }

            int idLinea= new UtilesSQL().ObtenerMaximoID("LineaProducto", "idLinea");
            SubLineaProductoSQL slpSQL = new SubLineaProductoSQL();
            foreach (SubLineaProducto slp in lp.Sublineas)
            {

                slpSQL.AgregarSubLineaProducto(slp,idLinea);
            }
        }
Exemple #4
0
        private void realizarCambios()
        {
            //Crea el hotel
            SqlCommand com = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.Hotel (hote_nombre, hote_mail, hote_telefono, hote_calle, hote_numeroDeCalle, hote_localidad, hote_estrellas, hote_recargaEstrella, hote_ciudad, hote_pais, hote_fechaDeCreacion) VALUES (@nom, @mail, @tel, @calle, @numCalle, @loc, @estr, @recEstr, @ciudad, @pais, CONVERT(datetime, @fecha, 121))");

            com.Parameters.AddWithValue("@nom", textBoxNombre.Text);
            com.Parameters.AddWithValue("@mail", textBoxMail.Text);
            com.Parameters.AddWithValue("@tel", textBoxTelefono.Text);
            com.Parameters.AddWithValue("@calle", textBoxDireccion.Text);
            com.Parameters.AddWithValue("@numCalle", textBoxNumeroCalle.Text);
            com.Parameters.AddWithValue("@loc", textBoxLocalidad.Text);
            com.Parameters.AddWithValue("@estr", comboBoxEstrellas.SelectedIndex);
            com.Parameters.AddWithValue("@recEstr", 10);
            com.Parameters.AddWithValue("@ciudad", textBoxCiudad.Text);
            com.Parameters.AddWithValue("@pais", textBoxPais.Text);
            com.Parameters.AddWithValue("@fecha", textBoxFecha.Text);
            UtilesSQL.ejecutarComandoNonQuery(com);

            com = UtilesSQL.crearCommand("SELECT MAX(hote_id) FROM DERROCHADORES_DE_PAPEL.Hotel");
            var hoteId = com.ExecuteScalar();

            //Crea los regimenes que esten seleccionados
            SqlCommand com1;
            int        i = 0;

            foreach (DataGridViewRow row in dataGridViewRegimenes.Rows)
            {
                i++;
                if (row.Cells[0].Value.ToString() == true.ToString())
                {
                    com1 = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.RegimenXHotel VALUES (@reg, @hote)");
                    com1.Parameters.AddWithValue("@reg", i);
                    com1.Parameters.AddWithValue("@hote", hoteId);
                    UtilesSQL.ejecutarComandoNonQuery(com1);
                }
            }

            //Asigna el rol de administrador del hotel al usuario logueado
            SqlCommand com2;

            com2 = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.RolXUsuarioXHotel VALUES (2, @user, @hotel, 1)");
            com2.Parameters.AddWithValue("@user", userId);
            com2.Parameters.AddWithValue("@hotel", hoteId);
            UtilesSQL.ejecutarComandoNonQuery(com2);

            //Asigna al usuario guest el rol de guest para el hotel creado
            SqlCommand com3;

            com3 = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.RolXUsuarioXHotel VALUES (4, 2, @hotel, 1)");
            com3.Parameters.AddWithValue("@hotel", hoteId);
            UtilesSQL.ejecutarComandoNonQuery(com3);

            //Asigna al usuario admin el rol de administrador general para el hotel creado
            SqlCommand com4;

            com4 = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.RolXUsuarioXHotel VALUES (1, 1, @hotel, 1)");
            com4.Parameters.AddWithValue("@hotel", hoteId);
            UtilesSQL.ejecutarComandoNonQuery(com4);
            MessageBox.Show("Creacion exitosa!");
        }
Exemple #5
0
 private void Entrar_Click(object sender, EventArgs e)
 {
     if (loginsIncorrectos != 0 && usuario != usuarioTextBox.Text)
     {
         loginsIncorrectos = 0;
     }                                                                                             //reinicia los logins invalidos si trato de logear con otro usuario
     usuario = usuarioTextBox.Text;
     sda     = UtilesSQL.crearDataAdapter("SELECT u.usur_username, u.usur_password, u.usur_habilitado, r.rol_nombre, h.hote_nombre, u.usur_id, ruh.rouh_hotel from DERROCHADORES_DE_PAPEL.Usuario as u  inner join DERROCHADORES_DE_PAPEL.RolXUsuarioXHotel as ruh ON u.usur_id = ruh.rouh_usuario inner join DERROCHADORES_DE_PAPEL.Hotel as h ON h.hote_id = ruh.rouh_hotel inner join DERROCHADORES_DE_PAPEL.Rol as r ON r.rol_id = ruh.rouh_rol WHERE u.usur_username = @usuario AND ruh.rouh_habilitado = 1 GROUP BY u.usur_username, u.usur_password, u.usur_habilitado, r.rol_nombre, h.hote_nombre, u.usur_id, ruh.rouh_hotel");
     sda.SelectCommand.Parameters.AddWithValue("@usuario", usuario);
     sda.Fill(dt);
     if (dt.Rows.Count == 0)      //Checkeo que exista el usuario
     {
         MessageBox.Show("No existe el usuario o no tiene asignado ningún rol");
     }
     else
     {
         if (ValidarUsuario(dt))         //Checkeo que el usuario este habilitado
         {
             if (ValidarContraseña(dt))  //checkea que la contraseña sea correcta
             {
                 LoginCorrecto(sda);
             }
             else
             {
                 LoginIncorrecto();
             }
         }
         else
         {
             MessageBox.Show("El usuario se encuentra bloqueado");
         }
     }
 }
Exemple #6
0
        private void eliminar_Click(object sender, EventArgs e)
        {
            if (roles.CurrentRow == null)
            {
                MessageBox.Show("Debe elegir un rol para poder eliminar");
                return;
            }

            DataRow rol        = ((DataRowView)roles.Rows[roles.CurrentCell.RowIndex].DataBoundItem).Row;
            String  nombre_rol = rol["Nombre"].ToString();

            if (MessageBox.Show("¿Está seguro de que quiere eliminar el rol " + nombre_rol + "?", "Eliminar el rol", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int resultado = UtilesSQL.ejecutarComandoNonQuery("DERROCHADORES_DE_PAPEL.EliminarRol " + rol["Rol"].ToString());
                if (resultado > 0)
                {
                    funcionalidades_dt.Clear();
                    roles_dt.Rows.Remove(rol);
                    MessageBox.Show("Se eliminó satisfactoriamente el rol " + nombre_rol);
                }
                else
                {
                    MessageBox.Show("No se pudo eliminar el rol porque hay usuarios que dependen de él");
                }
            }
        }
Exemple #7
0
 public BajaHotel(int hoteId)
 {
     UtilesSQL.inicializar();
     idH = hoteId;
     InitializeComponent();
     richTextBoxMotivo.MaxLength = 255;
 }
Exemple #8
0
        private void btn_reservar_Click(object sender, EventArgs e)
        {
            if (numericUpDownPersonas.Value == 0)
            {
                return;
            }
            if (clie_nombre.Text.Length.Equals(0))
            {
                MessageBox.Show("Se debe registrar cliente");
                return;
            }
            if (lbl_falta_habitaciones_1.Visible)
            {
                MessageBox.Show("Debe elegir bien las habitaciones");
                return;
            }
            //verificar que no haya otra reserva
            DataTable reservas = new DataTable();

            UtilesSQL.llenarTabla(reservas, "SELECT * FROM DERROCHADORES_DE_PAPEL.Reserva WHERE rese_usuario = " + reserva.cliente.ToString() + " AND rese_estado IN (1,2,6) AND ((rese_inicio <= CONVERT(datetime,'" + reserva.fecha_desde.ToString("yyyy-MM-dd") + "',121) AND CONVERT(datetime,'" + reserva.fecha_desde.ToString("yyyy-MM-dd") + "',121) <= rese_fin) OR (rese_inicio <= CONVERT(datetime,'" + reserva.fecha_hasta.ToString("yyyy-MM-dd") + "',121) AND CONVERT(datetime,'" + reserva.fecha_hasta.ToString("yyyy-MM-dd") + "',121) <= rese_fin))");
            if (reservas.Rows.Count > 0)
            {
                MessageBox.Show("El usuario ya tiene otra reserva en esas fechas");
                return;
            }
            AltaReserva();
            MessageBox.Show("Se genero un reserva en el hotel " + reserva.hotel.ID.ToString() + " desde el dia " + reserva.fecha_desde.ToString("yyyy-MM-dd") + " hasta el dia " + reserva.fecha_hasta.ToString("yyyy-MM-dd") + "\n Codigo de reserva: " + reserva.codigo.ToString());
            Close();
        }
Exemple #9
0
        private void AltaReserva()
        {
            command = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.Reserva (rese_cliente, rese_cantidadDeNoches, rese_estado, rese_fecha, rese_inicio, rese_fin, rese_hotel, rese_regimen, rese_usuario, rese_cantidadDePersonas) VALUES (@clie, @noches, @estado, CONVERT(datetime,@fecha, 121), CONVERT(datetime,@incio, 121), CONVERT(datetime,@fin, 121), @hotel, @regimen ,@user, @personas) SELECT SCOPE_IDENTITY()");
            command.Parameters.AddWithValue("@clie", reserva.cliente);
            command.Parameters.AddWithValue("@noches", reserva.cantidad_de_noches);
            command.Parameters.AddWithValue("@estado", CargarEstadosDeReserva("RESERVA CORRECTA"));
            command.Parameters.AddWithValue("@fecha", reserva.fecha_que_se_realizo_reserva.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            command.Parameters.AddWithValue("@incio", reserva.fecha_desde.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            command.Parameters.AddWithValue("@fin", reserva.fecha_hasta.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            command.Parameters.AddWithValue("@hotel", reserva.hotel.ID);
            command.Parameters.AddWithValue("@regimen", reserva.regimen_seleccionado);
            command.Parameters.AddWithValue("@user", reserva.usuario);
            command.Parameters.AddWithValue("@personas", reserva.personas);

            reserva.codigo = Convert.ToInt32(command.ExecuteScalar());

            for (int indice = 0; indice < reserva.habitaciones_reservadas.Count; indice++)
            {
                command = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.ReservaXHabitacion (rexh_reserva, rexh_hotel, rexh_numero, rexh_piso) VALUES (@reserva, @hotel, @numero, @piso)");
                command.Parameters.AddWithValue("@reserva", reserva.codigo);
                command.Parameters.AddWithValue("@hotel", reserva.hotel.ID);
                command.Parameters.AddWithValue("@piso", reserva.habitaciones_reservadas[indice].piso);
                command.Parameters.AddWithValue("@numero", reserva.habitaciones_reservadas[indice].numero);
                UtilesSQL.ejecutarComandoNonQuery(command);
            }
        }
Exemple #10
0
        public DistribuirClientes(DataTable clientes_disponibles, String reserva)
        {
            this.reserva = reserva;

            clientes_dt = clientes_disponibles.Copy();
            clientes_dt.Columns.Remove("Mail");

            InitializeComponent();

            clientes.DataSource = clientes_dt;

            distribucion_dt = new DataTable();
            distribucion_dt.Columns.Add("Cliente");
            distribucion_dt.Columns.Add("Apellido");
            distribucion_dt.Columns.Add("Nombre");
            distribucion_dt.Columns.Add("Habitación");
            distribucion_dt.Columns.Add("Piso");
            distribucion.DataSource = distribucion_dt;

            habitaciones_dt = new DataTable();
            UtilesSQL.llenarTabla(habitaciones_dt, "SELECT rexh_numero Número, rexh_piso Piso, tipo_cantidadDePersonas Cantidad FROM DERROCHADORES_DE_PAPEL.ReservaXHabitacion JOIN DERROCHADORES_DE_PAPEL.Habitacion ON rexh_hotel = habi_hotel AND rexh_numero = habi_numero AND rexh_piso = habi_piso JOIN DERROCHADORES_DE_PAPEL.TipoDeHabitacion ON tipo_codigo = habi_tipo WHERE rexh_reserva = " + reserva + " AND rexh_hotel = " + Login.SeleccionFuncionalidad.getHotelId());

            foreach (DataRow hab in habitaciones_dt.Rows)
            {
                habitaciones.Items.Add("Número: " + hab[0].ToString() + " - Piso: " + hab[1].ToString() + " - Capacidad: " + hab[2].ToString());
            }
            habitaciones.SelectedIndex = 0;
        }
Exemple #11
0
        private void volver_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("¿Está seguro de que quiere terminar la carga de consumibles?", "Finalizar carga", MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                //En caso de ser un régimen "All inclusive" hay que netear los costos de los consumibles
                SqlCommand com3 = UtilesSQL.crearCommand("SELECT re.regi_descripcion FROM DERROCHADORES_DE_PAPEL.Estadia AS e JOIN DERROCHADORES_DE_PAPEL.Reserva AS r ON e.esta_reserva = r.rese_codigo JOIN DERROCHADORES_DE_PAPEL.Regimen AS re ON re.regi_codigo = r.rese_regimen WHERE esta_id = @est");
                com3.Parameters.AddWithValue("@est", estadia);
                object regimen = com3.ExecuteScalar();
                if (regimen != null)
                {
                    if (regimen.ToString().Equals("All inclusive") || regimen.ToString().Equals("All Inclusive moderado"))
                    {
                        //Creamos el item de factura con el descuento
                        UtilesSQL.ejecutarComandoNonQuery("INSERT INTO DERROCHADORES_DE_PAPEL.ItemDeFactura (item_cantidad, item_monto, item_factura, item_descripcion, item_consumible, item_habitacionNumero, item_habitacionPiso) "
                                                          + "SELECT 1, SUM(item_monto), item_factura, '1x Descuento por régimen All Inclusive', NULL, MAX(item_habitacionNumero), MAX(item_habitacionPiso) "
                                                          + "FROM DERROCHADORES_DE_PAPEL.ItemDeFactura "
                                                          + "WHERE item_factura = " + factura + " AND item_consumible IS NOT NULL "
                                                          + "GROUP BY item_factura");
                    }
                }
                this.Close();
            }
        }
Exemple #12
0
 public SeleccionarHotel()
 {
     InitializeComponent();
     UtilesSQL.inicializar();
     sda.Fill(dt);
     Hoteles.DataSource = dt;
 }
Exemple #13
0
 private void button1_Click(object sender, EventArgs e)
 {
     this.Hide();
     RegistrarEstadia.ElegirCliente elegir = new RegistrarEstadia.ElegirCliente();
     elegir.ShowDialog();
     if (elegir.estaElegido())
     {
         DataTable dt    = new DataTable();
         String    desde = "CONVERT(datetime, \'" + reserva.fecha_desde.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\',121)";
         String    hasta = "CONVERT(datetime, \'" + reserva.fecha_hasta.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\',121)";
         UtilesSQL.llenarTabla(dt, "SELECT * FROM DERROCHADORES_DE_PAPEL.Reserva WHERE rese_hotel = " + reserva.hotel.ID + " AND rese_cliente = " + elegir.id() + " AND rese_codigo != " + reserva.codigo.ToString() + " AND ((rese_fin >= " + desde + " AND rese_fin <= " + hasta + ") OR (rese_inicio >= " + desde + " AND rese_inicio <= " + hasta + ") OR ( rese_inicio <=" + desde + " AND rese_fin >= " + hasta + "))");
         if (dt.Rows.Count != 0)
         {
             MessageBox.Show("Ese usuario ya tiene una reserva en este hotel en esas fechas");
         }
         else
         {
             reserva.cliente    = Int32.Parse(elegir.id());
             clie_nombre.Text   = elegir.nombre();
             clie_apellido.Text = elegir.apellido();
             clie_mail.Text     = elegir.mail();
         }
     }
     Show();
 }
Exemple #14
0
        private void buttonFinalizar_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("Esta seguro que los datos son correctos?", "Finalizar factura?", MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.No)
            {
                return;
            }

            SqlCommand com = UtilesSQL.crearCommand("UPDATE DERROCHADORES_DE_PAPEL.Estadia SET esta_usuarioCheckOut = " + Login.SeleccionFuncionalidad.getUserId() + " WHERE esta_id = @est");

            com.Parameters.AddWithValue("@est", dtF.Rows[0][2].ToString());
            UtilesSQL.ejecutarComandoNonQuery(com);

            if (!comboBoxFormaDePago.Text.Equals("TARJETA DE CREDITO"))
            {
                resetearLabels();
                finalizarFactura();
                MessageBox.Show("Check out completado!");
                this.Close();
            }
            else
            {
                if (validar())
                {
                    finalizarFacturaTarjeta();
                    MessageBox.Show("Check out completado!");
                    this.Close();
                }
            }
        }
Exemple #15
0
        private void checkout_Click(object sender, EventArgs e)
        {
            if (!estado.Text.Equals("RESERVA EFECTIVIZADA"))
            {
                MessageBox.Show("La reserva no hizo el check-in o fue cancelada");
                return;
            }

            //Checkea que no se haya realizado el check out
            dtH.Clear();
            UtilesSQL.llenarTabla(dtH, "SELECT h.habi_numero, h.habi_piso, e.esta_id FROM DERROCHADORES_DE_PAPEL.Habitacion AS h JOIN DERROCHADORES_DE_PAPEL.ReservaXHabitacion AS rh ON rh.rexh_piso = h.habi_piso AND rh.rexh_numero = h.habi_numero JOIN DERROCHADORES_DE_PAPEL.Reserva AS r ON r.rese_codigo = rh.rexh_reserva JOIN DERROCHADORES_DE_PAPEL.Estadia AS e ON e.esta_reserva = r.rese_codigo WHERE rh.rexh_reserva = '" + reserva.Text + "' AND e.esta_usuarioCheckOut IS NULL GROUP BY h.habi_numero, h.habi_piso, e.esta_id");
            if (dtH.Rows.Count == 0)
            {
                MessageBox.Show("Esta reserva ya realizo el check out.");
                return;
            }

            //Crea la factura para poder iniciar el proceso de check out
            SqlCommand com = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.Factura (fact_fecha, fact_estadia, fact_cliente) VALUES (CONVERT(datetime, @fecha, 121), @estadia, @cliente)");

            com.Parameters.AddWithValue("@fecha", Main.fecha());
            com.Parameters.AddWithValue("@estadia", dtH.Rows[0][2].ToString());
            com.Parameters.AddWithValue("@cliente", reserva_dt.Rows[0][9].ToString());
            UtilesSQL.ejecutarComandoNonQuery(com);

            com = UtilesSQL.crearCommand("SELECT f.fact_numero FROM DERROCHADORES_DE_PAPEL.Factura AS f JOIN DERROCHADORES_DE_PAPEL.Estadia AS e ON e.esta_id = f.fact_estadia WHERE e.esta_id = @estadia");
            com.Parameters.AddWithValue("@estadia", dtH.Rows[0][2].ToString());
            factura = com.ExecuteScalar().ToString();

            UtilesSQL.ejecutarComandoNonQuery("INSERT INTO DERROCHADORES_DE_PAPEL.ItemDeFactura (item_cantidad, item_monto, item_factura, item_descripcion, item_consumible, item_habitacionNumero, item_habitacionPiso) VALUES (1, (SELECT regi_precioBase * SUM(tipo_cantidadDePersonas) * rese_cantidadDeNoches + 10 FROM DERROCHADORES_DE_PAPEL.Reserva JOIN DERROCHADORES_DE_PAPEL.ReservaXHabitacion ON rese_codigo = rexh_reserva JOIN DERROCHADORES_DE_PAPEL.Habitacion ON habi_hotel = rexh_hotel AND habi_numero = rexh_numero AND habi_piso = rexh_piso JOIN DERROCHADORES_DE_PAPEL.TipoDeHabitacion ON habi_tipo = tipo_codigo JOIN DERROCHADORES_DE_PAPEL.Regimen ON regi_codigo = rese_regimen WHERE rese_codigo = " + reserva.Text + " AND habi_hotel = " + Login.SeleccionFuncionalidad.getHotelId() + " GROUP BY regi_precioBase, rese_cantidadDeNoches), " + factura + ", \'Hospedaje\', NULL, " + dtH.Rows[0][0].ToString() + ", " + dtH.Rows[0][1].ToString() + ")");

            Consumibles();
        }
Exemple #16
0
 public AbmUsuario(string hotel)
 {
     hotelId = hotel;
     UtilesSQL.inicializar();
     InitializeComponent();
     cargarRoles();
 }
Exemple #17
0
 public AltaHotel(int idU)
 {
     userId = idU;
     UtilesSQL.inicializar();
     InitializeComponent();
     cargarCosas();
 }
Exemple #18
0
 public ModificarHotel(DataTable dtHotel)
 {
     dtH = dtHotel;
     UtilesSQL.inicializar();
     InitializeComponent();
     cargarCosas();
 }
Exemple #19
0
 public ListadoHabitaciones(int hoteId)
 {
     idH = hoteId;
     UtilesSQL.inicializar();
     InitializeComponent();
     iniciarComboBox();
 }
Exemple #20
0
        private void cargarComboBox()
        {
            dtDoc.Clear();
            dtNac.Clear();
            command = UtilesSQL.crearCommand("select docu_detalle, docu_tipo from DERROCHADORES_DE_PAPEL.Documento");
            SqlDataReader reader;

            reader = command.ExecuteReader();
            dt.Columns.Add("docu_detalle", typeof(string));
            dt.Columns.Add("docu_tipo", typeof(string));
            dtDoc.Load(reader);

            comboBoxTipoDocumento.ValueMember   = "docu_tipo";
            comboBoxTipoDocumento.DisplayMember = "docu_detalle";
            comboBoxTipoDocumento.DataSource    = dtDoc;

            SqlDataReader reader2;

            command2 = UtilesSQL.crearCommand("SELECT naci_detalle, naci_id from DERROCHADORES_DE_PAPEL.Nacionalidad");
            reader2  = command2.ExecuteReader();
            dtNac.Columns.Add("naci_detalle", typeof(string));
            dtNac.Columns.Add("naci_id", typeof(string));
            dtNac.Load(reader2);

            comboBoxNacionalidad.ValueMember   = "naci_id";
            comboBoxNacionalidad.DisplayMember = "naci_detalle";
            comboBoxNacionalidad.DataSource    = dtNac;
        }
Exemple #21
0
 private void mailValido(string mail)
 {
     if (string.IsNullOrWhiteSpace(mail))
     {
         labelMailObligatorio.Visible = true;
         Valido = false;
     }
     else
     {
         DataTable      dtMail = new DataTable();
         SqlDataAdapter sda    = UtilesSQL.crearDataAdapter("select clie_id from DERROCHADORES_DE_PAPEL.Cliente where clie_mail = @mail");
         sda.SelectCommand.Parameters.AddWithValue("@mail", mail);
         sda.Fill(dtNac);
         if (dtMail.Rows.Count == 0) //El mail no esta en uso
         {
             try
             {
                 MailAddress m = new MailAddress(mail);
             }
             catch (FormatException)
             {
                 labelMailInvalido.Visible = true;
                 Valido = false;
             }
         }
         else
         {
             if (dtMail.Rows[0][0].ToString() == id.ToString())  //el mail esta en uso pero por ese usuario
             {
                 labelMailEnUso.Visible = Enabled;
                 Valido = false;
             }
         }
     }
 }
Exemple #22
0
        private void Consumibles()
        {
            //Si ya registro consumibles va directo al check out, sino pregunta
            SqlCommand com = UtilesSQL.crearCommand("SELECT item_id FROM DERROCHADORES_DE_PAPEL.ItemDeFactura WHERE item_factura = @factura AND item_habitacionNumero = @hab AND item_habitacionPiso = @piso AND item_consumible IS NOT NULL");

            com.Parameters.AddWithValue("@factura", factura);
            com.Parameters.AddWithValue("@hab", dtH.Rows[0][0].ToString());
            com.Parameters.AddWithValue("@piso", dtH.Rows[0][1].ToString());
            object itemPrevio = com.ExecuteScalar();

            if (itemPrevio != null)
            {
                this.Hide();
                Form f1 = new CheckOut(factura);
                f1.ShowDialog();
                return;
            }
            var confirmResult = MessageBox.Show("Desea registrar consumibles?", "Registrar consumibles?", MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                this.Hide();
                new RegistrarConsumible.ElegirHabitacion(factura, dtH).ShowDialog();
                new CheckOut(factura).ShowDialog();
                this.Close();
            }
            else
            {
                this.Hide();
                Form f1 = new CheckOut(factura);
                f1.ShowDialog();
                this.Close();
            }
        }
Exemple #23
0
 private void usernameValido(string username)
 {
     if (string.IsNullOrWhiteSpace(username))
     {
         labelUsuarioObligatorio.Visible = true;
         Valido = false;
     }
     else
     {
         DataTable      dtUsuario = new DataTable();
         SqlDataAdapter sda       = UtilesSQL.crearDataAdapter("select usur_username from DERROCHADORES_DE_PAPEL.Usuario where usur_username = @user");
         sda.SelectCommand.Parameters.AddWithValue("@user", username);
         sda.Fill(dtUsuario);
         if (dtUsuario.Rows.Count == 0) //El mail no esta en uso
         {
             if (!(username.All(Char.IsLetter)))
             {
                 labelUsuarioInvalido.Visible = true;
                 Valido = false;
             }
         }
         else
         {
             labelUsuarioEnUso.Visible = Enabled;
             Valido = false;
         }
     }
 }
Exemple #24
0
 private void roles_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     //Mostrar las funcionalidades del rol cuando se hace click en el número de rol
     if (e.ColumnIndex == 0 && e.RowIndex >= 0)
     {
         funcionalidades_dt.Clear();
         UtilesSQL.llenarTabla(funcionalidades_dt, "SELECT func_id Funcionalidad, func_detalle Detalle FROM DERROCHADORES_DE_PAPEL.Funcionalidad JOIN DERROCHADORES_DE_PAPEL.FuncionalidadXRol ON fxro_funcionalidad = func_id AND fxro_rol = " + roles.Rows[e.RowIndex].Cells["Rol"].Value.ToString());
     }
     //Confirmar que el usuario quiere deshabilitar el rol cuando aprieta en la columna Eliminar
     else if (e.ColumnIndex == 3 && e.RowIndex >= 0)
     {
         DataRow rol        = ((DataRowView)roles.Rows[e.RowIndex].DataBoundItem).Row;
         String  nombre_rol = rol["Nombre"].ToString();
         if (MessageBox.Show("¿Está seguro de que quiere eliminar el rol " + nombre_rol + "?", "Eliminar el rol", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             int resultado = UtilesSQL.ejecutarComandoNonQuery("DERROCHADORES_DE_PAPEL.EliminarRol " + rol["Rol"].ToString());
             if (resultado > 0)
             {
                 funcionalidades_dt.Clear();
                 roles_dt.Rows.Remove(rol);
                 MessageBox.Show("Se eliminó satisfactoriamente el rol " + nombre_rol);
             }
             else
             {
                 MessageBox.Show("No se pudo eliminar el rol porque hay usuarios que dependen de él");
             }
         }
     }
 }
Exemple #25
0
 private void checkearDatos()
 {
     Valido = true;
     if (!(textBoxPiso.Text.All(Char.IsDigit)) || String.IsNullOrEmpty(textBoxPiso.Text))
     {
         labelPisoInvalido.Visible = true;
         Valido = false;
     }
     if (!(textBoxNumero.Text.All(Char.IsDigit)) || String.IsNullOrEmpty(textBoxNumero.Text))
     {
         labelNumeroInvalido.Visible = true;
         Valido = false;
     }
     else
     {
         if (textBoxNumero.Text.Equals(dtH.Rows[0][1].ToString()))
         {
             return;
         }
         DataTable      dt  = new DataTable();
         SqlDataAdapter sda = UtilesSQL.crearDataAdapter("SELECT * FROM DERROCHADORES_DE_PAPEL.Habitacion WHERE habi_hotel = @hote AND habi_numero = @num");
         sda.SelectCommand.Parameters.AddWithValue("@hote", dtH.Rows[0][0]);
         sda.SelectCommand.Parameters.AddWithValue("@num", textBoxNumero.Text);
         sda.Fill(dt);
         if (dt.Rows.Count != 0) //Hay otra habitacion con el mismo número
         {
             labelNumeroInvalido2.Visible = true;
             Valido = false;
         }
     }
 }
Exemple #26
0
        private int getEstadosDeReserva(string estado_buscado)
        {
            DataTable estados_reserva = new DataTable();

            UtilesSQL.llenarTabla(estados_reserva, "SELECT esta_id FROM DERROCHADORES_DE_PAPEL.EstadoDeReserva WHERE esta_detalle = '" + estado_buscado + "'");
            return(Convert.ToInt32(estados_reserva.Rows[0]["esta_id"]));
        }
Exemple #27
0
        private void realizarCambios()
        {
            SqlCommand command1 = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.Usuario (usur_username, usur_password, usur_nombre, usur_apellido, usur_mail, usur_telefono, usur_fechaDeNacimiento, usur_calle, usur_numeroDeCalle, usur_piso, usur_departamento, usur_localidad, usur_tipoDeDocumento, usur_numeroDeDocumento, usur_habilitado) VALUES (@user, @pass, @nombre, @ape, @mail, @tel, CONVERT(datetime, @fecha, 121), @calle, @numCalle, @piso, @depto, @loc, @doc, @numDoc, @hab)");

            command1.Parameters.AddWithValue("@user", textBoxUsuario.Text);
            command1.Parameters.AddWithValue("@pass", sha256.GenerarSHA256String(textBoxContraseña.Text));
            command1.Parameters.AddWithValue("@nombre", textBoxNombre.Text);
            command1.Parameters.AddWithValue("@ape", textBoxApellido.Text);
            command1.Parameters.AddWithValue("@mail", textBoxMail.Text);
            if (teleNull)
            {
                command1.Parameters.AddWithValue("@tel", DBNull.Value);
            }
            else
            {
                command1.Parameters.AddWithValue("@tel", textBoxTelefono.Text);
            }
            command1.Parameters.AddWithValue("@fecha", textBoxFecha.Text);
            command1.Parameters.AddWithValue("@calle", textBoxDireccion.Text);
            command1.Parameters.AddWithValue("@numCalle", textBoxNumeroCalle.Text);
            if (pisoNull)
            {
                command1.Parameters.AddWithValue("@piso", DBNull.Value);
            }
            else
            {
                command1.Parameters.AddWithValue("@piso", textBoxPiso.Text);
            }
            if (deptoNull)
            {
                command1.Parameters.AddWithValue("@depto", DBNull.Value);
            }
            else
            {
                command1.Parameters.AddWithValue("@depto", textBoxDepto.Text);
            }
            if (locNull)
            {
                command1.Parameters.AddWithValue("@loc", DBNull.Value);
            }
            else
            {
                command1.Parameters.AddWithValue("@loc", textBoxLocalidad.Text);
            }
            command1.Parameters.AddWithValue("@doc", comboBoxTipoDocumento.SelectedValue.ToString());
            command1.Parameters.AddWithValue("@numDoc", textBoxNumeroDocumento.Text);
            command1.Parameters.AddWithValue("@hab", checkBoxHabilitado.Checked);
            UtilesSQL.ejecutarComandoNonQuery(command1);

            SqlCommand command2 = UtilesSQL.crearCommand("INSERT INTO DERROCHADORES_DE_PAPEL.RolXUsuarioXHotel SELECT @rol, u.usur_id, @hotel, u.usur_habilitado FROM DERROCHADORES_DE_PAPEL.Usuario AS u WHERE u.usur_username = @username");

            command2.Parameters.AddWithValue("@username", textBoxUsuario.Text);
            command2.Parameters.AddWithValue("@rol", comboBoxRoles.SelectedValue.ToString());
            command2.Parameters.AddWithValue("@hotel", textBoxHotel.Text);
            UtilesSQL.ejecutarComandoNonQuery(command2);

            MessageBox.Show("Creación exitosa!");
            this.Close();
        }
Exemple #28
0
        private void ValidarReserva()
        {
            dtReserva = new DataTable();
            UtilesSQL.llenarTabla(dtReserva, "SELECT * FROM DERROCHADORES_DE_PAPEL.Reserva WHERE rese_codigo = '" + txtbox_reserva.Text + "'");
            if (dtReserva.Rows.Count == 0)
            {
                lbl_error.Text    = "No se encuentra la reserva";
                lbl_error.Visible = true;
                return;
            }
            if (Convert.ToInt32(dtReserva.Rows[0]["rese_hotel"]) != hotel)
            {
                lbl_error.Text    = "La reserva corresponde a otro hotel";
                lbl_error.Visible = true;
                return;
            }
            TimeSpan dias_para_reserva = Convert.ToDateTime(dtReserva.Rows[0]["rese_inicio"]) - Convert.ToDateTime(Main.fecha());

            if (dias_para_reserva.Days <= 1)
            {
                if (dias_para_reserva.Days < 0)
                {
                    lbl_error.Text = "Ya pasó la fecha de reserva";
                }
                else
                {
                    lbl_error.Text = "No se puede modificar a menos de un día";
                }
                lbl_error.Visible = true;
                return;
            }
            if (ReservaYaCancelada())
            {
                lbl_error.Text    = "Esta reserva fue cancelada";
                lbl_error.Visible = true;
                return;
            }
            if (ReservaEfectivizada())
            {
                lbl_error.Text    = "Esta reserva ya se efectivizó";
                lbl_error.Visible = true;
                return;
            }

            txtbox_reserva.Enabled          = false;
            btn_cargar_reserva.Enabled      = false;
            lbl_cargado_correcto.Visible    = true;
            cbox_disponibles.Enabled        = true;
            cbox_seleccionadas.Enabled      = true;
            date_desde.Enabled              = true;
            date_hasta.Enabled              = true;
            btn_agregar_habitacion.Enabled  = true;
            btn_eliminar_habitacion.Enabled = true;
            btn_modificar.Enabled           = true;
            textBoxTotal.Enabled            = true;
            numericUpDown.Enabled           = true;

            cargarReserva();
        }
Exemple #29
0
 public AltaHabitacion(int id)
 {
     UtilesSQL.inicializar();
     idH = id;
     InitializeComponent();
     iniciarComboBox();
     richTextBoxDesc.MaxLength = 50;
 }
Exemple #30
0
 private void roles_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         funcionalidades_dt.Clear();
         UtilesSQL.llenarTabla(funcionalidades_dt, "SELECT func_id Funcionalidad, func_detalle Detalle FROM DERROCHADORES_DE_PAPEL.Funcionalidad JOIN DERROCHADORES_DE_PAPEL.FuncionalidadXRol ON fxro_funcionalidad = func_id AND fxro_rol = " + roles.Rows[e.RowIndex].Cells["Rol"].Value.ToString());
     }
 }
Exemple #31
0
 public CancelarReserva(long userId, string hotelId)
 {
     InitializeComponent();
     UtilesSQL.inicializar();
     usuario = userId;
     hotel   = Convert.ToInt64(hotelId);
     SetearTipoCancelacion();
 }
        public void Guardar()
        {
            OrdenCompraSQL oSQL = new OrdenCompraSQL();
            OrdenCompraxProductoSQL opSQL = new OrdenCompraxProductoSQL();
            UtilesSQL u = new UtilesSQL();
            SolicitudAdquisicionSQL sSQL = new SolicitudAdquisicionSQL();
               foreach (Proveedor p in LstProveedor){

               OrdenCompra o = new OrdenCompra(idAlmacen, p, "Entregar a la brevedad posible");
               o.Estado = 2;

               oSQL.Agregar(o);

               int idOrden = u.ObtenerMaximoID("OrdenCompra", "idOrden");
               o.IdOrden = idOrden;
               foreach (Consolidado c in LstConsolidado) {

               if (c.Prov.IdProveedor == p.IdProveedor)
               {
                   ProductoxOrdenCompra po = new ProductoxOrdenCompra(c, idOrden);
                   opSQL.Agregar(po);
                   o.LstProducto.Add(po);
               }

               }

               Enviar(o);

               foreach (int idSol in Solicitudes)
               {
               oSQL.relacionarOrden(idOrden, idSol);
               }

               }

               foreach (int idSol in Solicitudes)
               {
               sSQL.TerminarSolicitudes(idAlmacen, idSol);
               }
               MessageBox.Show( "Fueron generadas satisfactoriamente las Orden de compra","OBSERVACION", MessageBoxButton.OK, MessageBoxImage.Information);
               m.TryClose();
        }
        private string CodigoProducto()
        {
            UtilesSQL util = new UtilesSQL();
            string cod = null;

            cod = GetLinea(SelectedValue).Abreviatura + GetSubLinea(selectedValueSub).Abreviatura;

            return cod;
        }
        public MantenerGuiaDeRemisionViewModel(IWindowManager windowmanager)
        {
            _windowManager = windowmanager;
            int k=0;
            indicador = 1;

            k = new UtilesSQL().ObtenerMaximoID("GuiaRemision", "idGuia");
            TxtCodigo = "GR-" + (1000000 + k + 1).ToString();
            TxtEstado = "POR EMITIR";
        }
        public void GuardarMovimiento(DynamicGrid anaquel, DynamicGrid deposito)
        {
            int exito;

            /*Inicializacion de la transacción*/
            DBConexion db = new DBConexion();
            try
            {
                db.conn.Open();
                SqlTransaction trans = db.conn.BeginTransaction(IsolationLevel.ReadCommitted);

                db.cmd.Transaction = trans;

                SectorSQL sectorSQL = new SectorSQL(db);
                UbicacionSQL ubicacionSQL = new UbicacionSQL(db);

                /*Tablas temporales*/
                DataTable sectoresDT = sectorSQL.CrearSectoresDT();
                DataTable ubicacionesDT = ubicacionSQL.CrearUbicacionesDT();

                List<Sector> lstSectores = new List<Sector>();
                List<Ubicacion> ubicacionesModificadas = new List<Ubicacion>();

                /*Agrupo todos los sectores y ubicaciones modificadas*/
                for (int i = 0; i < anaquel.lstZonas.Count; i++)
                {
                    lstSectores.AddRange(anaquel.lstZonas[i].LstSectores);
                    for (int j = 0; j < anaquel.lstZonas[i].LstSectores.Count; j++)
                    {
                        ubicacionesModificadas.AddRange(anaquel.lstZonas[i].LstSectores[j].LstUbicaciones);
                    }

                }

                /*Agrego las filas a los DT*/
                sectorSQL.AgregarFilasToSectoresDT(sectoresDT, lstSectores);
                ubicacionSQL.AgregarFilasToUbicacionesDT(ubicacionesDT, ubicacionesModificadas);

                /*empieza el guardado en la bd*/
                exito = sectorSQL.AgregarMasivo(sectoresDT, trans); //insertados en TemporalSector
                if (exito > 0)
                {
                    exito = sectorSQL.ActualizarSectorMasivo(); //actualizados en tabla Sector
                    if (exito > 0)
                    {

                        exito = sectorSQL.ActualizarIdSector(); //actualizo idSector en tabla sector
                        if (exito > 0)
                        {
                            /*Agrego las ubicaciones de almacen de salida*/
                            ubicacionSQL.AgregarFilasToUbicacionesDT(ubicacionesDT, deposito.Ubicaciones, deposito.Ubicaciones[0][0][0].IdAlmacen);
                            exito = ubicacionSQL.AgregarMasivo(ubicacionesDT, trans);
                            if (exito > 0)
                            {
                                exito = ubicacionSQL.ActualizarIdSector();
                                if (exito > 0)
                                {
                                    exito = ubicacionSQL.ActualizarUbicacionMasivo();
                                    if (exito > 0)
                                    {
                                        /*Agrego el movimiento como un "todo" a la bd*/
                                        NotaISSQL notaSQL = new NotaISSQL(db);

                                        /*Salida para el depósito*/
                                        NotaIS nota = new NotaIS();
                                        nota.IdMotivo = 8;
                                        nota.Tipo = 2;
                                        nota.Observaciones = "";
                                        nota.IdDoc = 0;
                                        nota.IdAlmacen = idDeposito;
                                        nota.IdResponsable = idResponsable;

                                        /*Entrada para el anaquel*/
                                        NotaIS notaAn = new NotaIS();
                                        notaAn.IdMotivo = 8;
                                        notaAn.Tipo = 1;
                                        notaAn.Observaciones = "";
                                        notaAn.IdDoc = 0;
                                        notaAn.IdAlmacen = idAnaquel;
                                        notaAn.IdResponsable = idResponsable;

                                        int idNotaDeposito = notaSQL.AgregarNota(nota, 1);
                                        int idNotaAnaquel = notaSQL.AgregarNota(notaAn, 1);

                                        if (idNotaDeposito > 0 && idNotaAnaquel> 0)
                                        {
                                            exito = sectorSQL.ActualizarTemporalSector(idNotaDeposito);

                                            if (exito > 0)
                                            {
                                                exito = notaSQL.AgregarNotaxSector();

                                                if (exito > 0)
                                                {
                                                    exito = sectorSQL.ActualizarTemporalSector(idNotaAnaquel);

                                                    if (exito > 0)
                                                    {
                                                        exito = notaSQL.AgregarNotaxSector();
                                                        if (exito > 0)
                                                        {
                                                            UtilesSQL util = new UtilesSQL(db);
                                                            util.LimpiarTabla("TemporalUbicacion");
                                                            util.LimpiarTabla("TemporalSector");

                                                            trans.Commit();
                                                            _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Los productos fueron transferidos correctamente"));
                                                            return;
                                                        }

                                                    }

                                                }
                                            }

                                        }

                                    }
                                }
                            }
                        }
                    }
                }
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Lo sentimos , se produjo un error"));
                trans.Rollback();
            }
            catch (SqlException e)
            {
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Se fue la conexión"));
            }
        }
        public void Guardar()
        {
            OrdenCompra o = new OrdenCompra();
            o.IdOrden = idOrden;
            o.IdAlmacen = 4;
            o.LstProducto = Lst;
            o.MedioPago = EstadoSelected;
            o.Observaciones = Observaciones;
            o.FechaSinAtencion = FechaAtencion;
            o.Proveedor = Prov;

                if (Validar(o))
                {

                    OrdenCompraSQL oSQL = new OrdenCompraSQL();
                    OrdenCompraxProductoSQL opSQL = new OrdenCompraxProductoSQL();

                    if (esNuevo)
                    {

                        o.Estado = 2;

                        oSQL.Agregar(o);

                        int id = new UtilesSQL().ObtenerMaximoID("OrdenCompra", "idOrden");

                        foreach (ProductoxOrdenCompra oc in o.LstProducto)
                        {
                            oc.IdOrden = id;
                            opSQL.Agregar(oc);

                        }

                        MessageBox.Show("Se Generó Exitosamente la Orden de Compra", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        if (model != null)
                        {
                            model.Buscar();
                        }

                        this.TryClose();

                    }
                    else
                    {
                        o.Estado = estado;

                        oSQL.Actualizar(o);

                        if (o.Estado == 1)
                        {
                            opSQL.Eliminar(o);
                            foreach (ProductoxOrdenCompra oc in o.LstProducto)
                            {
                                oc.IdOrden = idOrden;
                                opSQL.Agregar(oc);

                            }

                            DialogResult result = MessageBox.Show("Está trabajando con un BORRADOR , desea EMITIRLO? ", "AVISO", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                            if (result == DialogResult.Yes)
                            {
                                o.Estado = 2;
                                oSQL.Actualizar(o);
                                MessageBox.Show("Se EMITIÓ adecuadamente la Orden de Compra", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            }
                        }
                        else
                        {

                            foreach (ProductoxOrdenCompra oc in o.LstProducto)
                            {
                                oc.IdOrden = idOrden;
                                opSQL.Actualizar(oc);
                                MessageBox.Show("Se Editó adecuadamente la Orden de Compra", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            }

                        }

                        if (model != null)
                        {
                            model.Buscar();
                        }
                        this.TryClose();

                    }

                }
        }
        public void Guardar(DynamicGrid almacenDG )
        {
            DBConexion db = new DBConexion();
            db.conn.Open();
            SqlTransaction trans = db.conn.BeginTransaction(IsolationLevel.Serializable);
            db.cmd.Transaction = trans;
            uSQL = new UbicacionSQL(db);
            DataTable temporal= uSQL.CrearUbicacionesDT();
            uSQL.AgregarFilasToUbicacionesDT(temporal, almacenDG.Ubicaciones, id);
            uSQL.AgregarMasivo(temporal, trans);
            int exito= uSQL.ActualizarUbicacionMasivo();
            if (exito > 0)
            {
                UtilesSQL util = new UtilesSQL(db);
                util.LimpiarTabla("TemporalUbicacion");
                trans.Commit();
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Se guardo el stock"));

            }
            else
            {
                trans.Rollback();
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Error: Revisar conexión al servidor"));
            }
        }
        public void GuardarBorrador()
        {
            OrdenCompra o = new OrdenCompra();
            o.IdOrden = idOrden;
            o.IdAlmacen = 4;
            o.LstProducto = Lst;
            o.MedioPago = EstadoSelected;
            o.Observaciones = Observaciones;
            o.FechaSinAtencion = FechaAtencion;
            o.Proveedor = Prov;

            if (Validar(o))
            {

                OrdenCompraSQL oSQL = new OrdenCompraSQL();
                OrdenCompraxProductoSQL opSQL = new OrdenCompraxProductoSQL();

                if (esNuevo)
                {

                       DialogResult result = MessageBox.Show("Está cerrando el Mantenimiento de Orden de compra , desea guardar en BORRADOR ? ", "AVISO", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                       if (result == DialogResult.Yes)
                       {

                           o.Estado = 1;

                           oSQL.Agregar(o);

                           int id = new UtilesSQL().ObtenerMaximoID("OrdenCompra", "idOrden");

                           foreach (ProductoxOrdenCompra oc in o.LstProducto)
                           {
                               oc.IdOrden = id;
                               opSQL.Agregar(oc);

                           }

                           MessageBox.Show("Se guardó la Orden de compra en BORRADOR", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);

                           if (model != null)
                           {
                               model.Buscar();
                           }

                           this.TryClose();
                       }
                }

            }
        }