Beispiel #1
0
        public void CargarTabla()
        {
            DataTable dt = new DataTable();

            peliDuracion = new Dictionary <int, string>();
            pbd          = new ProcesosBD();
            pbd.Conectar();
            string sql = "select *,duracion from funciones f,peliculas p " +
                         "where f.clavepelicula = p.clavenombrepelicula order by clavefuncion desc";

            dt = pbd.SqlSelect(sql).Tables[0];

            if (dt.Rows.Count > 0)
            {
                dgvFunciones.DataSource = dt.DefaultView;

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    peliDuracion.Add(int.Parse(dt.Rows[i][0].ToString()),
                                     dt.Rows[i][18].ToString().Substring(0, 5));
                    //MessageBox.Show(int.Parse(dt.Rows[i][0].ToString()) + "   " +
                    //    dt.Rows[i][18].ToString().Substring(0, 5));
                }
            }
        }
Beispiel #2
0
        private void CargarTabla()
        {
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            pdb = new ProcesosBD();

            pdb.Conectar();

            //consulta para producción
            string sql = "select distinct TRIM(clavenombrePelicula) peliculas from peliculas p, " +
                         "Funciones f where p.claveNombrePelicula = f.clavePelicula and " +
                         "hora>=DATEADD(minute,-20,CONVERT(time,getdate(),108)) order by 1";

            //consulta para desarrollo
            sql = "select distinct TRIM(clavenombrePelicula) peliculas from peliculas p, " +
                  "Funciones f where p.claveNombrePelicula = f.clavePelicula";

            ds = pdb.SqlSelect(sql);
            //dgvVentas.DataSource = ds.Tables[0].DefaultView;
            dt = ds.Tables[0];

            foreach (DataRow row in dt.Rows)
            {
                var cmb = new DataGridViewComboBoxCell();
                //var img = new DataGridViewImageCell();
                //Bitmap bitmap;

                //produccion
                sql = "select hora from Funciones where clavePelicula = '" + row["peliculas"]
                      + "' and hora >=DATEADD(minute,-20,CONVERT(time,getdate(),108))";

                //desarrollo
                sql = "select hora from Funciones where clavePelicula = '"
                      + row["peliculas"] + "'";

                cmb.DataSource    = pdb.SqlSelect(sql).Tables[0].DefaultView;
                cmb.ValueMember   = "hora";
                cmb.DisplayMember = "hora";

                //sql = "select top 1 (imgPath) from Funciones where clavePelicula = " +
                //    "'"+ row["peliculas"] + "'";

                //img.ImageLayout = DataGridViewImageCellLayout.Stretch;

                //MessageBox.Show(root + pdb.SqlSelect(sql).Tables[0].Rows[0][0]);
                //bitmap = new Bitmap(root + pdb.SqlSelect(sql).Tables[0].Rows[0][0]);
                //img.Value = bitmap;

                int n = dgvVentas.Rows.Add();
                dgvVentas.Rows[n].Cells[dgvCols["NombrePelicula"]].Value =
                    row["peliculas"].ToString();
                //dgvVentas.Rows[n].Cells[dgvCols["ImgPelicula"]] = img;
                dgvVentas.Rows[n].Cells[dgvCols["Horario"]]         = cmb;
                dgvVentas.Rows[n].Cells[dgvCols["Descuento"]].Value = "$"
                                                                      + descuento.ToString() + ".00";
                //MessageBox.Show(Program.ClaveUsario.ToString());
            }
            ready = true;
        }
Beispiel #3
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            string sql = "delete from peliculas where claveNombrePelicula='"
                         + claveNombrePelicula + "'";

            if (!claveNombrePelicula.Equals(""))
            {
                DialogResult d = MessageBox.Show(
                    "Seguro que desea eliminar la Película: "
                    + claveNombrePelicula
                    , "Aceptar", MessageBoxButtons.OKCancel);

                if (d.Equals(DialogResult.OK))
                {
                    ProcesosBD pbd = new ProcesosBD();
                    pbd.Conectar();
                    pbd.SqlUpdate(sql);
                    MessageBox.Show("Eliminación exitosa");
                    LimpiarControles();
                    CargarTabla();
                }
            }
            else
            {
                MessageBox.Show("Debe traer los datos por medio de la barra buscar. " +
                                "Coloque el nombre de la película y luego presione 'Enter' o 'Return'");
            }
        }
Beispiel #4
0
        private void CargarTabla()
        {
            pbd = new ProcesosBD();
            pbd.Conectar();
            string sql = "select * from usuarios order by claveusuario desc";

            dgvUsuarios.DataSource = pbd.SqlSelect(sql).Tables[0];
        }
Beispiel #5
0
        private void FrmUsuarios_Load(object sender, EventArgs e)
        {
            dtmInicioContrato.Format       = DateTimePickerFormat.Custom;
            dtmInicioContrato.CustomFormat = "yyyy/MM/dd";

            dtmInicioJornada.Format       = DateTimePickerFormat.Custom;
            dtmInicioJornada.CustomFormat = "HH:mm";


            dtmFinJornada.Format       = DateTimePickerFormat.Custom;
            dtmFinJornada.CustomFormat = "HH:mm";

            string sql = "select claveTipoUsuario,tipoUsuario from TipoUsuario";

            pbd = new ProcesosBD();
            DataTable dt = new DataTable();

            pbd.Conectar();
            cmbTipoUsuario.DataSource    = pbd.SqlSelect(sql).Tables[0].DefaultView;
            cmbTipoUsuario.ValueMember   = "claveTipoUsuario";
            cmbTipoUsuario.DisplayMember = "tipoUsuario";
            cmbTipoUsuario.SelectedValue = 3;

            string[] liSalarios = { "3590.0000", "4575.0000",  "5000.0000",  "6500.0000",  "8000.0000"
                                    ,            "12000.0000", "15000.0000", "23000.0000", "35000.0000", "45000.0000" };

            Dictionary <string, string> liSalario = new Dictionary <string, string>();

            liSalario.Add("3590.0000", "3590.0000");
            liSalario.Add("4575.0000", "4575.0000");
            liSalario.Add("5000.0000", "5000.0000");
            liSalario.Add("6500.0000", "6500.0000");
            liSalario.Add("8000.0000", "8000.0000");
            liSalario.Add("12000.0000", "12000.0000");
            liSalario.Add("15000.0000", "15000.0000");
            liSalario.Add("23000.0000", "23000.0000");
            liSalario.Add("35000.0000", "35000.0000");
            liSalario.Add("45000.0000", "45000.0000");

            sql = "select claveSalario,salario from Salario";

            pbd.Conectar();
            cmbSueldo.DataSource    = pbd.SqlSelect(sql).Tables[0].DefaultView;
            cmbSueldo.DisplayMember = "salario";
            cmbSueldo.ValueMember   = "claveSalario";
            cmbSueldo.SelectedValue = 1;

            //cmbSueldo.Items.AddRange(liSalarios);
            //cmbSueldo.DataSource = new BindingSource(liSalario,null);
            //cmbSueldo.DisplayMember = "Value";
            //cmbSueldo.ValueMember = "Key";



            chkStatusUser.Checked = true;

            CargarTabla();
        }
Beispiel #6
0
        private void CargarTabla()
        {
            pdb = new ProcesosBD();
            pdb.Conectar();
            string sql = "select TRIM(claveNombrePelicula),clasificacion,distribuidor,fechaEstreno," +
                         "fechaRetiro,duracion, disponible from peliculas order by indice desc";

            dgvPeliculas.DataSource = pdb.SqlSelect(sql).Tables[0];
        }
Beispiel #7
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (claveFunciones != 0)
            {
                vaciarFormAFunciones();
                int disponible = 1;
                if (!funciones.Disponible)
                {
                    disponible = 0;
                }

                string sql = "update Funciones set " +
                             " claveSala='" + funciones.ClaveSala + "'," +
                             " clavePelicula='" + funciones.ClavePelicula + "'," +
                             " claveTipoFuncion='" + funciones.ClaveTipoFuncion + "'," +
                             " claveIdioma='" + funciones.ClaveIdioma + "'," +
                             " claveSubtitulos='" + funciones.ClaveSubtitulos + "'," +
                             " fecha='" + funciones.Fecha.ToString("yyyy/MM/dd") + "'," +
                             " hora='" + funciones.Hora.ToString("HH:mm") + "'," +
                             " disponible='" + disponible + "'," +
                             " imgPath='" + funciones.ImgPath + "'" +
                             " where clavePelicula = '" + funciones.ClavePelicula + "'";

                Console.WriteLine(sql);

                if (validarDisponibilidad() && validarDatosEntrada())
                {
                    ProcesosBD pbd = new ProcesosBD();
                    DataTable  dt  = new DataTable();
                    pbd.Conectar();
                    pbd.SqlUpdate(sql);
                    dt = buscarPorId();
                    dgvFunciones.DataSource = dt.DefaultView;
                    MessageBox.Show("Actualización correcta");
                    limpiarControles();
                }

                //validarDatos();
                //ProcesosBD pbd = new ProcesosBD();
                //DataTable dt = new DataTable();
                //pbd.Conectar();
                //pbd.SqlUpdate(sql);
                //dt = buscarPorId();
                //dgvFunciones.DataSource = dt.DefaultView;
                //MessageBox.Show("Actualización correcta");
                //limpiarControles();
            }
            else
            {
                MessageBox.Show("Debe traer los datos por medio de la barra buscar. " +
                                "Coloque cualquiera de los siguientes datos: " +
                                "clave de Pelicula o nombre de pelicula " +
                                "y luego presione 'Enter' o 'Return'");
            }
        }
Beispiel #8
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (claveUsuario != 0)
            {
                bool datosValidos = true;
                vaciarFormAUsuario();
                datosValidos = validarDatosEntrada();

                if (datosValidos)
                {
                    string sql = "update Usuarios set " +
                                 "curp = '" + usuario.Curp + "'," +
                                 "Nombres = '" + usuario.Nombres + "'," +
                                 "paterno = '" + usuario.Paterno + "'," +
                                 "materno='" + usuario.Materno + "'," +
                                 "claveTipoUsuario='" + usuario.ClaveTipoUsuario + "'," +
                                 "calle='" + usuario.Calle + "'," +
                                 "numeroExterior='" + usuario.NumExt + "'," +
                                 "numeroInterior='" + usuario.NumInt + "',cp='" + usuario.Cp + "'," +
                                 "colonia='" + usuario.Colonia + "',localidad='" + usuario.Localidad + "'," +
                                 "telefonoCasa='" + usuario.TelCasa + "'," +
                                 "telefonoMovil='" + usuario.TelMovil + "'," +
                                 "inicioContrato='" + usuario.InicioContrato + "'," +
                                 "inicioTurno='" + usuario.InicioTurno + "'," +
                                 "finTurno='" + usuario.FinTurno + "'," +
                                 "mail='" + usuario.Mail + "'," +
                                 "claveSalario='" + cmbSueldo.SelectedValue + "'," +
                                 "contrasena='" + usuario.Password + "'," +
                                 "disponible='" + usuario.Disponible + "' " +
                                 "where claveUsuario = '" + claveUsuario + "'";

                    Console.WriteLine(sql);

                    //validarDatos();
                    ProcesosBD pbd = new ProcesosBD();
                    DataTable  dt  = new DataTable();
                    pbd.Conectar();
                    pbd.SqlUpdate(sql);
                    dt = buscarPorId();
                    dgvUsuarios.DataSource = dt.DefaultView;
                    MessageBox.Show("Actualización correcta");
                    limpiarControles();
                }
            }
            else
            {
                MessageBox.Show("Debe traer los datos por medio de la barra buscar. " +
                                "Coloque cualquiera de los siguientes datos: " +
                                "clave de Usuario, nombre del usuario, Paterno, Teléfono Móvil, mail" +
                                "y luego presione 'Enter' o 'Return'");
            }
        }
Beispiel #9
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            funciones = new Funciones();
            int  status       = 1;
            bool datosValidos = true;
            bool dispon       = true;

            dispon       = validarDisponibilidad();
            datosValidos = validarDatosEntrada();

            if (datosValidos && dispon)
            {
                funciones.ClaveSala        = int.Parse(cmbSalas.SelectedValue.ToString());
                funciones.ClavePelicula    = cmbPeliculas.SelectedValue.ToString();
                funciones.ClaveTipoFuncion = int.Parse(cmbTipoFuncion.SelectedValue.ToString());
                funciones.ClaveIdioma      = int.Parse(cmbIdioma.SelectedValue.ToString());
                funciones.ClaveSubtitulos  = int.Parse(cmbSubtitulos.SelectedValue.ToString());
                funciones.Fecha            = dtmFechaProy.Value;
                funciones.Hora             = dtmHoraIni.Value;
                funciones.Disponible       = chkPeliDisp.Checked;
                if (!funciones.Disponible)
                {
                    status = 0;
                }
                funciones.ImgPath = txtImgPath.Text;

                string sql = "insert into Funciones(claveSala,clavePelicula,claveTipoFuncion," +
                             "claveIdioma,claveSubtitulos,fecha,hora,disponible, imgPath)" +
                             "values("
                             + funciones.ClaveSala + ","
                             + "'" + funciones.ClavePelicula.ToString().Trim() + "',"
                             + funciones.ClaveTipoFuncion + ","
                             + funciones.ClaveIdioma + ","
                             + funciones.ClaveSubtitulos + ","
                             + "'" + funciones.Fecha.ToString("yyyy/MM/dd") + "',"
                             + "'" + funciones.Hora.ToString("hh:mm") + "',"
                             + status + ","
                             + "'" + funciones.ImgPath + "'"
                             + ")";
                Console.Write(sql);
                pbd = new ProcesosBD();
                pbd.Conectar();

                pbd.SqlUpdate(sql);

                MessageBox.Show("Se ha insertado el registro exitosamente");

                CargarTabla();
            }
        }
Beispiel #10
0
        private DataTable buscarPorId()
        {
            DataTable dt = new DataTable();

            claveNombrePelicula = txtBuscar.Text;

            string sql = "select top 1 * from Peliculas " +
                         " where claveNombrePelicula like '%" + claveNombrePelicula + "%'";

            Console.WriteLine(sql);

            ProcesosBD pbd = new ProcesosBD();

            pbd.Conectar();
            dt = pbd.SqlSelect(sql).Tables[0];

            return(dt);
        }
Beispiel #11
0
        private bool validarDisponibilidad()
        {
            DataTable dt     = new DataTable();
            bool      valido = true;

            string sql = "select top 1 clavefuncion from funciones " +
                         "where clavesala = " + cmbSalas.SelectedValue +
                         " and clavePELICULA !='" + cmbPeliculas.SelectedValue + "' ";

            ProcesosBD pdb = new ProcesosBD();

            pbd.Conectar();
            dt = pbd.SqlSelect(sql).Tables[0];

            if (getHorarioIni() < 11 || getHorarioIni() > 23)
            {
                MessageBox.Show("Las funciones no pueden empezar " +
                                "antes de las 11:00 am ni despues de las 23:00");
                valido = false;
            }
            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Esta sala ya esta reservada para una función.Seleccione otra.");
                valido = false;
            }
            //else
            //{
            //    MessageBox.Show("l HORA:" + dtmHoraIni.Value.ToString().Substring(10, 14));
            //    sql = "select * from funciones where hora > '"+ dtmHoraIni.Value.ToString().Substring(10,14)+ "' " +
            //        "and hora<'11:00'";
            //    pbd.Conectar();
            //    dt = pbd.SqlSelect(sql).Tables[0];
            //    if (dt.Rows.Count > 0)
            //    {
            //        MessageBox.Show("No se pueden empalmar los horarios seleccione otro");
            //        valido = false;
            //    }

            //}

            return(valido);
        }
Beispiel #12
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            vaciarFormAPeliculas();
            int disponible = 1;

            if (!peliculas.Disponible)
            {
                disponible = 0;
            }
            peliculas.Duracion = parseDuracion(numDuracion.Value);

            string sql = "update peliculas " +
                         " set claveNombrePelicula=UPPER('" + peliculas.ClaveNombrePelicula + "')," +
                         " clasificacion='" + peliculas.Clasificacion + "'," +
                         " distribuidor='" + peliculas.Distribuidor + "'," +
                         " fechaEstreno='" + peliculas.FechaEstreno + "'," +
                         " fechaRetiro='" + peliculas.FechaRetiro + "'," +
                         " duracion='" + peliculas.Duracion + "'," +
                         " disponible=" + disponible + "" +
                         " where claveNombrePelicula = '" + claveNombrePelicula + "'";

            Console.WriteLine(sql);

            if (!claveNombrePelicula.Equals("") && !peliculas.ClaveNombrePelicula.Equals(""))
            {
                ProcesosBD pbd = new ProcesosBD();
                DataTable  dt  = new DataTable();
                pbd.Conectar();
                pbd.SqlUpdate(sql);
                txtBuscar.Text          = txtNombrePeli.Text;
                dt                      = buscarPorId();
                dgvPeliculas.DataSource = dt.DefaultView;
                MessageBox.Show("Actualización correcta");
                LimpiarControles();
            }
            else
            {
                MessageBox.Show("Debe traer los datos por medio de la barra buscar. " +
                                "Coloque el nombre de la película y luego presione 'Enter' o 'Return'");
            }
        }
Beispiel #13
0
        public void getAsientos(Dictionary <int, Butaca> liButacas, int row)
        {
            ProcesosBD pbd = new ProcesosBD();
            string     butacasMostradas   = "";
            string     butacasInsertQuery = "";

            this.liButacas = liButacas;
            int i = 0;

            foreach (KeyValuePair <int, Butaca> butaca in liButacas)
            {
                if (i == 0)
                {
                    butacasMostradas   += butaca.Value.FilaLetra + butaca.Value.Asiento;
                    butacasInsertQuery += butaca.Value.Fila + "," + butaca.Value.Asiento;
                }
                else
                {
                    butacasMostradas   += ", " + butaca.Value.FilaLetra + butaca.Value.Asiento;
                    butacasInsertQuery += "|" + butaca.Value.Fila + "," + butaca.Value.Asiento;
                }
                i++;
            }
            dgvVentas.Rows[row].Cells[dgvCols["AsientosSeleccionados"]].Value = butacasMostradas;

            pbd.Conectar();

            string sql = "select precio from ListaDePrecios where claveListaDePrecios in " +
                         "(select claveListaDePrecios from TipoFuncion where claveTipoFuncion = "
                         + dgvVentas.Rows[row].Cells[dgvCols["TipoFuncion"]].Value.ToString() + ")";

            string precio = pbd.SqlSelect(sql).Tables[0].Rows[0][0].ToString();

            //MessageBox.Show(precio);

            precioUnitario = float.Parse(pbd.SqlSelect(sql).Tables[0]
                                         .Rows[0][0].ToString());

            dgvVentas.Rows[row].Cells[dgvCols["PrecioUnitario"]].Value = "$" + precioUnitario + ".00";
        }
Beispiel #14
0
        private void cargarForm()
        {
            string sql = "select  * from Salas";


            pbd = new ProcesosBD();
            pbd.Conectar();
            dt = pbd.SqlSelect(sql).Tables[0];
            liSalaTipoSala.Clear();

            if (dt.Rows.Count > 0)
            {
                cmbSalas.DataSource    = dt.DefaultView;
                cmbSalas.DisplayMember = "claveSala";
                cmbSalas.ValueMember   = "claveSala";

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    liSalaTipoSala.Add(int.Parse(dt.Rows[i][0].ToString()),
                                       int.Parse(dt.Rows[i][1].ToString()));
                    //MessageBox.Show(dt.Rows[i][0].ToString() + "  " + dt.Rows[i][1].ToString());
                }
            }

            sql = "select claveTipoSala, descripcion + ' ' + " +
                  "convert(nvarchar,capacidad,103)descripcion from TipoSala";

            pbd.Conectar();
            dt = pbd.SqlSelect(sql).Tables[0];

            if (dt.Rows.Count > 0)
            {
                cmbTipoSalaMod.DataSource    = dt.DefaultView;
                cmbTipoSalaMod.DisplayMember = "descripcion";
                cmbTipoSalaMod.ValueMember   = "claveTipoSala";
            }

            chkDisponibleMod.Checked = true;
        }
        private DataTable buscarPorId(string tabla)
        {
            DataTable dt  = new DataTable();
            string    sql = "";

            long clave    = 0;
            bool esNumero = long.TryParse(txtBuscar.Text.ToString().Trim(), out clave);

            if (esNumero)
            {
                clave = long.Parse(txtBuscar.Text.ToString().Trim());
            }


            //MessageBox.Show("se ha presionado enter");
            if (tabla.Equals("Boletos"))
            {
                sql = "select clavePelicula,claveSala,hora,fila,asiento,boleto,b.claveVenta from " +
                      "Funciones f,Boletos b where f.claveFuncion = b.claveFuncion and " +
                      "boleto =" + clave;
            }
            else
            {
                sql = "select clavePelicula,claveSala,hora,fila,asiento,boleto,b.claveVenta from " +
                      "Funciones f,Boletos b where " +
                      "f.claveFuncion = b.claveFuncion and " +
                      "claveVenta =" + clave;
            }



            Console.WriteLine(sql);
            pbd = new ProcesosBD();
            pbd.Conectar();
            dt = pbd.SqlSelect(sql).Tables[0];

            return(dt);
        }
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (lblClaveVenta.Text.Equals(""))
            {
                MessageBox.Show("Debe obtener los datos por medio del buscador para proceder");
            }
            else
            {
                string[]  arrBoletos = lblBoletos.Text.Split(',');
                string    usuario    = txtUsuario.Text;
                string    pass       = txtPass.Text;
                string    motivo     = txtMotivo.Text;
                DataTable dt;

                string sql = "select claveTipoUsuario,claveUsuario,contrasena from Usuarios " +
                             "where claveUsuario='" + usuario + "' and contrasena = '"
                             + pass + "' and disponible=1 and claveTipoUsuario in(1,2,4)";

                Console.WriteLine(sql);

                pbd = new ProcesosBD();
                pbd.Conectar();
                dt = new DataTable();
                dt = pbd.SqlSelect(sql).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    sql = "insert into Cancelados values";
                    for (int i = 0; i < arrBoletos.Length; i++)
                    {
                        if (i == 0)
                        {
                            sql += "(" +
                                   "" + lblClaveVenta.Text + "," +
                                   "" + arrBoletos[0] + "," +
                                   "getdate()," +
                                   "'" + motivo + "'," +
                                   "'" + usuario + "'," +
                                   "'" + pass + "')";
                        }
                        else
                        {
                            sql += ",(" +
                                   "" + lblClaveVenta.Text + "," +
                                   "" + arrBoletos[i] + "," +
                                   "getdate()," +
                                   "'" + motivo + "'," +
                                   "'" + usuario + "'," +
                                   "'" + pass + "')";
                        }
                    }

                    Console.WriteLine(sql);
                    pbd.Conectar();
                    pbd.SqlUpdate(sql);

                    MessageBox.Show("Se ha realizado la cancelación");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Sus credenciales no son válidas");
                }
            }
        }
Beispiel #17
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            peliculas = new Peliculas();
            int  disponible    = 1;
            bool PermisoInsert = true;

            if (txtNombrePeli != null && !txtNombrePeli.Text.Equals(""))
            {
                peliculas.ClaveNombrePelicula = txtNombrePeli.Text.ToUpper();
            }
            else
            {
                MessageBox.Show("Elnombre no puede estar vacío"); PermisoInsert = false;
            }

            if (cmbClasifica != null && cmbClasifica.Text != "Seleccionar")
            {
                peliculas.Clasificacion = cmbClasifica.Text;
            }
            else
            {
                MessageBox.Show("Debe seleccionar una clasificacion"); PermisoInsert = false;
            }
            if (cmbDistrib != null && cmbDistrib.Text != "Seleccionar")
            {
                peliculas.Distribuidor = cmbDistrib.Text;
            }
            else
            {
                MessageBox.Show("Debe seleccionar un distribuidor"); PermisoInsert = false;
            }
            if (numDuracion != null && numDuracion.Value > 0)
            {
                peliculas.Duracion = parseDuracion(numDuracion.Value);
            }
            else
            {
                MessageBox.Show("La duración de la Pelícua no puede ser 0"); PermisoInsert = false;
            }
            if (dtmEstreno != null)
            {
                peliculas.FechaEstreno = dtmEstreno.Text;
            }
            else
            {
                PermisoInsert = false;
            }
            if (dtmRetiro != null)
            {
                peliculas.FechaRetiro = dtmRetiro.Text;
            }
            else
            {
                PermisoInsert = false;
            }
            if (chkDisponible != null)
            {
                if (chkDisponible.Checked)
                {
                    peliculas.Disponible = true;
                    disponible           = 1;
                }
                else
                {
                    peliculas.Disponible = false;
                    disponible           = 0;
                }
            }
            else
            {
                PermisoInsert = false;
            }

            if (peliculas.ClaveNombrePelicula != null && PermisoInsert)
            {
                string sql = "select claveNombrePelicula from peliculas where " +
                             "claveNombrePelicula = '" + peliculas.ClaveNombrePelicula.Trim() + "'";

                pdb = new ProcesosBD();
                pdb.Conectar();
                if (pdb.SqlSelect(sql).Tables[0].Rows.Count > 0)
                {
                    MessageBox.Show("El registro ya existe en la base de datos");
                }
                else
                {
                    if (PermisoInsert)
                    {
                        try
                        {
                            sql = "insert into Peliculas(claveNombrePelicula,clasificacion,distribuidor," +
                                  "fechaEstreno,fechaRetiro,duracion, disponible)" +
                                  "values("
                                  + "'" + peliculas.ClaveNombrePelicula + "',"
                                  + "'" + peliculas.Clasificacion + "',"
                                  + "'" + peliculas.Distribuidor + "',"
                                  + "'" + peliculas.FechaEstreno + "',"
                                  + "'" + peliculas.FechaRetiro + "',"
                                  + "'" + peliculas.Duracion + "',"
                                  + disponible
                                  + ")";
                            pdb.SqlUpdate(sql);
                            MessageBox.Show("Registro exitoso");
                            LimpiarControles();
                            CargarTabla();
                        }
                        catch (Exception e1)
                        {
                            MessageBox.Show("No fue posible insertar en la base de datos, causa: " + e1);
                        }
                    }
                }
            }
        }
Beispiel #18
0
        private void dgvVentas_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (ready)
            {
                string sql = "";
                if (e.ColumnIndex == dgvCols["CerrarVenta"])
                {
                    if (dgvVentas.Rows[e.RowIndex]
                        .Cells[dgvCols["AsientosSeleccionados"]].Value != null)
                    {
                        //MessageBox.Show("se ha presionado el boton");
                        int cantBoletos = int.Parse(dgvVentas.Rows[e.RowIndex]
                                                    .Cells[dgvCols["CantidadAsientos"]].Value.ToString());
                        float precioBoletos =
                            precioUnitario * cantBoletos;

                        float importeTotal = precioBoletos - descuento;

                        DialogResult d = MessageBox.Show("Confirmar Pago\n"
                                                         + "Cantidad de Boletos:  \t" + cantBoletos + "\n"
                                                         + "Precio Unitario:  \t\t$" + precioUnitario + ".00\n"
                                                         + "Descuento:  \t\t$" + descuento + ".00\n"
                                                         + "Importe Total: \t\t$" + importeTotal + ".00\n"
                                                         , "Aceptar", MessageBoxButtons.OKCancel);

                        int i = 0;
                        if (d.Equals(DialogResult.OK))
                        {
                            int        p          = 0;
                            int        sumaPuntos = 0;//solo puede ser 0 o 1
                            ProcesosBD pbd        = new ProcesosBD();
                            pbd.Conectar();
                            List <long> liClaveBoletos = new List <long>();

                            sql = "select NEXT VALUE FOR SCH_Boletos.AI_Boletos";
                            for (int n = 0; n < liButacas.Count; n++)
                            {
                                liClaveBoletos.Add(long.Parse(pbd.SqlSelect(sql).Tables[0]
                                                              .Rows[0][0].ToString()));
                            }

                            sql = "select next value for SCH_Ventas.AI_Ventas";

                            int claveVenta = int.Parse(pbd.SqlSelect(sql).Tables[0].Rows[0][0]
                                                       .ToString());

                            pbd.Conectar();
                            pbd.abrirConexion();
                            pbd.comenzarTransaccion();

                            try
                            {
                                if (!claveCli.Equals("NULL"))
                                {
                                    sumaPuntos = 1; //el cliente es válido por lo que la compra suma puntos
                                                    //este valor se usa en otro punto del código
                                    sql = "update Clientes " +
                                          "set puntosUsados = (select puntosUsados " +
                                          "from Clientes where claveCliente =" +
                                          "" + claveCli + ") + " + puntos + ", " +
                                          "puntos = (select puntos from Clientes where claveCliente = " +
                                          "" + claveCli + ") + " + p + " " +
                                          "where claveCliente = " +
                                          "" + claveCli + "";

                                    pbd.sqlUpdateTransaction(sql);
                                }

                                sql = "insert into ventas(claveVenta,claveCliente,claveUsuario" +
                                      ",horaFechaVenta,importeTotal) values " +
                                      "(" + claveVenta + "," +
                                      "" + claveCli + "" +
                                      "," + Program.ClaveUsario + "" +
                                      ",CONVERT(datetime, GETDATE(),103)" +
                                      "," + importeTotal + ")";

                                pbd.sqlUpdateTransaction(sql);

                                sql = "insert into Boletos(boleto,claveFuncion, asiento,fila" +
                                      ",fechaHoraImpresion,claveVenta)" +
                                      " values";
                                foreach (KeyValuePair <int, Butaca> butaca in liButacas)
                                {
                                    if (i == 0)
                                    {
                                        sql += "(" +
                                               "" + liClaveBoletos[i++] + "," +
                                               "" + claveFuncion + "," +
                                               "" + butaca.Value.Asiento + "," +
                                               "" + butaca.Value.Fila + "," +
                                               "CONVERT(datetime,getdate(),103)" + "," +
                                               "" + claveVenta + ")";
                                    }
                                    else
                                    {
                                        sql += ",(" +
                                               "" + liClaveBoletos[i++] + "," +
                                               "" + claveFuncion + "," +
                                               "" + butaca.Value.Asiento + "," +
                                               "" + butaca.Value.Fila + "," +
                                               "CONVERT(datetime,getdate(),103)" + "," +
                                               "" + claveVenta + ")";
                                    }
                                }
                                i = 0;
                                pbd.sqlUpdateTransaction(sql);

                                sql = "insert into DetallesVentas(claveVenta,boleto,claveTipoVenta" +
                                      ",descuento,iva,precioUnitario,importeParcial" +
                                      ",fechaHoraRegistro,sumaPuntos) values";
                                for (int n = 0; n < liButacas.Count; n++)
                                {
                                    if (puntos <= 0)
                                    {
                                        descuento = 0;
                                    }
                                    if (n == 0)
                                    {
                                        sql +=
                                            "(" +
                                            "" + claveVenta +
                                            "," + liClaveBoletos[i++] +
                                            ",1" +//tipoventa 1 solo para venta de boletos
                                            "," + descuento + "" +
                                            ",0" +
                                            "," + precioUnitario +
                                            "," + (precioUnitario + precioUnitario * iva - descuento) + "" +
                                            ",CONVERT(datetime, GETDATE(),103)" +
                                            "," + sumaPuntos + ")";
                                    }
                                    else
                                    {
                                        sql +=
                                            ",(" +
                                            "" + claveVenta + "" +
                                            "," + liClaveBoletos[i++] + "" +
                                            ",1" +//tipoventa 1 solo para venta de boletos
                                            "," + descuento + "" +
                                            ",0" +
                                            "," + precioUnitario +
                                            "," + (precioUnitario + precioUnitario * iva - descuento) + "" +
                                            ",CONVERT(datetime, GETDATE(),103)" +
                                            "," + sumaPuntos + ")";
                                    }

                                    puntos--;
                                }

                                pbd.sqlUpdateTransaction(sql);
                                // Attempt to commit the transaction.
                                pbd.Transaction.Commit();

                                Console.WriteLine("Both records are written to database.");
                                MessageBox.Show("Venta registrada");
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Commit Exception Type: {0}", ex.GetType());
                                Console.WriteLine("  Message: {0}", ex.Message);
                                MessageBox.Show("Venta no registrada");
                                // Attempt to roll back the transaction.
                                try
                                {
                                    pbd.Transaction.Rollback();
                                }
                                catch (Exception ex2)
                                {
                                    // This catch block will handle any errors that may have occurred
                                    // on the server that would cause the rollback to fail, such as
                                    // a closed connection.
                                    Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType());
                                    Console.WriteLine("  Message: {0}", ex2.Message);
                                }
                            }
                            finally
                            {
                                veces      = 0;
                                filaActual = e.RowIndex;
                                limpiarControles();


                                pbd.Conexion.Close();
                                if (!claveCli.Equals("NULL"))
                                {
                                    sql = "select count(boleto)puntos from DetallesVentas d " +
                                          "where fechaHoraRegistro >= GETDATE()-90  and fechaPuntosUsados is null " +
                                          "and boleto not in (select boleto from Cancelados)  " +
                                          "and d.claveVenta not in (select d.claveVenta  from Cancelados) " +
                                          "and sumaPuntos = 1  and claveVenta in (select claveVenta  " +
                                          "from Ventas where claveCliente = " + claveCli + ")";

                                    Console.WriteLine(sql);

                                    dt = pbd.SqlSelect(sql).Tables[0];

                                    if (dt.Rows.Count > 0)
                                    {
                                        if (int.Parse(dt.Rows[0][0].ToString()) >= 5)
                                        {
                                            p = int.Parse(dt.Rows[0][0].ToString()) / 5;

                                            //MessageBox.Show("puntos" + p);

                                            sql = "update DetallesVentas set fechaPuntosUsados=GETDATE() " +
                                                  "where claveVenta in(select claveVenta from Ventas where " +
                                                  "claveCliente = " + claveCli + ")  " +
                                                  "and sumaPuntos = 1 " +//sumaPuntos=1 habilita la suma de los puntos
                                                  "and fechaPuntosUsados is null";

                                            pbd.SqlUpdate(sql);

                                            sql = "update Clientes " +
                                                  "set puntos = (select puntos from Clientes where claveCliente = " +
                                                  "" + claveCli + ") + " + p + " " +
                                                  "where claveCliente = " +
                                                  "" + claveCli + "";

                                            pbd.SqlUpdate(sql);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Debe seleccionar los asientos");
                    }
                }
                else if (e.ColumnIndex == dgvCols["SeleccionarAsientos"])
                {
                    if (dgvVentas.Rows[e.RowIndex].Cells[dgvCols["CantidadAsientos"]].Value != null)
                    {
                        sql = "select capacidad from TipoSala t,Salas s,Funciones f " +
                              " where f.claveSala = s.claveSala and s.claveTipoSala = t.claveTipoSala" +
                              " and claveFuncion ="
                              + claveFuncion;

                        Console.WriteLine("consulta para capacidad:" + sql);

                        int capacidad = int.Parse(pdb.SqlSelect(sql).Tables[0].Rows[0][0]
                                                  .ToString());
                        Console.WriteLine("capacidad:" + capacidad);

                        sql = "select fila,asiento from Boletos where claveFuncion = "
                              + claveFuncion + "" +
                              " and claveVenta not in(select c.claveVenta from Cancelados c," +
                              "boletos b where c.claveVenta = b.claveVenta)" +
                              " order by 1,2 asc";

                        Console.WriteLine("consulta para boletos: " + sql);

                        ds = pdb.SqlSelect(sql);
                        dt = ds.Tables[0];
                        Sala sala = null;
                        if (capacidad == 20)
                        {
                            sala = new SalaTipo2();
                        }
                        else if (capacidad == 50)
                        {
                            sala = new SalaTipo1();
                        }

                        sala.ObtenerAcomodamiento(dt, capacidad);
                        Console.Write(sala);
                        sala.imprimirAcomodamiento();

                        int cantAsientosPorVender =
                            int.Parse(dgvVentas.Rows[e.RowIndex].Cells[dgvCols["CantidadAsientos"]].Value.ToString());

                        int row = e.RowIndex;

                        FrmVentasLugares frmVentasLugares =
                            new FrmVentasLugares(this, cantAsientosPorVender, sala, row);
                        frmVentasLugares.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Debe elegir la cantidad de boletos");
                    }
                }
            }
        }
Beispiel #19
0
        public void CargarTabla()
        {
            DataTable  dt  = new DataTable();
            DataTable  dt2 = new DataTable();
            ProcesosBD pbd = new ProcesosBD();

            string root = @"F:\UVM\Tareas UVM\07 Septimo Semestre\Ing. de Software I\Parcial 1\";

            string sql = "select distinct(clavePelicula)pelicula," +
                         "imgPath from Funciones";

            pbd.Conectar();
            dt = pbd.SqlSelect(sql).Tables[0];
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sql = "select hora,Idioma,descripcion " +
                          "from Funciones f,Idioma i,TipoFuncion t where " +
                          "clavePelicula = '" + dt.Rows[i][0].ToString() + "' " +
                          "and t.claveTipoFuncion = f.claveTipoFuncion " +
                          "and i.claveIdioma = f.claveIdioma";

                    Funciones funciones = new Funciones();


                    pbd.Conectar();
                    dt2 = pbd.SqlSelect(sql).Tables[0];
                    string horarios    = "\n\rHorarios: ";
                    string idioma      = "\n\rIdioma: ";
                    string tipoFuncion = "\n\r";
                    if (dt2.Rows.Count > 0)
                    {
                        for (int j = 0; j < dt2.Rows.Count; j++)
                        {
                            funciones.Hora = Convert.ToDateTime(dt2.Rows[j][0].ToString());
                            horarios      += funciones.Hora.ToString("hh:mm") + " ";
                        }

                        idioma      += dt2.Rows[0][1] + " ";
                        tipoFuncion += dt2.Rows[0][2] + " ";
                    }

                    TableLayoutPanel panel = new TableLayoutPanel();
                    panel.Size = new Size(200, 500);
                    PictureBox picture = new PictureBox();
                    picture.Image    = Image.FromFile(root + dt.Rows[i][1].ToString());
                    picture.Size     = new Size(200, 250);
                    picture.SizeMode = PictureBoxSizeMode.CenterImage;
                    //Contenedor.Controls.Add(picture);
                    Label DatosPelicula = new Label();
                    DatosPelicula.Size = new Size(200, 250);
                    Console.Write(dt.Rows[i][0].ToString() + horarios + idioma + tipoFuncion);
                    DatosPelicula.Text = dt.Rows[i][0].ToString() + horarios + idioma + tipoFuncion;
                    //Contenedor.Controls.Add(descripcion);
                    panel.Controls.Add(picture);
                    panel.Controls.Add(DatosPelicula);
                    Contenedor.Controls.Add(panel);
                }
            }
        }
        private void btnPeliBuscar_Click(object sender, EventArgs e)
        {
            //List<float> ventaMensual=new List<float>();
            //List<string> mes = new List<string>();

            string sql = "select SUM(importeTotal)ventaSemanal, " +
                         "DATENAME(WEEK,horaFechaVenta)semana  from Ventas  " +
                         "where YEAR(horaFechaVenta) = '" + cmbYearPeli.SelectedValue.ToString() + "' " +
                         "and month(horaFechaVenta) = " + cmbMonthPeli.SelectedValue + " " +
                         "group by DATENAME(WEEK,horaFechaVenta)";


            ProcesosBD pbd = new ProcesosBD();

            System.Data.DataTable dt = new System.Data.DataTable();
            pbd.Conectar();
            dt = pbd.SqlSelect(sql).Tables[0];

            if (dt.Rows.Count > 0)
            {
                dgvPeliMensual.DataSource = dt.DefaultView;
                chartPeliMonth.Series["Semanas"].ChartType = SeriesChartType.Column;
                chartPeliMonth.Series["Semanas"].Points.Clear();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //ventaMensual.Add(float.Parse(dt.Rows[i][0].ToString()));
                    //mes.Add(dt.Rows[i][1].ToString());

                    float  ventaMensual = float.Parse(dt.Rows[i][0].ToString());
                    string semana       = dt.Rows[i][1].ToString();

                    //MessageBox.Show(ventaMensual + " " + semana);

                    chartPeliMonth.Series["Semanas"].Points.AddXY(semana, ventaMensual);
                }

                chartPeliMonth.Series["Semanas"].ChartArea = "ChartArea1";
            }

            sql = "select SUM(importeTotal)ventaMensual, " +
                  "DATENAME(MONTH,horaFechaVenta)mes  from Ventas  " +
                  "where YEAR(horaFechaVenta) = '" + cmbYearPeli.SelectedValue.ToString() + "' " +
                  "group by DATENAME(MONTH,horaFechaVenta)";

            pbd = new ProcesosBD();
            dt  = new System.Data.DataTable();
            pbd.Conectar();
            dt = pbd.SqlSelect(sql).Tables[0];

            if (dt.Rows.Count > 0)
            {
                dgvPeli.DataSource = dt.DefaultView;
                chartPeliYear.Series["Meses"].ChartType = SeriesChartType.Column;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //ventaMensual.Add(float.Parse(dt.Rows[i][0].ToString()));
                    //mes.Add(dt.Rows[i][1].ToString());

                    float  ventaMensual = float.Parse(dt.Rows[i][0].ToString());
                    string mes          = dt.Rows[i][1].ToString();

                    //MessageBox.Show(ventaMensual + " " + mes);
                    chartPeliYear.Series["Meses"].Points.AddXY(mes, ventaMensual);
                }

                chartPeliYear.Series["Meses"].ChartArea = "ChartArea1";
            }
        }
Beispiel #21
0
        private void btnGuardarCliente_Click(object sender, EventArgs e)
        {
            int  disponible   = 1;
            bool datosValidos = true;

            if (!chkStatusUser.Checked)
            {
                disponible = 0;
            }

            string sql = "";

            //vaciarFormAUsuario();
            datosValidos = validarDatosEntrada();

            if (datosValidos)
            {
                DataTable dt = new DataTable();

                sql = "select curp from usuarios where curp='" + txtCurp.Text + "'" +
                      " or telefonoMovil = '" + txtTelMovil.Text + "'" +
                      " or mail = '" + txtMail.Text + "'";
                pbd.Conectar();
                dt = pbd.SqlSelect(sql).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    MessageBox.Show("Ya existe un registro con esos datos, no se pueden duplicar," +
                                    " verifique curp, claveCliente, telefono movil o correo.");
                }
                else
                {
                    sql = "insert into Usuarios(curp,  Nombres, paterno, materno, claveTipoUsuario" +
                          ", calle, numeroExterior, numeroInterior, cp, colonia, localidad, telefonoCasa" +
                          ", telefonoMovil, inicioContrato, inicioTurno, finTurno, mail, claveSalario" +
                          ", contrasena, disponible)" +
                          "values(" +
                          "'" + txtCurp.Text + "'," +
                          "'" + txtNombreUsuario.Text + "'," +
                          "'" + txtPaterno.Text + "'," +
                          "'" + txtMaterno.Text + "'," +
                          "'" + cmbTipoUsuario.SelectedValue.ToString() + "'," +
                          "'" + txtCalle.Text + "'," +
                          "'" + txtNumExt.Text + "'," +
                          "'" + txtNumInt.Text + "'," +
                          "'" + txtCP.Text + "'," +
                          "'" + txtColonia.Text + "'," +
                          "'" + txtLocalidad.Text + "'," +
                          "'" + txtTelFijo.Text + "'," +
                          "'" + txtTelMovil.Text + "'," +
                          "'" + dtmInicioContrato.Value.ToString("yyyy/MM/dd") + "'," +
                          "'" + dtmInicioJornada.Value.ToString("hh:mm") + "'," +
                          "'" + dtmFinJornada.Value.ToString("hh:mm") + "'," +
                          "'" + txtMail.Text + "'," +
                          "'" + cmbSueldo.SelectedValue + "'," +
                          "'" + txtPass.Text + "'," +
                          disponible +
                          ")";

                    Console.WriteLine(sql);

                    pbd = new ProcesosBD();
                    pbd.Conectar();
                    pbd.SqlUpdate(sql);
                    MessageBox.Show("Se ha insertado el registro correctamente");

                    limpiarControles();
                    CargarTabla();
                }
            }
        }
Beispiel #22
0
        private void FrmFunciones_Load(object sender, EventArgs e)
        {
            CargarTabla();

            ds  = new DataSet();
            pbd = new ProcesosBD();
            pbd.Conectar();

            chkPeliDisp.Checked = true;

            dtmFechaProy.Format       = DateTimePickerFormat.Custom;
            dtmFechaProy.CustomFormat = "yyyy/MM/dd";

            dtmHoraIni.Format       = DateTimePickerFormat.Custom;
            dtmHoraIni.CustomFormat = "HH:mm";

            string sql = "select TRIM(clavenombrepelicula)clavenombrepelicula " +
                         "from Peliculas";

            ds = pbd.SqlSelect(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                cmbPeliculas.DataSource    = ds.Tables[0].DefaultView;
                cmbPeliculas.ValueMember   = "clavenombrepelicula";
                cmbPeliculas.DisplayMember = "clavenombrepelicula";
                defaultPelicula            = ds.Tables[0].Rows[0][0].ToString();
            }

            sql = "select clavesala from Salas";
            ds  = pbd.SqlSelect(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                cmbSalas.DataSource    = ds.Tables[0].DefaultView;
                cmbSalas.ValueMember   = "clavesala";
                cmbSalas.DisplayMember = "clavesala";
            }

            sql = "select descripcion,claveTipoFuncion from TipoFuncion";
            ds  = pbd.SqlSelect(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                cmbTipoFuncion.DataSource    = ds.Tables[0].DefaultView;
                cmbTipoFuncion.ValueMember   = "claveTipoFuncion";
                cmbTipoFuncion.DisplayMember = "descripcion";
            }

            sql = "select idioma,claveIdioma from Idioma";
            ds  = pbd.SqlSelect(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                cmbIdioma.DataSource    = ds.Tables[0].DefaultView;
                cmbIdioma.ValueMember   = "claveIdioma";
                cmbIdioma.DisplayMember = "idioma";
                cmbIdioma.SelectedValue = 1;
            }

            sql = "select subtitulos,claveSubtitulos from Subtitulos";
            ds  = pbd.SqlSelect(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                cmbSubtitulos.DataSource    = ds.Tables[0].DefaultView;
                cmbSubtitulos.ValueMember   = "claveSubtitulos";
                cmbSubtitulos.DisplayMember = "subtitulos";
                cmbSubtitulos.SelectedValue = 6;
            }
        }