示例#1
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;
        }
示例#2
0
        private DataTable buscarPorId()
        {
            DataTable dt = new DataTable();

            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");
            string sql = "select * from Funciones " +
                         " where clavePelicula ='" + txtBuscar.Text.ToString().Trim() + "'" +
                         " or claveFuncion  =" + clave + "";

            Console.WriteLine(sql);

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

            return(dt);
        }
示例#3
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();
        }
示例#4
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));
                }
            }
        }
示例#5
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            DataTable dt  = new DataTable();
            string    sql = "select max(clavesala)maxSala from salas";

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

            if (dt.Rows.Count > 0)
            {
                DialogResult d = MessageBox.Show("Se eliminará el último registro de la sala" +
                                                 "en la base de datos: " + dt.Rows[0][0].ToString() + ". ¿Desea continuar?\n"
                                                 , "Aceptar", MessageBoxButtons.OKCancel);

                int i = 0;
                if (d.Equals(DialogResult.OK))
                {
                    sql = "delete from salas where clavesala=" + dt.Rows[0][0].ToString();

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

                    cmbTipoSalaMod.Refresh();
                    cargarForm();
                    MessageBox.Show("Se ha actualizado el registro correctamente.");
                }
            }
        }
示例#6
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];
        }
示例#7
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];
        }
示例#8
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";
        }
示例#9
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;
        }
示例#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);
        }
        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 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";
            }
        }
示例#13
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);
                        }
                    }
                }
            }
        }
        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");
                }
            }
        }
示例#15
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;
            }
        }
示例#16
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");
                    }
                }
            }
        }
示例#17
0
        private void dgvVentas_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (ready)
            {
                var cmb = new DataGridViewComboBoxCell();
                if (e.ColumnIndex == dgvCols["Horario"])
                {
                    string sql = "";
                    //sql = "select f.claveTipoFuncion,descripcion,i.claveIdioma," +
                    //    "i.idioma,s.claveSala from Funciones f, TipoFuncion t, Idioma i," +
                    //    "Salas s where f.clavePelicula = " +
                    //    "'" + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["NombrePelicula"]].Value.ToString().Trim() + "' " +
                    //    "and hora = '" + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Horario"]].Value.ToString().Trim() + "' " +
                    //    "and f.claveTipoFuncion = t.claveTipoFuncion " +
                    //    "and f.claveSala = s.claveSala and f.claveIdioma = i.claveIdioma";

                    //Console.WriteLine(sql);

                    //pdb.Conectar();
                    //dt = pdb.SqlSelect(sql).Tables[0];
                    //if (dt.Rows.Count > 0)
                    //{
                    //    if (dt.Rows.Count == 1)
                    //    {
                    //        cmb.DataSource = dt.DefaultView;
                    //        cmb.ValueMember = "claveTipoFuncion";
                    //        cmb.DisplayMember = "descripcion";
                    //        dgvVentas.Rows[e.RowIndex].Cells[dgvCols["TipoFuncion"]] = cmb;
                    //        MessageBox.Show(
                    //            dt.Rows[0][0].ToString() + " " +
                    //            dt.Rows[0][2].ToString() + " " +
                    //            dt.Rows[0][4].ToString()
                    //            );
                    //        dgvVentas.Rows[e.RowIndex].Cells[dgvCols["TipoFuncion"]].Value =
                    //            dt.Rows[0][0].ToString();

                    //        cmb = new DataGridViewComboBoxCell();
                    //        cmb.DataSource = dt.DefaultView;
                    //        cmb.ValueMember = "claveIdioma";
                    //        cmb.DisplayMember = "idioma";
                    //        dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Idioma"]] = cmb;
                    //        dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Idioma"]].Value =
                    //            dt.Rows[0][2].ToString();

                    //        cmb = new DataGridViewComboBoxCell();
                    //        cmb.DataSource = dt.DefaultView;
                    //        cmb.ValueMember = "claveSala";
                    //        cmb.DisplayMember = "clavesala";
                    //        dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Sala"]] = cmb;
                    //        dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Sala"]].Value =
                    //            dt.Rows[0][4].ToString();
                    //    }
                    //    else
                    //    {
                    //MessageBox.Show("se ha cambiado el estatus");
                    sql = "select claveTipoFuncion, descripcion from TipoFuncion " +
                          "where claveTipoFuncion " +
                          "in(select claveTipoFuncion from Funciones where clavePelicula = " +
                          "'" + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["NombrePelicula"]].Value.ToString().Trim() + "'" +
                          " and hora =" +
                          "'" + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Horario"]].Value.ToString().Trim() + "')";

                    Console.WriteLine(sql);

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

                    dgvVentas.Rows[e.RowIndex].Cells[dgvCols["TipoFuncion"]] = cmb;
                    //    }
                    //}
                }
                else if (e.ColumnIndex == dgvCols["TipoFuncion"])
                {
                    string sql = "select claveIdioma, idioma from idioma where claveIdioma in(select " +
                                 "claveIdioma from Funciones where clavePelicula =" +
                                 "'" + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["NombrePelicula"]].Value.ToString().Trim() + "' " +
                                 " and hora =" +
                                 "'" + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Horario"]].Value.ToString().Trim() + "'" +
                                 " and claveTipoFuncion = " + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["TipoFuncion"]].Value.ToString().Trim() + ")";

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

                    dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Idioma"]] = cmb;
                }
                else if (e.ColumnIndex == dgvCols["Idioma"])
                {
                    string sql = "select clavesala from Salas where claveSala " +
                                 "in(select claveSala from Funciones where clavePelicula =" +
                                 "'" + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["NombrePelicula"]].Value.ToString().Trim() + "' " +
                                 " and hora =" +
                                 "'" + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Horario"]].Value.ToString().Trim() + "'" +
                                 " and claveTipoFuncion = "
                                 + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["TipoFuncion"]].Value.ToString().Trim() + "" +
                                 " and claveIdioma = "
                                 + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Idioma"]].Value.ToString().Trim() + "" +
                                 ")";

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

                    dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Sala"]] = cmb;
                }
                else if (e.ColumnIndex == dgvCols["Sala"])
                {
                    string sql = "select clavefuncion from Funciones where clavePelicula = '" +
                                 dgvVentas.Rows[e.RowIndex].Cells[dgvCols["NombrePelicula"]].Value.ToString().Trim() +
                                 "' and hora = '"
                                 + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Horario"]].Value.ToString().Trim() + "'" +
                                 " and claveTipoFuncion = "
                                 + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["TipoFuncion"]].Value.ToString().Trim() + "" +
                                 " and claveIdioma = "
                                 + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Idioma"]].Value.ToString().Trim() + "" +
                                 " and claveSala = "
                                 + dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Sala"]].Value.ToString().Trim();

                    Console.WriteLine(sql);
                    pdb.Conectar();
                    claveFuncion = int.Parse(pdb.SqlSelect(sql).Tables[0].Rows[0][0].ToString());

                    string[] cantidadAsientos = { "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",  "10",
                                                  "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" };

                    cmb.Items.AddRange(cantidadAsientos);
                    dgvVentas.Rows[e.RowIndex].Cells[dgvCols["CantidadAsientos"]] = cmb;
                }
                else if (e.ColumnIndex == dgvCols["IdCliente"])
                {
                    if (dgvVentas.Rows[e.RowIndex].Cells[dgvCols["AsientosSeleccionados"]].Value != null)
                    {
                        if (precioUnitario > 0)
                        {
                            string nombre       = "";
                            int    claveCliente = 0;


                            if (dgvVentas.Rows[e.RowIndex].Cells[dgvCols["IdCliente"]].Value != null &&
                                !dgvVentas.Rows[e.RowIndex].Cells[dgvCols["IdCliente"]].Value.Equals("")
                                )
                            {
                                claveCli = dgvVentas.Rows[e.RowIndex]
                                           .Cells[dgvCols["IdCliente"]].Value.ToString().Trim();
                                claveCliente = int.Parse(claveCli);
                            }

                            DataTable dt = new DataTable();

                            pdb.Conectar();

                            string sql = "select puntos-puntosUsados puntos, " +
                                         "Nombres + ' ' + paterno + ' ' + materno nombre from Clientes where " +
                                         "claveCliente = " + claveCliente;
                            dt = pdb.SqlSelect(sql).Tables[0];
                            if (pdb.SqlSelect(sql).Tables[0].Rows.Count > 0)
                            {
                                puntos = int.Parse(dt.Rows[0][0].ToString());
                                nombre = dt.Rows[0][1].ToString();
                                //MessageBox.Show(puntos + " " + precioUnitario + " " + nombre);
                            }
                            else
                            {
                                puntos = 0;
                                dgvVentas.Rows[e.RowIndex].Cells[dgvCols["IdCliente"]].Value =
                                    "";
                            }

                            descuento = puntos * precioUnitario;

                            dgvVentas.Rows[e.RowIndex].Cells[dgvCols["Descuento"]].Value =
                                "$" + descuento + ".00";

                            dgvVentas.Rows[e.RowIndex].Cells[dgvCols["NombreCliente"]].Value =
                                nombre;
                        }
                        else
                        {
                            MessageBox.Show("Debe seleccionar una funcion para aplicar el descuento");
                            dgvVentas.Rows[e.RowIndex].Cells[dgvCols["IdCliente"]].Value = "";
                            claveCli = "NULL";
                        }
                    }
                }
            }
        }
示例#18
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);
                }
            }
        }
示例#19
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();
                }
            }
        }