public ActionResult Editar(int Id) { BancoModel model = new BancoModel(); using (CPMEntities datos = new CPMEntities()) { var tabla = datos.BANCO.Find(Id); model.IdBanco = tabla.IdBanco; model.Nombre = tabla.Nombre; model.Correo = tabla.Correo; model.Telefono = tabla.Telefono; } return(View(model)); }
// GET: Banco/Delete/5 public ActionResult Delete(int id) { BancoModel bancoModel = new BancoModel(); DataTable dt = new DataTable(); BancoAppContext context = HttpContext.RequestServices.GetService(typeof(BancoApp.Models.BancoAppContext)) as BancoAppContext; MySqlConnection conn = context.GetConnection(); conn.Open(); string sqlquery = "SELECT * FROM Banco WHERE idBanco = @IdBanco"; MySqlDataAdapter sda = new MySqlDataAdapter(sqlquery, conn); sda.SelectCommand.Parameters.AddWithValue("@IdBanco", id); sda.Fill(dt); if (dt.Rows.Count == 1) { bancoModel.IdBanco = Convert.ToInt32(dt.Rows[0][0].ToString()); bancoModel.Nombre = dt.Rows[0][1].ToString(); bancoModel.Direccion = dt.Rows[0][2].ToString(); bancoModel.FechaRegistro = (System.DateTime)dt.Rows[0][3]; return(View(bancoModel)); } else { return(RedirectToAction("Index")); } }
/// <summary> /// Ejecuta la acción del command /// </summary> /// <param name="catalogItemStatusViewModel"></param> public ModifyBancoViewModel(CatalogBancoViewModel catalogBancoViewModel, BancoModel selectedBancoModel) { this._banco = new BancoModel(new BancoDataMapper(), catalogBancoViewModel.ActualUser); this._catalogBancoViewModel = catalogBancoViewModel; this._banco.UnidBanco = selectedBancoModel.UnidBanco; this._banco.BancoName = selectedBancoModel.BancoName; }
public IActionResult AddBanco([FromBody] BancoModel Banco) { var resul = _bancoService.AddBanco(BancoMappers.Map(Banco)); var Resultado = _bancoService.GetBancosAll(); return(Ok(Resultado)); }
public ActionResult Editar(BancoModel model) { using (CPMEntities datos = new CPMEntities()) { datos.sp_EditarBanco(model.IdBanco, model.Nombre, model.Telefono, model.Correo); } return(Redirect("~/Banco/")); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Add(BancoModel model) { #region Regras model.DataCadastro = DateTime.Now; model.Ativo = true; #endregion return(_rep.Add(model)); }
/// <summary> /// Método para retornar o Id após cadastro /// </summary> /// <param name="model"></param> /// <returns></returns> public BancoModel AddToReturnEntity(BancoModel model) { #region Regras model.DataCadastro = DateTime.Now; model.Ativo = true; #endregion return(_rep.AddToReturnEntity(model)); }
public static Banco Map(BancoModel Model) { return(new Banco() { Direccion = Model.Direccion, FechaRegistro = Model.FechaRegistro, Id = Model.Id, Nombre = Model.Nombre }); }
/// <summary> /// Selects the Single object of BancoModel table. /// </summary> public BancoModel GetBancoModel(int aID) { BancoModel BancoModel = null; try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlCommand command = connection.CreateCommand(); command.Parameters.AddWithValue("@pMode", 2); command.Parameters.AddWithValue("@ID", aID); command.CommandType = CommandType.StoredProcedure; command.CommandText = "spBanco"; SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { int ID = (int)(reader["ID"]); string Nombre = (string)(reader["Nombre"]); string Ubicacion = (string)(reader["Ubicacion"]); string USUARIO_CREADOR = (string)(reader["USUARIO_CREADOR"]); DateTime FECHA_CREACION = (DateTime)(reader["FECHA_CREACION"]); string USUARIO_MODIFICADOR = (reader["USUARIO_MODIFICADOR"]) == DBNull.Value ? null : (string)(reader["USUARIO_MODIFICADOR"]); DateTime?FECHA_MODIFICACION = reader["FECHA_MODIFICACION"] as DateTime?; BancoModel = new BancoModel { Id = ID, Nombre = Nombre, Ubicacion = Ubicacion, Usuario_creador = USUARIO_CREADOR, Fecha_creacion = FECHA_CREACION, Usuario_modificador = USUARIO_MODIFICADOR, Fecha_modificacion = FECHA_MODIFICACION, }; } } } return(BancoModel); } catch (Exception) { return(null); } }
// // GET: /Banco/Edit/5 public ActionResult Edit(int id) { var oBanco = new Banco { Id = id }; oBanco = _bancoAppService.ListarPorId(oBanco); BancoModel oBancoModel = Mapper.Map <Banco, BancoModel>(oBanco); return(View(oBancoModel)); }
/// <summary> /// Crea una nueva instancia de ModifyItemStatus y se pasa asi mismo como parámetro y el item seleccionado /// </summary> /// <returns></returns> public ModifyBancoViewModel CreateBancoViewModel() { BancoModel bancoModel = new BancoModel(new BancoDataMapper(), this.ActualUser); if (this._catalogBancoModel != null && this._catalogBancoModel.SelectedBanco != null) { bancoModel.BancoName = this._catalogBancoModel.SelectedBanco.BANCO_NAME; bancoModel.UnidBanco = this._catalogBancoModel.SelectedBanco.UNID_BANCO; } return(new ModifyBancoViewModel(this, bancoModel)); }
public async Task <IActionResult> Insert(BancoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var banco = _mapper.Map <BancoDto>(model); var a = await _bancoRepositorio.Insertar(banco); return(Ok(a)); }
public ActionResult Index() { BancoModel model = new BancoModel(); model.permisos = PermisosModulo.ObtenerPermisos(Modulo.BANCOS); if (model == null) { TempData["message"] = "danger,No tiene pemisos"; return(Redirect("~/Home")); } return(View(ABSOLUTE_PATH, model)); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(BancoModel model) { #region Regras var update = Get(model.Id); update.Nome = !string.IsNullOrEmpty(model.Nome)? model.Nome:update.Nome; update.Ativo = model.Ativo; update.DataAtualizacao = DateTime.Now; #endregion return(_rep.Update(update)); }
/// <summary> /// Saves a record to the BancoModel table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Insert(BancoModel aBancoModel, int ID_user) { try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlTransaction sqlTran = connection.BeginTransaction(); SqlCommand command = connection.CreateCommand(); command.Transaction = sqlTran; command.Parameters.AddWithValue("@pMode", 4); command.Parameters.AddWithValue("@ID_user", ID_user); command.Parameters.AddWithValue("@Nombre", aBancoModel.Nombre); command.Parameters.AddWithValue("@Ubicacion", aBancoModel.Ubicacion); SqlParameter paramId = new SqlParameter("@IDENTITY", SqlDbType.Int); paramId.Direction = ParameterDirection.Output; command.Parameters.Add(paramId); command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_pBanco"; int afectados = command.ExecuteNonQuery(); int identity = Convert.ToInt32(command.Parameters["@IDENTITY"].Value.ToString()); // Commit the transaction. sqlTran.Commit(); connection.Close(); connection.Dispose(); if (afectados > 0) { return(true); } else { return(false); } } } catch (Exception) { return(false); } }
public async Task <IActionResult> Edit(long id, BancoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var banco = _mapper.Map <BancoDto>(model); banco.Id = id; await _bancoRepositorio.Modificar(banco); return(Ok(model)); }
/// <summary> /// Updates a record to the BancoModel table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Update(BancoModel aBancoModel) { try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlTransaction sqlTran = connection.BeginTransaction(); SqlCommand command = connection.CreateCommand(); command.Transaction = sqlTran; command.Parameters.AddWithValue("@pMode", 5); command.Parameters.AddWithValue("@ID", aBancoModel.Id); command.Parameters.AddWithValue("@Nombre", aBancoModel.Nombre); command.Parameters.AddWithValue("@Ubicacion", aBancoModel.Ubicacion); command.Parameters.AddWithValue("@USUARIO_CREADOR", aBancoModel.Usuario_creador); command.Parameters.AddWithValue("@FECHA_CREACION", aBancoModel.Fecha_creacion); command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", aBancoModel.Usuario_modificador == null ? (object)DBNull.Value : aBancoModel.Usuario_modificador); command.Parameters.AddWithValue("@FECHA_MODIFICACION", aBancoModel.Fecha_modificacion == null ? (object)DBNull.Value : aBancoModel.Fecha_modificacion); command.CommandType = CommandType.StoredProcedure; command.CommandText = "spBanco"; int afectados = command.ExecuteNonQuery(); // Commit the transaction. sqlTran.Commit(); connection.Close(); connection.Dispose(); if (afectados > 0) { return(true); } else { return(false); } } } catch (Exception) { return(false); } }
// GET: Banco/Details/5 public ActionResult Details(int id) { BancoModel bancoModel = new BancoModel(); DataTable dt = new DataTable(); BancoAppContext context = HttpContext.RequestServices.GetService(typeof(BancoApp.Models.BancoAppContext)) as BancoAppContext; MySqlConnection conn = context.GetConnection(); conn.Open(); string sqlquery = "SELECT * FROM Banco WHERE idBanco = @IdBanco"; MySqlDataAdapter sda = new MySqlDataAdapter(sqlquery, conn); sda.SelectCommand.Parameters.AddWithValue("@IdBanco", id); sda.Fill(dt); if (dt.Rows.Count == 1) { bancoModel.IdBanco = Convert.ToInt32(dt.Rows[0][0].ToString()); bancoModel.Nombre = dt.Rows[0][1].ToString(); bancoModel.Direccion = dt.Rows[0][2].ToString(); bancoModel.FechaRegistro = (System.DateTime)dt.Rows[0][3]; // get list sucursales DataTable dts = new DataTable(); string sqlquery_s = "SELECT * FROM Sucursal WHERE Banco_idBanco = @IdBanco"; MySqlCommand cmd = new MySqlCommand(sqlquery_s, conn); cmd.Parameters.AddWithValue("@IdBanco", id); MySqlDataReader sdr = cmd.ExecuteReader(); List <SucursalModel> list = new List <SucursalModel>(); while (sdr.Read()) { list.Add(new SucursalModel() { IdSucursal = Convert.ToInt32(sdr["IdSucursal"]), Nombre = sdr["Nombre"].ToString(), Direccion = sdr["Direccion"].ToString(), FechaRegistro = (System.DateTime)sdr["FechaRegistro"], IdBanco = Convert.ToInt32(sdr["Banco_idBanco"].ToString()), }); } ViewBag.sucursales = list; return(View(bancoModel)); } else { return(RedirectToAction("Index")); } }
/// <summary> /// Selects the Single object of BancoModel table. /// </summary> public BancoModel GetBancoModel(int aID) { BancoModel BancoModel = null; try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlCommand command = connection.CreateCommand(); command.Parameters.AddWithValue("@pMode", 2); command.Parameters.AddWithValue("@ID", aID); command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_pBanco"; SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { int ID = (int)(reader["ID"]); string Nombre = (string)(reader["Nombre"]); string Ubicacion = (string)(reader["Ubicacion"]); BancoModel = new BancoModel { Id = ID, Nombre = Nombre, Ubicacion = Ubicacion, }; } } } return(BancoModel); } catch (Exception) { return(null); } }
/// <summary> /// Updates a record to the BancoModel table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Update(BancoModel aBancoModel, int ID_user) { try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlTransaction sqlTran = connection.BeginTransaction(); SqlCommand command = connection.CreateCommand(); command.Transaction = sqlTran; command.Parameters.AddWithValue("@pMode", 5); command.Parameters.AddWithValue("@ID_user", ID_user); command.Parameters.AddWithValue("@ID", aBancoModel.Id); command.Parameters.AddWithValue("@Nombre", aBancoModel.Nombre); command.Parameters.AddWithValue("@Ubicacion", aBancoModel.Ubicacion); command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_pBanco"; int afectados = command.ExecuteNonQuery(); // Commit the transaction. sqlTran.Commit(); connection.Close(); connection.Dispose(); if (afectados > 0) { return(true); } else { return(false); } } } catch (Exception) { return(false); } }
public ActionResult Edit(BancoModel bancoModel) { BancoAppContext context = HttpContext.RequestServices.GetService(typeof(BancoApp.Models.BancoAppContext)) as BancoAppContext; MySqlConnection conn = context.GetConnection(); conn.Open(); string sqlquery = "Update Banco SET Nombre=@Nombre, Direccion=@Direccion, FechaRegistro=@FechaRegistro WHERE idBanco=@IdBanco"; MySqlCommand cmd = new MySqlCommand(sqlquery, conn); cmd.Parameters.AddWithValue("@IdBanco", bancoModel.IdBanco); cmd.Parameters.AddWithValue("@Nombre", bancoModel.Nombre); cmd.Parameters.AddWithValue("@Direccion", bancoModel.Direccion); cmd.Parameters.AddWithValue("@FechaRegistro", bancoModel.FechaRegistro); cmd.ExecuteNonQuery(); conn.Close(); return(RedirectToAction("Index")); }
public ActionResult Create(BancoModel bancoModel) { BancoAppContext context = HttpContext.RequestServices.GetService(typeof(BancoApp.Models.BancoAppContext)) as BancoAppContext; MySqlConnection conn = context.GetConnection(); conn.Open(); string sqlquery = "INSERT Into Banco (nombre, direccion, fechaRegistro)VALUES (@Nombre, @Direccion, @FechaRegistro)"; MySqlCommand cmd = new MySqlCommand(sqlquery, conn); //cmd.Parameters.AddWithValue("@IdBanco", bancoModel.IdBanco); cmd.Parameters.AddWithValue("@Nombre", bancoModel.Nombre); cmd.Parameters.AddWithValue("@Direccion", bancoModel.Direccion); cmd.Parameters.AddWithValue("@FechaRegistro", bancoModel.FechaRegistro); cmd.ExecuteNonQuery(); conn.Close(); return(RedirectToAction("Index")); }
public ActionResult Agregar(BancoModel model) { try { if (ModelState.IsValid) { using (CPMEntities datos = new CPMEntities()) { datos.sp_AgregarBanco(model.Nombre, model.Telefono, model.Correo); } return(Redirect("~/Banco/")); } return(View(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public JsonResult Guardar(BancoModel model) { var rm = new ResponseModel(); if (!ModelState.IsValid) { rm.message = "Hubo un problema verifique sus datos e intente de nuevo."; rm.message += ExtensionMethods.GetAllErrorsFromModelState(this); return(Json(rm, JsonRequestBehavior.AllowGet)); } using (ArtexConnection db = new ArtexConnection()) { BancoDAO dao = new BancoDAO(); var entity = dao.GetById(model.Id, db); if (entity == null) { entity = new bancos(); entity.NOMBRE = model.Nombre; entity.ACTIVO = model.Activo; db.bancos.Add(entity); } else { entity.NOMBRE = model.Nombre; entity.ACTIVO = model.Activo; } if (db.SaveChanges() > 0 || db.Entry(entity).State == EntityState.Unchanged) { rm.response = true; rm.message = "Sus datos se guardaron correctamente"; rm.function = "reload(true,'" + rm.message + "')"; } } return(Json(rm, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(Banco oBanco) { try { string sMensaje = _bancoAppService.Validar(oBanco); if (sMensaje != string.Empty) { ModelState.AddModelError("Nombre", sMensaje); BancoModel oBancoModel = Mapper.Map <Banco, BancoModel>(oBanco); return(View(oBancoModel)); } else { _bancoAppService.Agregar(oBanco); return(RedirectToAction("Index")); } } catch { return(View()); } }
/// <summary> /// Updates a record to the banco table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Editar(BancoModel aBanco, int id_user) { return(ADBancoManager.Update(aBanco, id_user)); }
/// <summary> /// Saves a record to the banco table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Crear(BancoModel aBanco, int id_user) { return(ADBancoManager.Insert(aBanco, id_user)); }
public bool Crear(BancoModel aBanco) { return(ADBancoManager.Insert(aBanco)); }
public bool Editar(BancoModel aBanco) { return(ADBancoManager.Update(aBanco)); }
public bool Banco_Editar(BancoModel aBanco) { return(BLBanco.Editar(aBanco)); }