Beispiel #1
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            if (cmbNroCuenta.SelectedItem == null)
            {
                MessageBox.Show("Seleccione un Número de Cuenta, por favor");
                return;
            }
            if (cmbMoneda.SelectedItem == null)
            {
                MessageBox.Show("Seleccione un tipo de moneda, por favor");
                return;
            }
            if (cmbTarjeta.SelectedItem == null)
            {
                MessageBox.Show("Seleccione un Número de Tarjeta de Crédito, por favor");
                return;
            }
            if (txtImporte.Text == "")
            {
                MessageBox.Show("Ingrese un Importe, por favor");
                return;
            }
            decimal temp;
            try
            {
                if (txtImporte.Text != "") {
                    temp = Convert.ToDecimal(txtImporte.Text);
                    if (temp <= 1)
                    {
                        MessageBox.Show("El importe debe ser mayor a uno.");
                        return;
                    }
                }

            }
            catch (Exception h)
            {
                MessageBox.Show("Importe solo puede contener números",h.ToString());
                return;
            }

            Conexion con = new Conexion();
            //CONSIGO ID DE EMISOR TARJETA (?)
            string query1 = "SELECT id_emisor FROM LPP.TARJETAS WHERE num_tarjeta = '" + num_tarjeta + "'";
            con.cnn.Open();
            SqlCommand command1 = new SqlCommand(query1, con.cnn);
            SqlDataReader lector1 = command1.ExecuteReader();
            while (lector1.Read())
            {
                id_emisor = lector1.GetDecimal(0);
            }
            con.cnn.Close();

            //CONSIGO ID DE MONEDA
            string query = "SELECT id_moneda FROM LPP.MONEDAS WHERE descripcion = '"+cmbMoneda.Text+"'";
            con.cnn.Open();
            SqlCommand command = new SqlCommand(query, con.cnn);
            SqlDataReader lector = command.ExecuteReader();
            while (lector.Read())
            {
                id_moneda = lector.GetDecimal(0);
            }
            con.cnn.Close();

            //INSERTO DATOS EN DEPOSITOS
            string query4 = "INSERT INTO LPP.DEPOSITOS (num_cuenta, importe, id_moneda, num_tarjeta, id_emisor, fecha_deposito)"
                            +" VALUES (" + Convert.ToDecimal(cmbNroCuenta.Text) + ", "+Convert.ToDecimal(txtImporte.Text) +", "+ id_moneda +", '"+ num_tarjeta +"', "+ id_emisor +", CONVERT(datetime,'" + readConfiguracion.Configuracion.fechaSystem() + " 00:00:00.000', 103))";
            con.cnn.Open();
            SqlCommand command4 = new SqlCommand(query4, con.cnn);
            command4.ExecuteNonQuery();
            con.cnn.Close();

            //SUMO IMPORTE EN CUENTA
            string query5 = "UPDATE LPP.CUENTAS SET saldo = saldo + "+Convert.ToDecimal(txtImporte.Text)+" WHERE num_cuenta = "+Convert.ToDecimal(cmbNroCuenta.SelectedItem)+"";
            con.cnn.Open();
            SqlCommand command5 = new SqlCommand(query5, con.cnn);
            command5.ExecuteNonQuery();
            con.cnn.Close();

             DialogResult dialogResult = MessageBox.Show("Su deposito se realizo correctamente. ¿Desea ver el comprobante?", "Despositos", MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 //Obtengo el numero del deposito que acabo de hacer
                string query6 = "SELECT num_deposito FROM LPP.DEPOSITOS WHERE "
                             +" num_cuenta = " + Convert.ToDecimal(cmbNroCuenta.Text)
                             +" AND importe = "+Convert.ToDecimal(txtImporte.Text)
                             +" AND id_moneda = "+ id_moneda
                             +" AND num_tarjeta = '"+ num_tarjeta +"'"
                             +" AND id_emisor = "+ id_emisor
                             +" AND fecha_deposito = CONVERT(datetime,'" + readConfiguracion.Configuracion.fechaSystem() + " 00:00:00.000', 103)";
                con.cnn.Open();
                SqlCommand command6 = new SqlCommand(query6, con.cnn);
                decimal num_deposito = Convert.ToDecimal(command6.ExecuteScalar());

                ListaDeposito ld = new ListaDeposito(num_deposito);
                ld.Show();
                this.Close();
             }
             else
             {
                 this.Close();
             }
        }
Beispiel #2
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            if (cmbNroCuenta.SelectedItem == null)
            {
                MessageBox.Show("Seleccione un Número de Cuenta, por favor");
                return;
            }
            if (cmbMoneda.SelectedItem == null)
            {
                MessageBox.Show("Seleccione un tipo de moneda, por favor");
                return;
            }
            if (cmbTarjeta.SelectedItem == null)
            {
                MessageBox.Show("Seleccione un Número de Tarjeta de Crédito, por favor");
                return;
            }
            if (txtImporte.Text == "")
            {
                MessageBox.Show("Ingrese un Importe, por favor");
                return;
            }
            int temp;

            try
            {
                if (txtImporte.Text != "")
                {
                    temp = Convert.ToInt32(txtImporte.Text);
                }
            }
            catch (Exception h)
            {
                MessageBox.Show("Importe solo puede contener números", h.ToString());
                return;
            }

            Conexion con = new Conexion();
            //CONSIGO ID DE EMISOR TARJETA (?)
            string query1 = "SELECT id_emisor FROM LPP.TARJETAS WHERE num_tarjeta = '" + num_tarjeta + "'";

            con.cnn.Open();
            SqlCommand    command1 = new SqlCommand(query1, con.cnn);
            SqlDataReader lector1  = command1.ExecuteReader();

            while (lector1.Read())
            {
                id_emisor = lector1.GetDecimal(0);
            }
            con.cnn.Close();

            //CONSIGO ID DE MONEDA
            string query = "SELECT id_moneda FROM LPP.MONEDAS WHERE descripcion = '" + cmbMoneda.Text + "'";

            con.cnn.Open();
            SqlCommand    command = new SqlCommand(query, con.cnn);
            SqlDataReader lector  = command.ExecuteReader();

            while (lector.Read())
            {
                id_moneda = lector.GetDecimal(0);
            }
            con.cnn.Close();



            //INSERTO DATOS EN DEPOSITOS
            string query4 = "INSERT INTO LPP.DEPOSITOS (num_cuenta, importe, id_moneda, num_tarjeta, id_emisor, fecha_deposito)"
                            + " VALUES (" + Convert.ToDecimal(cmbNroCuenta.Text) + ", " + Convert.ToDecimal(txtImporte.Text) + ", " + id_moneda + ", '" + num_tarjeta + "', " + id_emisor + ", CONVERT(datetime,'" + readConfiguracion.Configuracion.fechaSystem() + " 00:00:00.000', 103))";

            con.cnn.Open();
            SqlCommand command4 = new SqlCommand(query4, con.cnn);

            command4.ExecuteNonQuery();
            con.cnn.Close();

            //SUMO IMPORTE EN CUENTA
            string query5 = "UPDATE LPP.CUENTAS SET saldo = saldo + " + Convert.ToDecimal(txtImporte.Text) + " WHERE num_cuenta = " + Convert.ToDecimal(cmbNroCuenta.SelectedItem) + "";

            con.cnn.Open();
            SqlCommand command5 = new SqlCommand(query5, con.cnn);

            command5.ExecuteNonQuery();
            con.cnn.Close();



            DialogResult dialogResult = MessageBox.Show("Su deposito se realizo correctamente. ¿Desea ver el comprobante?", "Despositos", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                //Obtengo el numero del deposito que acabo de hacer
                string query6 = "SELECT num_deposito FROM LPP.DEPOSITOS WHERE "
                                + " num_cuenta = " + Convert.ToDecimal(cmbNroCuenta.Text)
                                + " AND importe = " + Convert.ToDecimal(txtImporte.Text)
                                + " AND id_moneda = " + id_moneda
                                + " AND num_tarjeta = '" + num_tarjeta + "'"
                                + " AND id_emisor = " + id_emisor
                                + " AND fecha_deposito = CONVERT(datetime,'" + readConfiguracion.Configuracion.fechaSystem() + " 00:00:00.000', 103)";
                con.cnn.Open();
                SqlCommand command6     = new SqlCommand(query6, con.cnn);
                decimal    num_deposito = Convert.ToDecimal(command6.ExecuteScalar());

                ListaDeposito ld = new ListaDeposito(num_deposito);
                ld.Show();
                this.Close();
            }
            else
            {
                this.Close();
            }
        }