/// <summary> /// Constructor con todos los atributos. Requerido por el equipo 7 (gestion de cuentas por pagar). /// </summary> /// <param name="idNumeroCuentaBanco"></param> /// <param name="nroCuentaBanco"></param> /// <param name="miBanco"></param> /// <param name="tipoCuentaBanco"></param> /// <param name="listaCuentasPorPagar"></param> public NumeroCuentaBanco(string idNumeroCuentaBanco, string nroCuentaBanco, Banco miBanco, string tipoCuentaBanco, List<CuentaPorPagar> listaCuentasPorPagar) { this.idNumeroCuentaBanco = idNumeroCuentaBanco; this.nroCuentaBanco = nroCuentaBanco; this.tipoCuentaBanco = tipoCuentaBanco; //atributos Listas: this.listaCuentasPorPagar = new List<CuentaPorPagar>(); this.listaCuentasPorPagar = listaCuentasPorPagar; this.miBanco = new Banco(); this.miBanco = miBanco; }
public void OnClickModificar2CuentaPorPagar() { //1- Se recoge la data de cada campo de la gui en el objeto de cuentas por pagar: //id de la cuenta por pagar: (miCuentaPorPagarAagregar as CuentaPorPagar).IdCuentaPorPagar = _vista.LabelcuentaCodigo.Text; //Convert.ToDateTime(miCuentaPorPagarAagregar.FechaEmision).Date //Fila 1: Fechas: (miCuentaPorPagarAagregar as CuentaPorPagar).FechaEmision = _vista.FechaEmision.Text; (miCuentaPorPagarAagregar as CuentaPorPagar).FechaVencimiento = _vista.FechaVencimiento.Text; //Fila 2 y 3: dropdownlists: //DropDownList3: razonsocial/empresa: Proveedor miProveedor = new Proveedor(); miProveedor.Nombre = _vista.DropDownListRazon.SelectedItem.Text.ToString(); //agrego a la lista el proveedor elegido por el usuario (razon social): (miCuentaPorPagarAagregar as CuentaPorPagar).ListaProveedor.Add(miProveedor); //DropDownList5: numero Cuenta bancaria: NumeroCuentaBanco miNumeroCuentaBanco = new NumeroCuentaBanco(); miNumeroCuentaBanco.NroCuentaBanco = _vista.DropDownListCuentaBancaria.SelectedItem.Text.ToString(); //agrego a la lista general: (miCuentaPorPagarAagregar as CuentaPorPagar).ListaNumeroCuentaBanco.Add(miNumeroCuentaBanco); //DropDownList4: banco Banco miBanco = new Banco(); miBanco.NombreBanco = _vista.DropDownListBanco.SelectedItem.Text.ToString(); //agrego a la lista (banco): (miCuentaPorPagarAagregar as CuentaPorPagar).ListaNumeroCuentaBanco.ElementAt(0).Banco = miBanco; //DropDownList6: tipo de pago. (miCuentaPorPagarAagregar as CuentaPorPagar).TipoPago = _vista.DropDownListTipoPago.SelectedItem.Text.ToString(); //FILA 4: Monto deuda: (miCuentaPorPagarAagregar as CuentaPorPagar).MontoInicialDeuda = Convert.ToDouble(_vista.TextBox1.Text); //Validaciones FINALES DE INTEGRIDAD DE LOS DATOS (Justo antes de insertar) //[//0.2- Validar: (int)monto > 0], [//0.1- Validar: FECHA1 <= FECHA2:] + decision si es contra proveedor: //valida fechaini <= fechafin fechasValidas = (miCuentaPorPagarAagregar as CuentaPorPagar).ValidarFechaInicioMayorOigualQueFechaFin(Convert.ToDateTime((miCuentaPorPagarAagregar as CuentaPorPagar).FechaEmision).Date, Convert.ToDateTime((miCuentaPorPagarAagregar as CuentaPorPagar).FechaVencimiento).Date); //validar monto como un int mayor que cero (el hecho de ser DOUBLE ya fue validado en la GUI con la etiqueta VALIDATOR): montoValido = (miCuentaPorPagarAagregar as CuentaPorPagar).ValidarMontoMayorQueCero((miCuentaPorPagarAagregar as CuentaPorPagar).MontoInicialDeuda); //Fila 5: detalle. (miCuentaPorPagarAagregar as CuentaPorPagar).Detalle = _vista.TextBox3DetalleDeuda.Text; string tipoDeudaEmpleado = "nomina"; string tipoDeudaProveedor = "proveedor"; //Si es contra empleados (nomina) o proveedores: la deuda if (fechasValidas && (miCuentaPorPagarAagregar as CuentaPorPagar).ListaProveedor.ElementAt(0).Nombre.Equals(tipoDeudaEmpleado) && montoValido) { //caso: nomina (miCuentaPorPagarAagregar as CuentaPorPagar).TipoDeuda = tipoDeudaEmpleado; //2- Modificar la Cuenta Por Pagar en la BD: // modificacionExitosaCPP = miLogicaCuentaPorPagar.ModificarCuentaPorPagarBD((miCuentaPorPagarAagregar as CuentaPorPagar)); _listaComando = FabricaComando.CrearComandoModificarCuentaPorPagar(miCuentaPorPagarAagregar); _milistaCpp = _listaComando.Ejecutar(); modificacionExitosaCPP=_milistaCpp; } else if (fechasValidas && !(miCuentaPorPagarAagregar as CuentaPorPagar).ListaProveedor.ElementAt(0).Nombre.Equals(tipoDeudaEmpleado) && montoValido) { //caso: proveedor (miCuentaPorPagarAagregar as CuentaPorPagar).TipoDeuda = tipoDeudaProveedor; //2- Modificar la Cuenta Por Pagar en la BD: //modificacionExitosaCPP = miLogicaCuentaPorPagar.ModificarCuentaPorPagarBD((miCuentaPorPagarAagregar as CuentaPorPagar)); _listaComando = FabricaComando.CrearComandoModificarCuentaPorPagar(miCuentaPorPagarAagregar); _milistaCpp = _listaComando.Ejecutar(); modificacionExitosaCPP=_milistaCpp; } else { //Si las dos fechas son invalidas (Emision mayor que la de vencimiento) if (!fechasValidas) { _vista.Falla.Text = _vista.Falla.Text + ": Fecha de Emisión es mayor que la Fecha de Vencimiento."; } //Si las dos fechas son invalidas (Emision mayor que la de vencimiento) if (!montoValido) { _vista.Falla.Text = _vista.Falla.Text + ": El Monto Total (BsF) debe ser mayor que cero."; } _vista.Falla.Visible = true; } //3- Terminada la modoificacion, chequea y decir por pantalla si fue un exito o un fracaso: _vista.Exito.Text = "Operacion Realizada Exitosamente"; _vista.Falla.Text = "Operacion Fallida"; //si fue un fallo: if (!modificacionExitosaCPP) { _vista.Exito.Visible = false; //Exito.Text = ""; //falla.Text = "Operacion Fallida"; _vista.Falla.Visible = true; //Validador del Monto: _vista.ValidatorCompareDoubleTypeMonto.Visible = false; //Validador de Fecha Emision: haciendolo invisible _vista.RegularExpressionValidatorFechaEmision.Visible = false; //Validador de Fecha Vencimiento: haciendolo invisible _vista.RegularExpressionValidatorFechaVencimiento.Visible = false; } else { //si fue un exito: _vista.Falla.Visible = false; //Exito.Text = "Operacion Realizada Exitosamente"; _vista.Exito.Visible = true; //falla.Text = ""; } }
public NumeroCuentaBanco() { //atributos Listas this.miBanco = new Banco(); this.listaCuentasPorPagar = new List<CuentaPorPagar>(); }
public NumeroCuentaBanco() { //atributos Listas this.miBanco = new Banco(); this.listaCuentasPorPagar = new List <CuentaPorPagar>(); }
public List<Banco> ListaBancoProveedores(string nombreProveedor) { { // instancio un objeto conexion y otro Sqlcommand para la BD ConexionDAOS conex = new ConexionDAOS(); SqlCommand command = new SqlCommand(); SqlDataReader reader = null; List<Banco> listaBanco = new List<Banco>(); try { conex.AbrirConexion(); command.Connection = conex.ObjetoConexion(); command.CommandType = System.Data.CommandType.StoredProcedure; // Aqui debo poner el nombre del storeProcedure que no esta hecho command.CommandText = "[dbo].[BuscarBancoProveedor]"; command.CommandTimeout = 10; //Aqui van los parametros del store procesure command.Parameters.AddWithValue("@nombreProveedor", nombreProveedor); //Se indica que es un parametro de entrada command.Parameters["@nombreProveedor"].Direction = ParameterDirection.Input; reader = command.ExecuteReader(); // guarda registro a registro cada objeto de tipo cuentaPorPagar while (reader.Read()) { Banco banco = new Banco(); banco.NombreBanco = reader.GetString(0); //Lleno la lista de cuentas por pagar listaBanco.Add(banco); } } catch (SqlException) { throw new Exception(); } finally { if (reader != null) reader.Close(); conex.CerrarConexion(); } return listaBanco; } }
public Entidad llenarAbonarCpp2(string nombreProveedor, Int64 codigoCuenta) { // instancio un objeto conexion y otro Sqlcommand para la BD ConexionDAOS conex = new ConexionDAOS(); SqlCommand command = new SqlCommand(); SqlDataReader reader = null; Entidad cuentaPP = FabricaEntidad.CrearCuentaPorPagar(); try { conex.AbrirConexion(); command.Connection = conex.ObjetoConexion(); command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "[dbo].[llenarAbonoCpp2]"; command.CommandTimeout = 10; //Aqui van los parametros del store procesure command.Parameters.AddWithValue("@proveedor", nombreProveedor); command.Parameters.AddWithValue("@idCuentaPP", codigoCuenta); //Se indica que es un parametro de entrada command.Parameters["@proveedor"].Direction = ParameterDirection.Input; command.Parameters["@idCuentaPP"].Direction = ParameterDirection.Input; //CuentaPorPagar cuentaPP = new CuentaPorPagar(); reader = command.ExecuteReader(); // guarda registro a registro cada objeto de tipo cuentaPorPagar if (reader.Read()) { NumeroCuentaBanco miNumeroCuentaBanco = new NumeroCuentaBanco(); miNumeroCuentaBanco.NroCuentaBanco = reader.GetString(0); (cuentaPP as CuentaPorPagar).ListaNumeroCuentaBanco.Add(miNumeroCuentaBanco); Banco miBanco = new Banco(); miBanco.NombreBanco = reader.GetString(1); (cuentaPP as CuentaPorPagar).ListaNumeroCuentaBanco.ElementAt(0).Banco = miBanco; (cuentaPP as CuentaPorPagar).TipoPago = reader.GetString(2); Entidad miabono = FabricaEntidad.CrearAbono(); (miabono as Abono).MontoAbono = reader.GetDouble(3); (cuentaPP as CuentaPorPagar).ListaAbono.Add(miabono as Abono); } } catch (SqlException) { throw new Exception(); } finally { if (reader != null) reader.Close(); conex.CerrarConexion(); } return cuentaPP; }
public Entidad ConsultarCuentaPorPagar(string idCuentaPorPagar) { // instancia de un objeto de tipo conexion para acceder a la bd // instancia de un objeto de tipo sqlCommand ConexionDAOS miConexion = new ConexionDAOS(); SqlCommand command = new SqlCommand(); SqlDataReader reader = null; //se carga la informacion consultada en un objeto de tipo cuenta por pagar try { // se abre la conexion a bd vudu miConexion.AbrirConexion(); command.Connection = miConexion.ObjetoConexion(); command.CommandType = System.Data.CommandType.StoredProcedure; //nombre del stored Procedure que aun no esta hecho command.CommandText = "[dbo].[ConsultarCuentaPorPagar]"; command.CommandTimeout = 10; // variables del stored procedure de sql server. command.Parameters.AddWithValue("@idCuentaPorPagar", idCuentaPorPagar); // Se indica que es un parametro de entrada command.Parameters["@idCuentaPorPagar"].Direction = ParameterDirection.Input; reader = command.ExecuteReader(); if (reader.Read()) { (_cuentaPorPagar as CuentaPorPagar).IdCuentaPorPagar = Convert.ToString(reader.GetInt64(0)); (_cuentaPorPagar as CuentaPorPagar).FechaEmision = String.Format("{0:yyyy/MM/dd}", Convert.ToString(reader.GetDateTime(1))); (_cuentaPorPagar as CuentaPorPagar).FechaVencimiento = String.Format("{0:yyyy/MM/dd}", Convert.ToString(reader.GetDateTime(2))); (_cuentaPorPagar as CuentaPorPagar).TipoPago = reader.GetString(3); (_cuentaPorPagar as CuentaPorPagar).Estatus = reader.GetString(4); (_cuentaPorPagar as CuentaPorPagar).TipoDeuda = reader.GetString(5); //Puede dar error si los inserts son nulos: if (!reader.IsDBNull(6)) { (_cuentaPorPagar as CuentaPorPagar).Detalle = reader.GetString(6); } else { (_cuentaPorPagar as CuentaPorPagar).Detalle = ""; } (_cuentaPorPagar as CuentaPorPagar).MontoInicialDeuda = Convert.ToDouble(reader.GetFloat(7)); Proveedor miProveedor = new Proveedor(); miProveedor.Nombre = reader.GetString(8); (_cuentaPorPagar as CuentaPorPagar).ListaProveedor.Add(miProveedor); NumeroCuentaBanco miNumeroCuentaBanco = new NumeroCuentaBanco(); miNumeroCuentaBanco.NroCuentaBanco = reader.GetString(9); (_cuentaPorPagar as CuentaPorPagar).ListaNumeroCuentaBanco.Add(miNumeroCuentaBanco); Banco miBanco = new Banco(); miBanco.NombreBanco = reader.GetString(10); (_cuentaPorPagar as CuentaPorPagar).ListaNumeroCuentaBanco.ElementAt(0).Banco = miBanco; } } catch (SqlException) { throw new Exception(); } //se cierra la conexion independientemente de que se haya detectado o no una excepcion. finally { if (reader != null) reader.Close(); miConexion.CerrarConexion(); } return _cuentaPorPagar; }