Exemplo n.º 1
0
        private void obtiene_Imagen(int id)
        {
            try
            {
                SqlConnection Conexion = basedatos.conexionsql();
                Conexion.Open();
                string sql = "Select Imagen from Cliente Where Cliente_Id =   " + id;

                SqlCommand    command = new SqlCommand(sql, Conexion);
                SqlDataReader lector  = command.ExecuteReader();

                if (lector.Read())
                {
                    byte[]       arreglo = (byte[])lector["Imagen"];
                    MemoryStream m       = new MemoryStream(arreglo);
                    Image        imagen  = Image.FromStream(m);
                    pbFotoUser.Image = imagen;
                    lector.Close();
                    Conexion.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void autoriza()
        {
            try
            {
                //Creando conexion
                conexion = basedatos.conexionsql();
                //Abriendo conexion
                conexion.Open();
                SqlCommand comando = new SqlCommand("select usuario_login,usuario_password, usuario_id, usuario_nombre from usuario where usuario_login = '******' ", conexion);

                //ejecuta una instruccion de sql devolviendo el numero de las filas afectadas
                comando.ExecuteNonQuery();
                DataSet        ds = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter(comando);

                //Llenando el dataAdapter
                da.Fill(ds, "usuario");
                //utilizado para representar una fila de la tabla q necesitas en este caso usuario
                DataRow DR;
                DR = ds.Tables["usuario"].Rows[0];

                //evaluando que la contraseña y usuario sean correctos
                if ((txtuser.Text == DR["usuario_login"].ToString()))
                {
                    Program.UsuarioId = Convert.ToInt32(DR["usuario_id"].ToString());
                }
            }
            catch
            {
                MessageBox.Show("Acceso No valido");
            }
        }
Exemplo n.º 3
0
 private void btnbuscar_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtventa_id.Text != "")
         {
             BD            basedatos = new BD();
             SqlConnection conexion;
             //Creando conexion
             conexion = basedatos.conexionsql();
             //Abriendo conexion
             conexion.Open();
             SqlCommand     comando = new SqlCommand("Select Venta_Id,Boleta_Id,Categoria_Nombre,Cliente_Nombre,Kilataje,Descripcion,Peso,Peso_Piedra,Fecha,Total from venta Where venta_id=" + txtventa_id.Text, conexion);
             SqlDataAdapter da      = new SqlDataAdapter(comando);
             DataTable      dt      = new DataTable();
             using (da)
             {
                 da.Fill(dt);
             }
             gvBoleta.DataSource = dt;
             txtventa_id.Text    = "";
         }
         else
         {
             MessageBox.Show("Ingrese el número de Venta");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Ingrese un numero de Venta valido");
         txtventa_id.Text = "";
     }
 }
Exemplo n.º 4
0
        private void btnguardar_Click(object sender, EventArgs e)
        {
            BD            basedatos = new BD();
            SqlConnection conexion;

            //Creando conexion
            conexion = basedatos.conexionsql();
            //Abriendo conexion
            conexion.Open();

            string   dtme  = Convert.ToString(DateTime.Now.ToShortDateString());
            DateTime fecha = Convert.ToDateTime(dtme);

            DateTime fecha_vencimiento = Convert.ToDateTime(dtme);

            fecha_vencimiento = fecha_vencimiento.AddDays(28);

            DateTime fecha_comercializacion = fecha_vencimiento;

            fecha_comercializacion = fecha_vencimiento.AddDays(3);

            string actualizar = "update Boleta_Encabezado set Estado='Vigente',Boleta_Fecha_Vencimiento= '" + fecha_vencimiento.ToString("yyyy-MM-dd hh:mm") + "',Boleta_Fecha_Comercializacion= '" + fecha_comercializacion.ToString("yyyy-MM-dd hh:mm") + "' where Boleta_id = " + txtboletaid.Text;

            if (bdatos.executecommand(actualizar))
            {
                MessageBox.Show("Boleta Actualizada correctamente");
            }
            else
            {
                MessageBox.Show("Error al actualizar la boleta");
            }
            conexion.Close();
        }
Exemplo n.º 5
0
        private void Carga_parametros()
        {
            try
            {
                BD            basedatos = new BD();
                SqlConnection conexion;
                //Creando conexion
                conexion = basedatos.conexionsql();
                //Abriendo conexion
                conexion.Open();
                SqlCommand    comando = new SqlCommand("Select Tasa_Interes_Anual,Costo_Anual_Total,Oro,Electronicos,Almacenaje,Comercializacion,Desempenio_Extemporaneo,Reposicion_contrato from intereses", conexion);
                SqlDataReader dr      = comando.ExecuteReader();

                if (dr.Read())
                {
                    txttasainteresanual.Text = dr[0].ToString();
                    txtcostoanualtotal.Text  = dr[1].ToString();
                    txtoro.Text                   = dr[2].ToString();
                    txtelectronicos.Text          = dr[3].ToString();
                    txtalmacenaje.Text            = dr[4].ToString();
                    txtcomercializacion.Text      = dr[5].ToString();
                    txtdesempeñoextemporaneo.Text = dr[6].ToString();
                    txtreposicioncontrato.Text    = dr[7].ToString();
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Error al cargar los datos", "Error:", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
 private void btnguardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtnombre.Text == "" || txtdireccion.Text == "" || txttelefono.Text == "")
         {
             MessageBox.Show("Le falta escribir algunos datos.", "Error:", MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
         else
         {
             DateTime      fecha    = Convert.ToDateTime(DateTime.Now.ToLocalTime());
             SqlConnection conexion = basedatos.conexionsql();
             conexion.Open();
             string     comado    = "insert into Empleado (Empleado_Nombre,Empleado_Direccion,Emp_Fecha_Actualizacion,Empleado_Telefono,Rol_Id)values(@Empleado_Nombre,@Empleado_Direccion,@Emp_Fecha_Actualizacion,@Empleado_Telefono,@Rol_Id);";
             SqlCommand micomando = new SqlCommand(comado, conexion);
             micomando.Parameters.Add("@Empleado_Nombre", SqlDbType.VarChar, 200).Value    = txtnombre.Text;
             micomando.Parameters.Add("@Empleado_Direccion", SqlDbType.VarChar, 300).Value = txtdireccion.Text;
             micomando.Parameters.Add("@Emp_Fecha_Actualizacion", DateTime.Today).Value    = fecha;
             micomando.Parameters.Add("@Empleado_Telefono", SqlDbType.VarChar, 15).Value   = txtdireccion.Text;
             micomando.Parameters.Add("@Rol_Id", SqlDbType.VarChar, 100).Value             = 1;
             micomando.ExecuteNonQuery();
             conexion.Close();
             MessageBox.Show("Registro insertado correctamente");
             limpiar();
         }
     } //try
     catch (SqlException excep)
     {
         MessageBox.Show(excep.Message);
     }       //catch
 }
Exemplo n.º 7
0
        private void Reimpresionrpt_Load(object sender, EventArgs e)
        {
            conexion = basedatos.conexionsql();
            //Abriendo conexion
            conexion.Open();
            SqlCommand comando = new SqlCommand("select Categoria_Id From Boleta_encabezado where Boleta_id= '" + boleta_id + "' ", conexion);

            SqlDataReader dr = comando.ExecuteReader();
            int           resultado;

            if (dr.Read())
            {
                resultado = Convert.ToInt32(dr[0].ToString());

                if (resultado == 1)
                {
                    lanza_impresion_oro();
                }
                else
                {
                    lanza_impresion_electronicos();
                }
            }

            this.reportViewer1.RefreshReport();
        }
Exemplo n.º 8
0
 private void btnbuscar_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtboleta_id.Text != "")
         {
             BD            basedatos = new BD();
             SqlConnection conexion;
             //Creando conexion
             conexion = basedatos.conexionsql();
             //Abriendo conexion
             //conexion.Open();
             SqlCommand     comando = new SqlCommand("select D.Cliente_Nombre, D.Categoria_Nombre, D.Subcategoria_Nombre, D.Descripcion, D.Estado, D.Kilateje, D.Peso, D.Peso_Piedra, D.Prestamo, D.Avaluo, D.Boleta_Fecha, D.Boleta_Fecha_Vencimiento from Boleta_Detalle D,	 Boleta_Encabezado E where E.Boleta_Id=D.Boleta_Id And   E.Boleta_Id="+ txtboleta_id.Text + "  And   E.Estado='Vencido'  ", conexion);
             SqlDataAdapter da      = new SqlDataAdapter(comando);
             DataTable      dt      = new DataTable();
             using (da)
             {
                 da.Fill(dt);
             }
             gvBoleta.DataSource   = dt;
             txtboleta_id.ReadOnly = true;
         }
         else
         {
             MessageBox.Show("Ingrese el número de boleta");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Ingrese un numero de boleta valido");
         txtboleta_id.Text = "";
     }
 }
Exemplo n.º 9
0
 private void Guardarefrendo_total()
 {
     try
     {
         BD            basedatos = new BD();
         SqlConnection conexion;
         //Creando conexion
         conexion = basedatos.conexionsql();
         //Abriendo conexion
         conexion.Open();
         SqlCommand cmd = new SqlCommand("Insert Into Refrendo_Total(Boleta_Id, Cliente_Nombre, Prestamo, Interes, Almacenaje, Iva, Total, Fecha) Values(@Prm1,@Prm2,@Prm3,@Prm4,@Prm5,@Prm6,@Prm7,@Prm8)");
         cmd.Connection = conexion;
         cmd.Parameters.Add(new SqlParameter("@Prm1", txtboleta_id.Text));
         cmd.Parameters.Add(new SqlParameter("@Prm2", txtcliente.Text));
         cmd.Parameters.Add(new SqlParameter("@Prm3", txtprestamo.Text));
         cmd.Parameters.Add(new SqlParameter("@Prm4", txtalmacenaje.Text));
         cmd.Parameters.Add(new SqlParameter("@Prm5", txtinteres.Text));
         cmd.Parameters.Add(new SqlParameter("@Prm6", txtiva.Text));
         cmd.Parameters.Add(new SqlParameter("@Prm7", txttotal.Text));
         cmd.Parameters.Add(new SqlParameter("@Prm8", DateTime.Now.ToString("yyyy/MM/dd")));
         cmd.ExecuteNonQuery();
     }
     catch (Exception)
     {
         MessageBox.Show("Error no existen datos");
     }
 }
Exemplo n.º 10
0
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     if (txtId.Text != "")
     {
         BD            basedatos = new BD();
         SqlConnection conexion;
         //Creando conexion
         conexion = basedatos.conexionsql();
         //Abriendo conexion
         conexion.Open();
         string query = string.Empty;
         if (cmbMovimiento.SelectedItem.ToString() == "Cajero")
         {
             query = "select Empleado_Nombre from Empleado where Empleado_Id=" + txtId.Text;
         }
         else
         {
             query = "select Suc_Regimen_Nombre from Sucursal where Suc_Id=" + txtId.Text;
         }
         SqlCommand comando = new SqlCommand(query, conexion);
         txtNombre.Text = comando.ExecuteScalar().ToString();
         conexion.Close();
         btnReporte.Enabled = true;
         btnReporte.Enabled = true;
     }
     else
     {
         MessageBox.Show("Ingrese Id de Cajero/Sucursal");
     }
 }
Exemplo n.º 11
0
 private void btnbuscar_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtrefrendo.Text != "")
         {
             BD            basedatos = new BD();
             SqlConnection conexion;
             //Creando conexion
             conexion = basedatos.conexionsql();
             //Abriendo conexion
             conexion.Open();
             SqlCommand comando = new SqlCommand("Select Refrendo_id,Boleta_Id,Cliente_Nombre,Prestamo,Interes,Almacenaje,Iva,Total,Fecha from Refrendo_Total " +
                                                 " Where Refrendo_id=" + txtrefrendo.Text, conexion);
             SqlDataAdapter da = new SqlDataAdapter(comando);
             DataTable      dt = new DataTable();
             using (da)
             {
                 da.Fill(dt);
             }
             gvBoleta.DataSource = dt;
             // txtrefrendo.ReadOnly = true;
             txtrefrendo.Text = "";
         }
         else
         {
             MessageBox.Show("Ingrese el número de refrendo");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Ingrese un numero de refendo valido");
         txtrefrendo.Text = "";
     }
 }
Exemplo n.º 12
0
        private void numero_refrendo()
        {
            try
            {
                string        contador;
                SqlConnection Conexion = basedatos.conexionsql();
                Conexion.Open();
                string sql = "select max(refrendo) as refrendo from refrendo";

                SqlCommand    command = new SqlCommand(sql, Conexion);
                SqlDataReader reader  = command.ExecuteReader();

                if (reader.Read())
                {
                    contador         = Convert.ToString(reader["refrendo"]);
                    lblrefrendo.Text = Convert.ToString(Convert.ToInt32(contador) + 1);
                }
                Conexion.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 13
0
        private void Subcategorias_Load(object sender, EventArgs e)
        {
            SqlConnection Conexion = basedatos.conexionsql();

            dgvsubcategorias.DataSource = bdatos.SelectDataTable("Select B.Categoria_nombre,A.Subcategoria_Id,a.Subcategoria_Nombre,a.Categoria_Fec_Actualizacion " +
                                                                 " From sub_categoria A, " +
                                                                 " Categoria B " +
                                                                 " Where A.Categoria_id=B.Categoria_id");

            string         Ccategorias = "Select Categoria_id,categoria_nombre from Categoria";
            DataSet        ds_catego   = new DataSet();
            SqlDataAdapter Catego      = new SqlDataAdapter(Ccategorias, Conexion);

            Catego.Fill(ds_catego, "Categorias");
            cmbcategoria.DataSource    = ds_catego.Tables[0].DefaultView;
            cmbcategoria.ValueMember   = "Categoria_id";
            cmbcategoria.DisplayMember = "Categoria_Nombre";
        }
Exemplo n.º 14
0
        private void btngenerar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtboleta_id.Text != "" && txttotal.Text != "")
                {
                    BD            basedatos = new BD();
                    SqlConnection conexion;
                    //Creando conexion
                    conexion = basedatos.conexionsql();
                    //Abriendo conexion
                    conexion.Open();
                    SqlCommand comando = new SqlCommand("Insert Into Desempenio(IdBoleta, Monto, Fecha,Usuario_Id) Values(@IdBoleta, @Monto, @Fecha, @Usuario)", conexion);
                    comando.Parameters.Add(new SqlParameter("@IdBoleta", txtboleta_id.Text));
                    comando.Parameters.Add(new SqlParameter("@Monto", txttotal.Text));
                    comando.Parameters.Add(new SqlParameter("@Fecha", DateTime.Now));
                    comando.Parameters.Add(new SqlParameter("@Usuario", Program.UsuarioId));
                    int           res           = comando.ExecuteNonQuery();
                    Desempeniorpt rptDesempenio = new Desempeniorpt();
                    rptDesempenio.IdBoleta = Convert.ToInt32(txtboleta_id.Text);
                    rptDesempenio.linea    = cbxsemana.SelectedItem.ToString();
                    rptDesempenio.ShowDialog(this);
                    rptDesempenio.Dispose();
                    conexion.Close();



                    string actualizar = "update Boleta_Encabezado set Estado = 'Desempeñado'  where Boleta_id = " + txtboleta_id.Text;

                    if (bdatos.executecommand(actualizar))
                    {
                        Gurda_PDF datos = new Gurda_PDF();
                        datos.Boleta     = txtboleta_id.Text;
                        datos.Cliente    = txtcliente.Text;
                        datos.Nombre     = lblnombre.Text;
                        datos.Movimiento = lbldesempenio.Text;
                        datos.ShowDialog(this);
                        datos.Dispose();
                        MessageBox.Show("Boleta dada de baja correctamente");
                    }
                    else
                    {
                        MessageBox.Show("Error al Desempeñar");
                    }
                    this.limpiar();
                }
                else
                {
                    MessageBox.Show("Ingrese un numero de boleta valido");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error al generar el Desempeño");
            }
        }
Exemplo n.º 15
0
        private void btnDesgloseBoleta_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtboleta_id.Text != "")
                {
                    BD            basedatos = new BD();
                    SqlConnection conexion;
                    //Creando conexion
                    conexion = basedatos.conexionsql();
                    //Abriendo conexion
                    using (conexion)
                    {
                        conexion.Open();
                        SqlCommand comando = new SqlCommand("Insert Into Desglose_Boleta(Boleta_Id,Categoria_Id,Categoria_Nombre,Kilateje,SubCategoria_Nombre,Estado,Descripcion,Peso,Peso_Piedra,Prestamo,Avaluo,Estatus) select Boleta_Id,Categoria_Id,Categoria_Nombre,Kilateje,Subcategoria_Nombre,Estado,Descripcion,Peso,Peso_Piedra,Prestamo,Avaluo,'Activo' from Boleta_Detalle where Boleta_Id=" + txtboleta_id.Text, conexion);
                        int        res     = comando.ExecuteNonQuery();
                        conexion.Close();
                        if (res > 0)
                        {
                            rptDesgloseBoleta rpt = new rptDesgloseBoleta();
                            rpt.IdBoleta = Convert.ToInt32(txtboleta_id.Text);
                            rpt.ShowDialog(this);
                            rpt.Dispose();

                            string actualizar = "update Boleta_Encabezado set Estado = 'Desglosada'  where Boleta_id = " + txtboleta_id.Text;

                            if (bdatos.executecommand(actualizar))
                            {
                                MessageBox.Show("Boleta Desglosada correctamente");
                                txtboleta_id.ReadOnly = false;
                            }
                            else
                            {
                                MessageBox.Show("Error al Desglosar");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error al desglosar la boleta. Vuelva a Intentarlo");
                        }
                        gvBoleta.DataSource = null;
                        txtboleta_id.Text   = "";
                    }
                }
                else
                {
                    MessageBox.Show("Ingrese el número de boleta");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("");
            }
        }
Exemplo n.º 16
0
        private void btnbuscar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtcodigo.Text != "")
                {
                    BD            basedatos = new BD();
                    string        prestamo  = "";
                    SqlConnection conexion;
                    //Creando conexion
                    conexion = basedatos.conexionsql();
                    //Abriendo conexion
                    conexion.Open();
                    SqlCommand    comando = new SqlCommand(" select Boleta_id,Categoria_Nombre,kilateje,Peso,peso_piedra,Descripcion,prestamo  From  Desglose_Boleta Where Codigo_id=" + txtcodigo.Text + " And Estatus='Activo' ", conexion);
                    SqlDataReader dr      = comando.ExecuteReader();

                    if (dr.Read())
                    {
                        txtboleta.Text      = dr[0].ToString();
                        txtcategoria.Text   = dr[1].ToString();
                        txtkilataje.Text    = dr[2].ToString();
                        txtpeso.Text        = dr[3].ToString();
                        txtpiedra.Text      = dr[4].ToString();
                        txtdescripcion.Text = dr[5].ToString();
                        prestamo            = dr[6].ToString();

                        string comercializacion = " Select importe from Interes where Interes_Nombre='Comercializacion'";

                        string importecomercialiacion = Convert.ToString(bdatos.selectstring(comercializacion));
                        double comer = 0;
                        comer = Convert.ToDouble(importecomercialiacion);
                        comer = comer / 100;
                        double importe = Convert.ToDouble(prestamo);
                        double total   = comer * importe;
                        txttotal.Text = Convert.ToString(total + importe);
                        // txtcodigo.ReadOnly = true;
                    }
                    else
                    {
                        MessageBox.Show("No existen el codigo"); this.limpiar();
                    }
                }
                else
                {
                    MessageBox.Show("Ingrese el código de la prenda");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Verifique la informacion ingresada ");
                txtcodigo.Text = "";
            }
        }
Exemplo n.º 17
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            if (txtId.Text != "")
            {
                BD            basedatos = new BD();
                SqlConnection conexion;
                //Creando conexion
                conexion = basedatos.conexionsql();
                //Abriendo conexion
                conexion.Open();
                string queryRefrendo = string.Empty;
                string queryVentas   = string.Empty;
                string queryEmpenio  = string.Empty;
                if (cmbMovimiento.SelectedItem.ToString() == "Cajero")
                {
                    queryRefrendo = "select SUM(Total) Total from Refrendo Where Usuario_Id=@Id and CAST(CONVERT(nvarchar(10), FechaCreacion, 101) as date) between CAST(@FecIni as date) and CAST(@FecFin+1 as date)";
                    queryVentas   = "select SUM(Total) Total from Venta Where Usuario_Id=@Id and CAST(CONVERT(nvarchar(10), Fecha, 101) as date) between CAST(@FecIni as date) and CAST(@FecFin+1 as date)";
                    queryEmpenio  = "select SUM(Avaluo) Total from Boleta_Encabezado Where Usuario_Id=@Id and CAST(CONVERT(nvarchar(10), Boleta_Fecha, 101) as date) between CAST(@FecIni as date) and CAST(@FecFin+1 as date)";
                }
                else
                {
                    queryRefrendo = "select SUM(Total) Total from Refrendo A inner join Sucursal B on A.Usuario_Id>0 Where B.Suc_Id=@Id and CAST(CONVERT(nvarchar(10), FechaCreacion, 101) as date) between CAST(@FecIni+1 as date) and CAST(@FecFin as date)";
                    queryVentas   = "select SUM(Total) Total from Venta A inner join Sucursal B on A.Usuario_Id>0 Where B.Suc_Id=@Id and CAST(CONVERT(nvarchar(10), Fecha, 101) as date) between CAST(@FecIni as date) and CAST(@FecFin+1 as date)";
                    queryEmpenio  = "select SUM(Avaluo) Total from Boleta_Encabezado A inner join Sucursal B on A.Usuario_Id>0 Where B.Suc_Id=@Id and CAST(CONVERT(nvarchar(10), Boleta_Fecha, 101) as date) between CAST(@FecIni as date) and CAST(@FecFin+1 as date)";
                }
                SqlCommand comando = new SqlCommand(queryRefrendo, conexion);
                comando.Parameters.Add(new SqlParameter("Id", txtId.Text));
                comando.Parameters.Add(new SqlParameter("FecIni", dtpFecInicio.Value));
                comando.Parameters.Add(new SqlParameter("FecFin", dtpFecFin.Value));
                Double Total = 0;
                Double.TryParse(comando.ExecuteScalar().ToString(), out Total);
                DataTable dt = new DataTable("Movimientos");
                dt.Columns.Add("Movimiento", typeof(String));
                dt.Columns.Add("Total", typeof(Double));

                dt.Rows.Add(new object[] { "Refrendo", Total });
                comando.CommandText = queryVentas;
                Double.TryParse(comando.ExecuteScalar().ToString(), out Total);

                dt.Rows.Add(new object[] { "Ventas", Total });
                comando.CommandText = queryEmpenio;
                Double.TryParse(comando.ExecuteScalar().ToString(), out Total);

                dt.Rows.Add(new object[] { "Empeños", Total });
                dgvMovimientos.DataSource = dt;
                conexion.Close();
            }
            else
            {
                MessageBox.Show("Ingrese Id de Cajero/Sucursal");
            }
        }
Exemplo n.º 18
0
 private void btnconsultar_Click(object sender, EventArgs e)
 {
     try
     {
         BD            basedatos = new BD();
         SqlConnection conexion;
         //Creando conexion
         conexion = basedatos.conexionsql();
         //Abriendo conexion
         conexion.Open();
         string queryIngreso = string.Empty;
         string queryEgreso  = string.Empty;
         if (cmbMovimiento.SelectedItem.ToString() == "Ingresos")
         {
             queryIngreso = "select SUM(Importe)as Total from Ingresos Where  CAST(CONVERT(nvarchar(10), Fecha_Actualizacion, 101) as date) between CAST(@FecIni as date) and CAST(@FecFin+1 as date) ";
             SqlCommand comando = new SqlCommand(queryIngreso, conexion);
             comando.Parameters.Add(new SqlParameter("FecIni", dtpFecInicio.Value));
             comando.Parameters.Add(new SqlParameter("FecFin", dtpFecFin.Value));
             Double Total = 0;
             Double.TryParse(comando.ExecuteScalar().ToString(), out Total);
             DataTable dt = new DataTable("Movimientos");
             dt.Columns.Add("Movimiento", typeof(String));
             dt.Columns.Add("Total", typeof(Double));
             dt.Rows.Add(new object[] { "Ingresos", Total });
             dgvMovimientos.DataSource = dt;
             conexion.Close();
         }
         else
         {
             queryEgreso = "select SUM(Importe) Total from Egresos Where  CAST(CONVERT(nvarchar(10), Fecha_Actualizacion, 101) as date) between CAST(@FecIni as date) and CAST(@FecFin+1 as date) ";
             SqlCommand comando = new SqlCommand(queryEgreso, conexion);
             comando.Parameters.Add(new SqlParameter("FecIni", dtpFecInicio.Value));
             comando.Parameters.Add(new SqlParameter("FecFin", dtpFecFin.Value));
             Double Total = 0;
             Double.TryParse(comando.ExecuteScalar().ToString(), out Total);
             DataTable dt = new DataTable("Movimientos");
             dt.Columns.Add("Movimiento", typeof(String));
             dt.Columns.Add("Total", typeof(Double));
             dt.Rows.Add(new object[] { "Egresos", Total });
             dgvMovimientos.DataSource = dt;
             conexion.Close();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Error al consultar");
     }
 }
Exemplo n.º 19
0
        private void GuardarFicheroBDD(string sRuta, string sFichero)
        {
            //Creamos un nuevo objeto de tipo FileStream para leer el fichero
            //Word en modo binario
            System.IO.FileStream fs = new FileStream(sRuta,
                                                     System.IO.FileMode.Open);
            //Creamos un array de bytes para almacenar los datos leídos por fs.
            Byte[] data = new byte[fs.Length];
            //Y guardamos los datos en el array data
            fs.Read(data, 0, Convert.ToInt32(fs.Length));
            //Abrimos una conexion. En este caso los datos de la cadena de
            //conexion a la base de datos se recuperan de una sección del
            //fichero web.config mediante ConfigurationSettings
            BD            basedatos = new BD();
            SqlConnection conexion;

            //Creando conexion
            conexion = basedatos.conexionsql();
            //Abriendo conexion
            conexion.Open();
            //Creamos un comando de tipo StoredProcedure para invocar a
            //UploadDocs
            SqlCommand cmd = new SqlCommand("UploadDoc", conexion);

            cmd.CommandType = CommandType.StoredProcedure;
            //Añadimos los parametros esperados y los valores de los mismos
            //cmd.Parameters.Add("@doc", data); //los datos del fichero Word
            cmd.Parameters.Add(new SqlParameter("@doc", SqlDbType.VarBinary, data.Length, ParameterDirection.Input, false, 0, 0, "Data", DataRowVersion.Current, (SqlBinary)data));
            cmd.Parameters.Add("@nombre", nombre);         //y su nombre
            cmd.Parameters.Add("@Mov", mov);               //y su nombre
            cmd.Parameters.Add("@Boleta", boleta);         //y su nombre
            cmd.Parameters.Add("nombre_cliente", cliente); //y su nombre
            //Ejecutamos el procedimiento almacenado, que inserta un nuevo
            //registro en DocsBinarios con los datos que queremos introducir
            cmd.ExecuteNonQuery();
            //Cerramos la conexión y el fichero
            conexion.Close();
            fs.Close();
        }
Exemplo n.º 20
0
 private void btnbuscar_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtdesempenio.Text != "")
         {
             BD            basedatos = new BD();
             SqlConnection conexion;
             //Creando conexion
             conexion = basedatos.conexionsql();
             //Abriendo conexion
             conexion.Open();
             SqlCommand comando = new SqlCommand("Select B.Cliente_Nombre,C.IdDesempenio,C.IdBoleta,C.Monto,C.Fecha from Boleta_Encabezado A With (Nolock), " +
                                                 "                 Cliente B With (Nolock)," +
                                                 "                Desempenio C With (Nolock)" +
                                                 "   Where	A.Cliente_Id	= B.Cliente_Id"+
                                                 "   And		A.Boleta_Id		= C.IdBoleta"+
                                                 "   And		C.IdDesempenio	="+ txtdesempenio.Text, conexion);
             SqlDataAdapter da = new SqlDataAdapter(comando);
             DataTable      dt = new DataTable();
             using (da)
             {
                 da.Fill(dt);
             }
             gvBoleta.DataSource = dt;
             txtdesempenio.Text  = "";
         }
         else
         {
             MessageBox.Show("Ingrese el número de Desempeño");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Ingrese un numero de Desempeño valido");
         txtdesempenio.Text = "";
     }
 }
Exemplo n.º 21
0
        private void btnbuscar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtboleta_id.Text != "")
                {
                    BD            basedatos = new BD();
                    SqlConnection conexion;
                    //Creando conexion

                    conexion = basedatos.conexionsql();
                    //Abriendo conexion
                    //conexion.Open();
                    SqlCommand comando = new SqlCommand("SELECT  Codigo_Id, Boleta_Id, Categoria_Id, Categoria_Nombre, Kilateje, SubCategoria_Nombre, Estado, Descripcion, Peso, Peso_Piedra, Prestamo, Avaluo, Estatus " +
                                                        " FROM            Desglose_Boleta " +
                                                        "WHERE        Boleta_Id =" + txtboleta_id.Text, conexion);
                    SqlDataAdapter da = new SqlDataAdapter(comando);
                    DataTable      dt = new DataTable();
                    using (da)
                    {
                        da.Fill(dt);
                    }
                    gvBoleta.DataSource   = dt;
                    txtboleta_id.ReadOnly = true;
                    txtboleta_id.Text     = "";
                }
                else
                {
                    MessageBox.Show("Ingrese el número de boleta");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ingrese un numero de boleta valido");
                txtboleta_id.Text = "";
            }
        }
Exemplo n.º 22
0
 private void btnbuscar_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtempenio.Text != "")
         {
             BD            basedatos = new BD();
             SqlConnection conexion;
             //Creando conexion
             conexion = basedatos.conexionsql();
             //Abriendo conexion
             //conexion.Open();
             SqlCommand comando = new SqlCommand("Select Boleta_Id,B.Cliente_Nombre,Prestamo,Avaluo,Estado,Boleta_Fecha,Boleta_Fecha_Vencimiento,Boleta_Fecha_Comercializacion from	Boleta_Encabezado A With (Nolock), "+
                                                 "                       Cliente B With (Nolock) " +
                                                 "       Where A.Cliente_Id	= B.Cliente_Id "+
                                                 "       And Boleta_Id		= "+ txtempenio.Text, conexion);
             SqlDataAdapter da = new SqlDataAdapter(comando);
             DataTable      dt = new DataTable();
             using (da)
             {
                 da.Fill(dt);
             }
             gvBoleta.DataSource = dt;
             // txtrefrendo.ReadOnly = true;
             txtempenio.Text = "";
         }
         else
         {
             MessageBox.Show("Ingrese el número de refrendo");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Ingrese un numero de refendo valido");
         txtempenio.Text = "";
     }
 }
Exemplo n.º 23
0
        private void btnbuscar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtboleta_id.Text != "")
                {
                    BD            basedatos = new BD();
                    SqlConnection conexion;
                    //Creando conexion
                    conexion = basedatos.conexionsql();
                    //Abriendo conexion
                    conexion.Open();
                    SqlCommand    comando = new SqlCommand("Select A.Cliente_id,A.cliente_nombre,b.Prestamo from Cliente A,Boleta_encabezado B Where A.Cliente_id=B.Cliente_id And B.Estado='Vigente' And B.Boleta_id=" + txtboleta_id.Text + "", conexion);
                    SqlDataReader dr      = comando.ExecuteReader();

                    if (dr.Read())
                    {
                        txtcliente_id.Text = dr[0].ToString();
                        txtcliente.Text    = dr[1].ToString();
                        txtprestamo.Text   = dr[2].ToString();
                    }
                    else
                    {
                        MessageBox.Show("La boleta no existe"); txtboleta_id.ReadOnly = false;
                    }
                }
                else
                {
                    MessageBox.Show("Ingrese el número de boleta");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Verifica la informacion introducida");
                this.limpiar();
            }
        }
Exemplo n.º 24
0
        private void numero_desempenio()
        {
            try
            {
                string        contador;
                SqlConnection Conexion = basedatos.conexionsql();
                Conexion.Open();
                string sql = "Select isnull(Max(IdDesempenio),0) as IdDesempenio  from Desempenio";

                SqlCommand    command = new SqlCommand(sql, Conexion);
                SqlDataReader reader  = command.ExecuteReader();

                if (reader.Read())
                {
                    contador           = Convert.ToString(reader["IdDesempenio"]);
                    lbldesempenio.Text = Convert.ToString(Convert.ToInt32(contador) + 1);
                }
                Conexion.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 25
0
        private void btnbuscar_Click(object sender, EventArgs e)
        {
            try
            {
                double prestamo   = 0;
                double almacenaje = 0;
                double iva        = 0;
                double interes    = 0;
                string cliente    = "";
                string Fecha      = "";
                int    Ndias      = 0;
                string dias       = "";
                double Nsemana    = 0;
                //public  int Rsemana         = 0;

                if (txtboleta_id.Text != "")
                {
                    BD            basedatos = new BD();
                    SqlConnection conexion;
                    //Creando conexion
                    conexion = basedatos.conexionsql();
                    //Abriendo conexion
                    conexion.Open();
                    SqlCommand    comando = new SqlCommand("Select top 1 C.Cliente_nombre,A.Importe as Prestamo,A.Interes,A.Almacenaje,A.Iva,Convert(varchar,B.Boleta_Fecha,112) as fecha From Pagos  A,  Boleta_Encabezado B, Cliente C where A.idboleta = B.Boleta_id and  B.Estado<>'Desempeñado'  And B.Cliente_id = C.Cliente_id And A.IdBoleta=" + txtboleta_id.Text + " Order by A.linea asc", conexion);
                    SqlDataReader dr      = comando.ExecuteReader();

                    if (dr.Read())
                    {
                        cliente    = dr[0].ToString();
                        prestamo   = Convert.ToDouble(dr[1]);
                        interes    = Convert.ToDouble(dr[2]);
                        almacenaje = Convert.ToDouble(dr[3]);
                        iva        = Convert.ToDouble(dr[4]);
                        Fecha      = dr[5].ToString();
                        // ndias        =  dr[6];
                    }
                    conexion.Close();

                    // DateTime Fechaactual = DateTime.Now;
                    //DateTime Fechaactual = DateTime.ParseExact(Fechaactual, "yyyymmdd", System.Globalization.CultureInfo.InvariantCulture);
                    //DateTime Fechavieja = DateTime.ParseExact(Fecha, "yyyymmdd", System.Globalization.CultureInfo.CurrentUICulture);//.InvariantCulture);
                    // DateTime Fechavieja = Convert.ToDateTime(Fecha);// (Fecha, "yyyymmdd", System.Globalization.CultureInfo.CurrentUICulture);//.InvariantCulture);


                    conexion.Open();
                    SqlCommand cmd = new SqlCommand("Ndias", conexion);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@fechainicio", Fecha);

                    SqlDataReader dar = cmd.ExecuteReader();

                    if (dar.Read())
                    {
                        dias = dar[0].ToString();
                    }

                    conexion.Close();
                    Ndias = Convert.ToInt32(dias);



                    //Ndias   = CalculateDays(Fechavieja, Fechaactual);
                    Nsemana = (Ndias / 7);
                    Rsemana = (int)Math.Ceiling(Math.Round(Nsemana));

                    txtalmacenaje.Text = "0";
                    txtiva.Text        = "0";
                    txtinteres.Text    = "0";

                    almacenaje         = (almacenaje * Rsemana);
                    txtalmacenaje.Text = Convert.ToString(almacenaje);

                    iva         = (iva * Rsemana);
                    txtiva.Text = Convert.ToString(iva);

                    interes         = (interes * Rsemana);
                    txtinteres.Text = Convert.ToString(interes);

                    txtprestamo.Text = Convert.ToString(prestamo);

                    txtcliente.Text = cliente;

                    txttotal.Text = Convert.ToString(almacenaje + iva + interes);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ingrese un Numero de boleta valido", "Error:", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 26
0
        private void lanza_impresion_electronicos()
        {
            BD             basedatos = new BD();
            string         strPagos  = "select Plazo, SUM(Prestamo) Prestamo, SUM(Avaluo) Avaluo from PRESTO.dbo.Boleta_Detalle where Boleta_Id=" + boleta_id + " group by Plazo";
            SqlDataAdapter da        = new SqlDataAdapter(strPagos, basedatos.conexionsql());
            DataSet        ds        = new DataSet();

            try
            {
                da.Fill(ds);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //PRESTODataSet.PagosDataTable dt = new PRESTODataSet.PagosDataTable();
            DataTable dt = new DataTable("Pagos");

            dt.Columns.Add("IdBoleta", typeof(int));
            dt.Columns.Add("Importe", typeof(double));
            dt.Columns.Add("Interes", typeof(double));
            dt.Columns.Add("Almacenaje", typeof(double));
            dt.Columns.Add("IVA", typeof(double));
            dt.Columns.Add("PorRefrendo", typeof(double));
            dt.Columns.Add("PorDesempenio", typeof(double));
            dt.Columns.Add("FechaPago", typeof(string));
            dt.Columns.Add("Fecha_Semana", typeof(string));
            dt.Columns.Add("Linea", typeof(string));
            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        switch (ds.Tables[0].Rows[0][0].ToString())
                        {
                        case "1":
                        default:
                            double Prestamo = Convert.ToDouble(ds.Tables[0].Rows[0][1]);
                            for (int i = 1; i < 5; i++)
                            {
                                DataRow dr = dt.NewRow();
                                dr[0] = boleta_id;
                                dr[1] = Prestamo;
                                //double Interes = (Prestamo * .00486) * (i * 7);
                                //0.00397
                                //4069
                                double Interes = (Prestamo * 0.004069) * (i * 7);
                                dr[2] = Math.Round(Interes, 2);
                                double Almacenaje = Prestamo * 0.006 * i;
                                dr[3] = Math.Round(Almacenaje, 2);
                                double IVA = (Interes + Almacenaje) * 0.16;
                                dr[4] = Math.Round(IVA, 2);
                                double Refrendo = (Interes + Almacenaje + IVA);
                                dr[5] = Math.Round(Refrendo, 2);
                                dr[6] = Prestamo + Refrendo;
                                dr[7] = "S " + i.ToString() + "-hasta el->" + DateTime.Now.AddDays(i * 7).ToString("dd/MM/yyyy");
                                dr[8] = DateTime.Now.AddDays(i * 7).ToString("dd/MM/yyyy");
                                dr[9] = i * 1;
                                dt.Rows.Add(dr);
                            }
                            break;
                        }
                    }
                }
            }

            foreach (DataRow dr in dt.Rows)
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("Insert Into Pagos Values(" + dr[0] + "," + dr[1] + "," + dr[2] + "," + dr[3] + "," + dr[4] + "," + dr[5] + "," + dr[6] + ",'" + dr[7] + "','" + dr[8] + "','" + dr[9] + "')", basedatos.conexionsql());
                    cmd.Connection.Open();
                    cmd.ExecuteNonQuery();
                    cmd.Connection.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            reportViewer1.LocalReport.DataSources.Clear();
            Boleta_EncabezadoTableAdapter.Fill(PRESTODataSet.Boleta_Encabezado, boleta_id);
            Boleta_DetalleTableAdapter.Fill(PRESTODataSet.Boleta_Detalle, boleta_id);
            InteresesTableAdapter.Fill(PRESTODataSet.Intereses);
            ClienteTableAdapter.Fill(PRESTODataSet.Cliente, cliente_id);
            SucursalTableAdapter.Fill(PRESTODataSet.Sucursal, 1);

            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsEmpenio", dt));
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsBoleta_Encabezado", PRESTODataSet.Tables["Boleta_Encabezado"]));
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsBoletaDetalle", PRESTODataSet.Tables["Boleta_Detalle"]));
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsIntereses", PRESTODataSet.Tables["Intereses"]));
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsCliente", PRESTODataSet.Tables["Cliente"]));
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsSucursal", PRESTODataSet.Tables["Sucursal"]));

            this.reportViewer1.RefreshReport();
        }
Exemplo n.º 27
0
        private void btnbuscar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtboleta_id.Text != "" && cbxsemana.SelectedItem.ToString() != "0")
                {
                    if (cbxsemana.SelectedItem.ToString() == "1")
                    {
                        BD            basedatos = new BD();
                        SqlConnection conexion;
                        //Creando conexion
                        conexion = basedatos.conexionsql();
                        //Abriendo conexion
                        conexion.Open();
                        SqlCommand    comando = new SqlCommand("select Cliente_nombre, MAX(Importe) Prestamo, MAX(Interes) Intereses, MAX(Almacenaje) Almacenaje, MAX(Iva) Iva, MAX(PorDesempenio) Desempenio from Pagos A Inner Join Boleta_Detalle B on A.IdBoleta=B.Boleta_Id inner join Boleta_Encabezado C on C.boleta_id=B.Boleta_id where idBoleta=" + txtboleta_id.Text + " And Linea=1 And C.Estado='Vigente' " + " Group by Cliente_Nombre", conexion);
                        SqlDataReader dr      = comando.ExecuteReader();

                        if (dr.Read())
                        {
                            txtcliente.Text    = dr[0].ToString();
                            txtprestamo.Text   = dr[1].ToString();
                            txtalmacenaje.Text = dr[3].ToString();
                            txtiva.Text        = dr[4].ToString();
                            txtinteres.Text    = dr[2].ToString();
                            txttotal.Text      = dr[5].ToString();
                        }
                        else
                        {
                            MessageBox.Show("La boleta ya a sido Desempeñada"); txtboleta_id.ReadOnly = false;
                        }
                        lblusuario.Text = "Cajero: " + Program.Usuario;
                    }
                    if (cbxsemana.SelectedItem.ToString() == "2")
                    {
                        BD            basedatos = new BD();
                        SqlConnection conexion;
                        //Creando conexion
                        conexion = basedatos.conexionsql();
                        //Abriendo conexion
                        conexion.Open();
                        SqlCommand    comando = new SqlCommand("select Cliente_nombre, MAX(Importe) Prestamo, MAX(Interes) Intereses, MAX(Almacenaje) Almacenaje, MAX(Iva) Iva, MAX(PorDesempenio) Desempenio from Pagos A Inner Join Boleta_Detalle B on A.IdBoleta=B.Boleta_Id inner join Boleta_Encabezado C on C.boleta_id=B.Boleta_id where idBoleta=" + txtboleta_id.Text + " And Linea=2 And C.Estado='Vigente' " + " Group by Cliente_Nombre", conexion);
                        SqlDataReader dr      = comando.ExecuteReader();

                        if (dr.Read())
                        {
                            txtcliente.Text    = dr[0].ToString();
                            txtprestamo.Text   = dr[1].ToString();
                            txtalmacenaje.Text = dr[3].ToString();
                            txtiva.Text        = dr[4].ToString();
                            txtinteres.Text    = dr[2].ToString();
                            txttotal.Text      = dr[5].ToString();
                        }
                        else
                        {
                            MessageBox.Show("La boleta ya a sido Desempeñada"); txtboleta_id.ReadOnly = false;
                        }
                        lblusuario.Text = "Cajero: " + Program.Usuario;
                    }
                    if (cbxsemana.SelectedItem.ToString() == "3")
                    {
                        BD            basedatos = new BD();
                        SqlConnection conexion;
                        //Creando conexion
                        conexion = basedatos.conexionsql();
                        //Abriendo conexion
                        conexion.Open();
                        SqlCommand    comando = new SqlCommand("select Cliente_nombre, MAX(Importe) Prestamo, MAX(Interes) Intereses, MAX(Almacenaje) Almacenaje, MAX(Iva) Iva, MAX(PorDesempenio) Desempenio from Pagos A Inner Join Boleta_Detalle B on A.IdBoleta=B.Boleta_Id inner join Boleta_Encabezado C on C.boleta_id=B.Boleta_id where idBoleta=" + txtboleta_id.Text + " And Linea=3 And C.Estado='Vigente' " + " Group by Cliente_Nombre", conexion);
                        SqlDataReader dr      = comando.ExecuteReader();

                        if (dr.Read())
                        {
                            txtcliente.Text    = dr[0].ToString();
                            txtprestamo.Text   = dr[1].ToString();
                            txtalmacenaje.Text = dr[3].ToString();
                            txtiva.Text        = dr[4].ToString();
                            txtinteres.Text    = dr[2].ToString();
                            txttotal.Text      = dr[5].ToString();
                        }
                        else
                        {
                            MessageBox.Show("La boleta ya a sido Desempeñada"); txtboleta_id.ReadOnly = false;
                        }
                        lblusuario.Text = "Cajero: " + Program.Usuario;
                    }

                    if (cbxsemana.SelectedItem.ToString() == "4")
                    {
                        BD            basedatos = new BD();
                        SqlConnection conexion;
                        //Creando conexion
                        conexion = basedatos.conexionsql();
                        //Abriendo conexion
                        conexion.Open();
                        SqlCommand    comando = new SqlCommand("select Cliente_nombre, MAX(Importe) Prestamo, MAX(Interes) Intereses, MAX(Almacenaje) Almacenaje, MAX(Iva) Iva, MAX(PorDesempenio) Desempenio from Pagos A Inner Join Boleta_Detalle B on A.IdBoleta=B.Boleta_Id inner join Boleta_Encabezado C on C.boleta_id=B.Boleta_id where idBoleta=" + txtboleta_id.Text + " And Linea=4 And C.Estado='Vigente' " + " Group by Cliente_Nombre", conexion);
                        SqlDataReader dr      = comando.ExecuteReader();

                        if (dr.Read())
                        {
                            txtcliente.Text    = dr[0].ToString();
                            txtprestamo.Text   = dr[1].ToString();
                            txtalmacenaje.Text = dr[3].ToString();
                            txtiva.Text        = dr[4].ToString();
                            txtinteres.Text    = dr[2].ToString();
                            txttotal.Text      = dr[5].ToString();
                        }
                        else
                        {
                            MessageBox.Show("La boleta ya a sido Desempeñada"); txtboleta_id.ReadOnly = false;
                        }
                        lblusuario.Text = "Cajero: " + Program.Usuario;
                    }
                }
                else
                {
                    MessageBox.Show("Ingrese el número de boleta");
                }

                lblusuario.Text       = "Cajero: " + Program.Usuario;
                txtboleta_id.ReadOnly = true;
            }
            catch (Exception)
            {
                MessageBox.Show("Verifica la informacion introducida");
                this.limpiar();
            }
        }
Exemplo n.º 28
0
        private void CargaCombos()
        {     //MostrarDatos
            try
            { //try
                SqlConnection Conexion  = basedatos.conexionsql();
                string        CTipo     = "Select Categoria_Id,Categoria_Nombre from Categoria Order by Categoria_Id;";
                string        CKilataje = "Select Kilataje_id,Kilataje_valor from  Kilataje order by kilataje_valor;";
                string        CEstado   = "Select idpresentacion,presentacion from presentaciones order by idpresentacion;";
                string        Cplazo    = "Select Plazo_id,plazo_nombre from plazo";

                DataSet        ds_tipo = new DataSet();
                SqlDataAdapter Tipo    = new SqlDataAdapter(CTipo, Conexion);
                Tipo.Fill(ds_tipo, "Categoria");
                cbxtipo.DataSource    = ds_tipo.Tables[0].DefaultView;
                cbxtipo.ValueMember   = "Categoria_Id";
                cbxtipo.DisplayMember = "Categoria_Nombre";


                DataSet        ds_kilataje = new DataSet();
                SqlDataAdapter kilataje    = new SqlDataAdapter(CKilataje, Conexion);
                kilataje.Fill(ds_kilataje, "Kilataje");
                cmbkilataje.DataSource    = ds_kilataje.Tables[0].DefaultView;
                cmbkilataje.ValueMember   = "Kilataje_id";
                cmbkilataje.DisplayMember = "Kilataje_valor";

                DataSet        ds_Estado = new DataSet();
                SqlDataAdapter Estado    = new SqlDataAdapter(CEstado, Conexion);
                Estado.Fill(ds_Estado, "presentaciones");
                cmbpresentacion.DataSource    = ds_Estado.Tables[0].DefaultView;
                cmbpresentacion.ValueMember   = "idpresentacion";
                cmbpresentacion.DisplayMember = "presentacion";

                DataSet        ds_Plazo = new DataSet();
                SqlDataAdapter plazo    = new SqlDataAdapter(Cplazo, Conexion);
                plazo.Fill(ds_Plazo, "plazo");
                cmbplazo.DataSource    = ds_Plazo.Tables[0].DefaultView;
                cmbplazo.ValueMember   = "Plazo_id";
                cmbplazo.DisplayMember = "plazo_nombre";



                int kil = Convert.ToInt32(cbxtipo.SelectedValue);

                if (kil > 0)
                {
                    string Cmarca = "Select subcategoria_id,Subcategoria_Nombre From Sub_categoria where Categoria_id= " + kil;

                    DataSet        ds_marca = new DataSet();
                    SqlDataAdapter marca    = new SqlDataAdapter(Cmarca, Conexion);
                    marca.Fill(ds_marca, "sub_categoria");
                    cmbmarca.DataSource    = ds_marca.Tables[0].DefaultView;
                    cmbmarca.ValueMember   = "subcategoria_id";
                    cmbmarca.DisplayMember = "Subcategoria_nombre";
                }
                else
                {
                }
                lblprestamo.Enabled = false;
                txtprestamo.Enabled = false;
            }//try
            catch (SqlException excep)
            {//catch
                MessageBox.Show(excep.Message);
            } //catch
        }     //MostrarDatos
Exemplo n.º 29
0
        private void btnbuscar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtboleta_id.Text != "" && cbxsemana.SelectedItem.ToString() != "0")
                {
                    if (cbxsemana.SelectedItem.ToString() == "1")
                    {
                        BD            basedatos = new BD();
                        SqlConnection conexion;
                        //Creando conexion
                        conexion = basedatos.conexionsql();
                        //Abriendo conexion
                        conexion.Open();
                        SqlCommand    comando = new SqlCommand("select Cliente_nombre, MAX(Importe) Prestamo, MAX(Interes) Intereses, MAX(Almacenaje) Almacenaje, MAX(Iva) Iva, MAX(PorRefrendo) Refrendo from Pagos A Inner Join Boleta_Detalle B on A.IdBoleta=B.Boleta_Id inner join Boleta_Encabezado C on C.boleta_id=B.Boleta_id where idBoleta=" + txtboleta_id.Text + " And linea=1 And ((Convert(varchar,C.Boleta_Fecha_Vencimiento,112)=convert(varchar,getdate(),112)) and C.Estado='Vigente') " + " Group by Cliente_Nombre", conexion);
                        SqlDataReader dr      = comando.ExecuteReader();

                        if (dr.Read())
                        {
                            txtcliente.Text    = dr[0].ToString();
                            txtprestamo.Text   = dr[1].ToString();
                            txtalmacenaje.Text = dr[3].ToString();
                            txtiva.Text        = dr[4].ToString();
                            txtinteres.Text    = dr[2].ToString();
                            txttotal.Text      = dr[5].ToString();
                        }
                    }

                    if (cbxsemana.SelectedItem.ToString() == "2")
                    {
                        BD            basedatos = new BD();
                        SqlConnection conexion;
                        //Creando conexion
                        conexion = basedatos.conexionsql();
                        //Abriendo conexion
                        conexion.Open();
                        SqlCommand    comando = new SqlCommand("select Cliente_nombre, MAX(Importe) Prestamo, MAX(Interes) Intereses, MAX(Almacenaje) Almacenaje, MAX(Iva) Iva, MAX(PorRefrendo) Refrendo from Pagos A Inner Join Boleta_Detalle B on A.IdBoleta=B.Boleta_Id inner join Boleta_Encabezado C on C.boleta_id=B.Boleta_id where idBoleta=" + txtboleta_id.Text + " And linea=2 And ((Convert(varchar,C.Boleta_Fecha_Vencimiento,112)=convert(varchar,getdate(),112))or C.Estado='Vigente') " + " Group by Cliente_Nombre", conexion);
                        SqlDataReader dr      = comando.ExecuteReader();

                        if (dr.Read())
                        {
                            txtcliente.Text    = dr[0].ToString();
                            txtprestamo.Text   = dr[1].ToString();
                            txtalmacenaje.Text = dr[3].ToString();
                            txtiva.Text        = dr[4].ToString();
                            txtinteres.Text    = dr[2].ToString();
                            txttotal.Text      = dr[5].ToString();
                        }
                    }
                    if (cbxsemana.SelectedItem.ToString() == "3")
                    {
                        BD            basedatos = new BD();
                        SqlConnection conexion;
                        //Creando conexion
                        conexion = basedatos.conexionsql();
                        //Abriendo conexion
                        conexion.Open();
                        SqlCommand    comando = new SqlCommand("select Cliente_nombre, MAX(Importe) Prestamo, MAX(Interes) Intereses, MAX(Almacenaje) Almacenaje, MAX(Iva) Iva, MAX(PorRefrendo) Refrendo from Pagos A Inner Join Boleta_Detalle B on A.IdBoleta=B.Boleta_Id inner join Boleta_Encabezado C on C.boleta_id=B.Boleta_id where idBoleta=" + txtboleta_id.Text + " And linea=3 And ((Convert(varchar,C.Boleta_Fecha_Vencimiento,112)=convert(varchar,getdate(),112))or C.Estado='Vigente') " + " Group by Cliente_Nombre", conexion);
                        SqlDataReader dr      = comando.ExecuteReader();

                        if (dr.Read())
                        {
                            txtcliente.Text    = dr[0].ToString();
                            txtprestamo.Text   = dr[1].ToString();
                            txtalmacenaje.Text = dr[3].ToString();
                            txtiva.Text        = dr[4].ToString();
                            txtinteres.Text    = dr[2].ToString();
                            txttotal.Text      = dr[5].ToString();
                        }
                    }
                    if (cbxsemana.SelectedItem.ToString() == "4")
                    {
                        BD            basedatos = new BD();
                        SqlConnection conexion;
                        //Creando conexion
                        conexion = basedatos.conexionsql();
                        //Abriendo conexion
                        conexion.Open();
                        SqlCommand    comando = new SqlCommand("select Cliente_nombre, MIN(Importe) Prestamo, MIN(Interes) Intereses, MIN(Almacenaje) Almacenaje, MIN(Iva) Iva, MIN(PorRefrendo) Refrendo from Pagos A Inner Join Boleta_Detalle B on A.IdBoleta=B.Boleta_Id inner join Boleta_Encabezado C on C.boleta_id=B.Boleta_id where idBoleta=" + txtboleta_id.Text + " And linea=1 And ((Convert(varchar,C.Boleta_Fecha_Vencimiento,112)=convert(varchar,getdate(),112)) and C.Estado='Vigente') " + " Group by Cliente_Nombre", conexion);
                        SqlDataReader dr      = comando.ExecuteReader();

                        if (dr.Read())
                        {
                            txtcliente.Text    = dr[0].ToString();
                            txtprestamo.Text   = dr[1].ToString();
                            txtalmacenaje.Text = dr[3].ToString();
                            txtiva.Text        = dr[4].ToString();
                            txtinteres.Text    = dr[2].ToString();
                            txttotal.Text      = dr[5].ToString();
                        }
                        else
                        {
                            MessageBox.Show("La Boleta no cumplan con lo seleccionado para realizar el refrendo extemporaneo");
                        }
                    }
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Ingrese un Numero de boleta valido", "Error:", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 30
0
        private void btngenerar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtboleta_id.Text != "" && txtcliente.Text != "" && txtinteres.Text != "" && txtiva.Text != "" && txtprestamo.Text != "" && txttotal.Text != "")
                {
                    BD            basedatos = new BD();
                    SqlConnection conexion;
                    //Creando conexion
                    conexion = basedatos.conexionsql();
                    //Abriendo conexion
                    conexion.Open();
                    SqlCommand    comando = new SqlCommand("select Importe, Interes, Almacenaje, Iva, PorRefrendo from Pagos  A inner join Boleta_Encabezado B on A.idBoleta=B.Boleta_id where B.Estado='Vigente' And Linea=4 And A.idBoleta=" + txtboleta_id.Text, conexion);
                    SqlDataReader dr      = comando.ExecuteReader();
                    DataTable     dt      = new DataTable();
                    using (dr)
                    {
                        dt.Load(dr);
                    }
                    int i        = 4;
                    int contador = Convert.ToInt32(lblrefrendo.Text);
                    foreach (DataRow row in dt.Rows)
                    {
                        SqlCommand cmd = new SqlCommand("Insert Into Refrendo(Boleta_Id, Cliente_Nombre, Prestamo, Interes, Almacenaje, Iva, Total, Fecha,Usuario_Id,refrendo) Values(@Prm1,@Prm2,@Prm3,@Prm4,@Prm5,@Prm6,@Prm7,@Prm8,@Prm9,@Prm10)");
                        cmd.Connection = conexion;
                        cmd.Parameters.Add(new SqlParameter("@Prm1", txtboleta_id.Text));
                        cmd.Parameters.Add(new SqlParameter("@Prm2", txtcliente.Text));
                        cmd.Parameters.Add(new SqlParameter("@Prm3", row[0].ToString()));
                        cmd.Parameters.Add(new SqlParameter("@Prm4", row[1].ToString()));
                        cmd.Parameters.Add(new SqlParameter("@Prm5", row[2].ToString()));
                        cmd.Parameters.Add(new SqlParameter("@Prm6", row[3].ToString()));
                        cmd.Parameters.Add(new SqlParameter("@Prm7", row[4].ToString()));
                        cmd.Parameters.Add(new SqlParameter("@Prm8", "S " + i.ToString() + "-hasta el->" + DateTime.Now.AddDays(i * 7).ToString("dd/MM/yyyy")));
                        cmd.Parameters.Add(new SqlParameter("@Prm9", Program.UsuarioId));
                        cmd.Parameters.Add(new SqlParameter("@Prm10", contador));
                        cmd.ExecuteNonQuery();
                        i++;
                    }
                    string   dtme  = Convert.ToString(DateTime.Now.ToShortDateString());
                    DateTime fecha = Convert.ToDateTime(dtme);

                    DateTime fecha_vencimiento = Convert.ToDateTime(dtme);
                    fecha_vencimiento = fecha_vencimiento.AddDays(7);

                    DateTime fecha_comercializacion = fecha_vencimiento;
                    fecha_comercializacion = fecha_comercializacion.AddDays(2);

                    string actualizar = "update Boleta_Encabezado set Estado='Vigente',Boleta_Fecha = '" + fecha.ToString("yyyy-MM-dd hh:mm") + "',Boleta_Fecha_Vencimiento= '" + fecha_vencimiento.ToString("yyyy-MM-dd hh:mm") + "',Boleta_Fecha_Comercializacion= '" + fecha_comercializacion.ToString("yyyy-MM-dd hh:mm") + "' where Boleta_id = " + txtboleta_id.Text;

                    if (bdatos.executecommand(actualizar))
                    {
                        MessageBox.Show("Refrendo generado correctamente");
                    }
                    else
                    {
                        MessageBox.Show("Error al refrendar");
                    }
                    conexion.Close();
                    rptRefrendoExtemporaneo rpt = new rptRefrendoExtemporaneo();
                    rpt.IdBoleta = Convert.ToInt32(txtboleta_id.Text);
                    rpt.refrendo = lblrefrendo.Text;
                    rpt.Linea    = cbxsemana.SelectedItem.ToString();
                    rpt.ShowDialog(this);
                    rpt.Dispose();
                    this.limpiar();
                }
                else
                {
                    MessageBox.Show("Ingrese el número de boleta");
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Error al generar el proceso", "Error:", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }