public bool CambioDePinCliente(Cliente elCliente, string nuevoPin, string pinAnterior) { try { if (elCliente.pin != pinAnterior) { throw new CustomException("!El PIN actual ingresado es incorrecto!"); } else if (elCliente.pin == nuevoPin) { throw new CustomException("!El nuevo PIN no puede ser igual al PIN anterior!"); } else if (elCliente.pin == pinAnterior) { elCliente.pin = nuevoPin; Cliente.ActualizarPin(elCliente); return true; } else return false; } catch (CustomException ex) { throw ex; } }
public static bool ActualizarSaldo(Cliente elCliente) { SqlConnection conn = new SqlConnection(@"server = .\sqlexpress; integrated security = true; database = GenisysATM"); SqlCommand cmd = new SqlCommand("sp_ModificarSaldoCliente", conn); cmd.CommandType = CommandType.StoredProcedure; // Parámteros cmd.Parameters.Add(new SqlParameter("saldoCliente", SqlDbType.Decimal)); cmd.Parameters.Add(new SqlParameter("idCliente", SqlDbType.SmallInt)); cmd.Parameters["saldoCliente"].Value = elCliente.saldo; cmd.Parameters["idCliente"].Value = elCliente.id; try { conn.Open(); cmd.ExecuteNonQuery(); return true; } catch (CustomException ex) { throw ex; } finally { conn.Close(); } }
public RetiroDolares(string clienteIngresado) { InitializeComponent(); materialSkinManager = MaterialSkinManager.Instance; materialSkinManager.AddFormToManage(this); materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE); // Definiendo los valores del cliente elCliente = Cliente.ObtenerCliente(clienteIngresado); }
public static Cliente ObtenerCliente(string tarjeta) { SqlConnection conn = new SqlConnection(@"server = .\sqlexpress; integrated security = true; database = GenisysATM"); string sql; Cliente resultado = new Cliente(); sql = @"Select * From ATM.Clientes Where NumeroTarjeta = @tarjeta"; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader rdr; try { // Establecer la conexión conn.Open(); using (cmd) { cmd.Parameters.Add("@tarjeta", SqlDbType.NVarChar, 16).Value = tarjeta; rdr = cmd.ExecuteReader(); } while (rdr.Read()) { resultado.id = rdr.GetInt16(0); resultado.nombre = rdr.GetString(1); resultado.apellido = rdr.GetString(2); resultado.pin = rdr.GetString(3); resultado.saldo = rdr.GetDecimal(4); resultado.numeroTarjeta = rdr.GetString(5); // removiendo espacios puestos por SQL resultado.nombre = resultado.nombre.TrimEnd(); resultado.apellido = resultado.apellido.TrimEnd(); resultado.numeroTarjeta = resultado.numeroTarjeta.TrimEnd(); } return resultado; } catch (SqlException ex) { return resultado; } finally { conn.Close(); } }
public bool VerificarInicio(string tarjeta, string pin) { cliente = Cliente.ObtenerCliente(tarjeta); if (cliente.numeroTarjeta == tarjeta && cliente.pin == pin) { return true; } else return false; }
public bool RetiroLempiras(Cliente elCliente, int monto) { try { if (this.EvaluarTransaccionLempiras(monto)) { if (elCliente.saldo <= monto) { throw new CustomException("Saldo insuficiente para realizar la transacción"); } else { elCliente.saldo = elCliente.saldo - monto; // Actualizar el saldo del cliente if (Cliente.ActualizarSaldo(elCliente)) { return true; } else throw new CustomException("Error al momento de realizar el retiro. Su saldo no fué afectado."); } } else throw new CustomException("El monto ingresado de Lps. {0} supera el monto límite de retiro en lempiras.", monto); } catch (CustomException ex) { throw ex; } }
public bool PagoTarjetaCredito(Cliente elCliente, TarjetaCredito tarjeta, decimal montoAPagar) { try { decimal montoLempiras = montoAPagar * decimal.Parse(tasaCambio); if (elCliente.saldo < montoLempiras) { throw new CustomException("Saldo insuficiente para realizar la transacción"); } else if (elCliente.saldo == montoLempiras) { throw new CustomException("Por políticas del ATM, no puede dejar su saldo en Lps. 0.00, favor revise el monto a pagar."); } else { elCliente.saldo = elCliente.saldo - montoLempiras; tarjeta.monto = tarjeta.monto - montoAPagar; // Actualizar los valores pagados y debitados Cliente.ActualizarSaldo(elCliente); TarjetaCredito.ActualizarMonto(tarjeta); return true; } } catch (CustomException ex) { throw ex; } }