Exemplo n.º 1
0
        public static List <Ent_PagosProveedores> getPagos(string fecha)
        {
            List <Ent_PagosProveedores> lstProveedores = new List <Ent_PagosProveedores>();

            con = Conexion.getConnection();
            MySqlCommand cmd = new MySqlCommand();

            con.Open();

            cmd.Connection  = con;
            cmd.CommandText = "SP_SYS_GET_PAGO_PROVEEDOR";
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@PSTR_FECHA", fecha);
            cmd.Parameters["@PSTR_FECHA"].Direction = ParameterDirection.Input;

            MySqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Ent_PagosProveedores proveedor = new Ent_PagosProveedores();

                proveedor.codigo        = Convert.ToString(dr["CODIGO"]);
                proveedor.fecha_emision = Convert.ToString(dr["FECHA_EMISION"]);
                proveedor.proveedor     = Convert.ToString(dr["PROVEEDOR"]);
                proveedor.usuario       = Convert.ToString(dr["USUARIO"]);
                proveedor.monto         = Convert.ToDouble(dr["MONTO"]);

                lstProveedores.Add(proveedor);
            }

            con.Close();

            return(lstProveedores);
        }
Exemplo n.º 2
0
        private void btnRegistrarPago_Click(object sender, EventArgs e)
        {
            if (txtNroFactura.Text.Equals(String.Empty))
            {
                MessageBox.Show("El número de factura no puede estar vacío.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtNroFactura.Focus();
                return;
            }

            if (txtMonto.Text.Equals(String.Empty))
            {
                MessageBox.Show("El monto no puede estar vacío o ser menor o igual a 0.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtMonto.Text = "0.00";
                txtMonto.Focus();
                return;
            }

            try
            {
                int    id_proveedor = int.Parse(cboProveedores.SelectedValue.ToString());
                int    nro_factura  = int.Parse(txtNroFactura.Text.Split('-')[1]);
                double monto        = double.Parse(txtMonto.Text);

                Ent_PagosProveedores ent = new Ent_PagosProveedores();
                ent.id_proveedor = id_proveedor;
                ent.nro_factura  = nro_factura;
                ent.usuario      = usuario;
                ent.monto        = monto;

                string result = BL_Proveedores.registrarPago(ent);

                if (result == "1")
                {
                    MessageBox.Show("Pago registrado con éxito!.", "Regitrar Pago", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    reiniciarRegistrarPago();
                }
                else
                {
                    MessageBox.Show("Ocurrió un error al registrar el pago.\n\n" + result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show("Error en el formato del número de factura.\n\nFormato: 000-000000", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public static string registrarPago(Ent_PagosProveedores ent)
        {
            MySqlTransaction tr = null;

            con = Conexion.getConnection();

            string retval = "1";

            try
            {
                con.Open();

                tr = con.BeginTransaction();

                MySqlCommand cmd = new MySqlCommand();

                cmd.Connection  = con;
                cmd.Transaction = tr;

                cmd.CommandText = "SP_SYS_SET_PAGO_PROVEEDOR";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@RETVAL", MySqlDbType.VarChar);
                cmd.Parameters["@RETVAL"].Direction = ParameterDirection.Output;

                cmd.Parameters.AddWithValue("@PSTR_ID_PROVEEDOR", ent.id_proveedor);
                cmd.Parameters["@PSTR_ID_PROVEEDOR"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_NRO_FACTURA", ent.nro_factura);
                cmd.Parameters["@PSTR_NRO_FACTURA"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_USUARIO", ent.usuario);
                cmd.Parameters["@PSTR_USUARIO"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_MONTO", ent.monto);
                cmd.Parameters["@PSTR_MONTO"].Direction = ParameterDirection.Input;

                cmd.ExecuteNonQuery();

                retval = cmd.Parameters["@RETVAL"].Value.ToString();

                if (retval == "1")
                {
                    tr.Commit();
                }
                else
                {
                    tr.Rollback();
                    return(retval);
                }
            }
            catch (MySqlException ex)
            {
                try
                {
                    tr.Rollback();
                }
                catch (MySqlException ex1)
                {
                    return(ex1.ToString());
                }

                return(ex.ToString());
            }
            finally
            {
                con.Close();
            }

            return(retval);
        }
Exemplo n.º 4
0
 public static string registrarPago(Ent_PagosProveedores ent)
 {
     return(DAO_Proveedores.registrarPago(ent));
 }