private void CargaInicial(int id) { try { using (WsSistemaBancario.ComponenteServiceClient componente = new WsSistemaBancario.ComponenteServiceClient()) { componenteSelect = componente.Componente_ObtenerUno(id); if (componenteSelect == null) { MetroFramework.MetroMessageBox.Show(this, "Componente no encontrado!.", "Componentes.", MessageBoxButtons.OK, MessageBoxIcon.Error, 170); return; } } txtId.Text = componenteSelect.Id.ToString(); txtNombre.Text = componenteSelect.Nombre; txtDescripcion.Text = componenteSelect.Descripcion; txtCodigo.Text = componenteSelect.Codigo; chkEstado.Checked = componenteSelect.Estado; //tool strip tslCreador.Text = componenteSelect.Usuario_Creador; tslModificador.Text = componenteSelect.Usuario_Modificador == null ? "[*]" : componenteSelect.Usuario_Modificador; tslCreacion.Text = componenteSelect.Fecha_Creacion.ToString(); tslModificacion.Text = componenteSelect.Fecha_Modificacion == null?"[*]": componenteSelect.Fecha_Modificacion.ToString(); } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, "Error en cargar componentes!.", "Componentes.", MessageBoxButtons.OK, MessageBoxIcon.Error, 170); } }
private void cboModulos_SelectedIndexChanged(object sender, EventArgs e) { if (cboModulos.SelectedValue != null && cboModulos.Items.Count != 0) { int selectIndex = Convert.ToInt32(cboModulos.SelectedValue); if (selectIndex == 0) { return; } componenteSelect = componentes.Where(n => n.Id == selectIndex).FirstOrDefault(); lblPermisoSelect.Text = componenteSelect.Nombre; if (componenteSelect.Estado) { permisoEstado.BackColor = Color.Green; } else { permisoEstado.BackColor = Color.Maroon; } dtgPermisos.Rows.Clear(); var list = componentes.Where(n => n.IdPadre == selectIndex).ToList(); foreach (var item in list) { dtgPermisos.Rows.Add(item.Id, item.Nombre, item.Estado); } } else { dtgPermisos.Rows.Clear(); lblPermisoSelect.Text = string.Empty; permisoEstado.BackColor = Color.Black; } }
public ActivarPersonas(ComponenteModel pComponente, ISession sesion) { InitializeComponent(); this.Sesion = sesion; this.Componente = pComponente; lblTitulo.Text = "Permiso: " + Componente.Nombre; }
private void dgvComponentes_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex >= 0) { if (this.dgvPermisos.Columns[e.ColumnIndex].Name == "Editar") { string nombreComponente = dgvPermisos.Rows[e.RowIndex].Cells["Nombre"].Value.ToString(); componenteActualizar = (from a in componentes_list where a.Nombre == nombreComponente select a).FirstOrDefault(); frmAgregarPermiso p = new frmAgregarPermiso(true, componenteActualizar); p.ShowDialog(); Listar_Componentes(); } if (this.dgvPermisos.Columns[e.ColumnIndex].Name == "Eliminar") { MessageBox.Show("Eliminar"); } if (this.dgvPermisos.Columns[e.ColumnIndex].Name == "Estado") { DataGridViewCheckBoxCell chk = this.dgvPermisos.Rows[e.RowIndex].Cells["Estado"] as DataGridViewCheckBoxCell; if (chk.Value == chk.TrueValue) { chk.Value = chk.FalseValue; MessageBox.Show("Check"); } else { chk.Value = chk.TrueValue; MessageBox.Show("No check"); } } } }
public ActivarRoles(ComponenteModel pComp, ISession sesion) { InitializeComponent(); this.Componente = pComp; this.Sesion = sesion; lblTitulo.Text = "Componente: " + Componente.Descripcion; }
public ActionResult Delete(int id) { HttpResponseMessage risposta = GlobalVariables.WebApiClient.DeleteAsync("Componenti/" + id.ToString()).Result; ComponenteModel componente = risposta.Content.ReadAsAsync <ComponenteModel>().Result; return(RedirectToAction("Show", "Carrelli", new { id = componente.CarrelloID })); }
public void Agregar() { try { using (WsSistemaBancario.ComponenteServiceClient componente = new WsSistemaBancario.ComponenteServiceClient()) { ComponenteModel nuevoComponente = new ComponenteModel { Nombre = txtNombe.Text, Codigo = txtCodigo.Text, Descripcion = txtDescripcion.Text, Id_aplicacion = 1, Estado = (checkEstado.Checked) ? true : false, }; if (checkPadre.Checked) { nuevoComponente.IdPadre = null; } else { nuevoComponente.IdPadre = (int)cmbPadre.SelectedIndex; } if (!(componente.Componente_Crear(nuevoComponente, 8))) { MessageBox.Show("Error al registrar Dato"); } } } catch (Exception) { } }
public frmAgregarPermiso(bool editar, ComponenteModel componente = null) { InitializeComponent(); llenarCombo(); if (editar) { lblTitulo.Text = "Editar Permiso"; btnAgregar.Text = "Actualizar"; this._componente = componente; this._editar = editar; txtNombe.Text = componente.Nombre; txtDescripcion.Text = componente.Descripcion; txtCodigo.Text = componente.Codigo; txtNombe.Text = componente.Nombre; checkEstado.Checked = componente.Estado; if (componente.IdPadre == null) { checkPadre.Checked = true; cmbPadre.SelectedIndex = 1; } else { checkPadre.Checked = false; cmbPadre.SelectedIndex = (int)componente.IdPadre; } } else { lblTitulo.Text = "Agregar Permiso"; btnAgregar.Text = "Agregar +"; } }
/// <summary> /// Selects the Single object of ComponenteModel table. /// </summary> public ComponenteModel GetComponenteModel(int aId) { ComponenteModel ComponenteModel = 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_tComponente"; SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { int Id = (int)(reader["Id"]); string Nombre = (string)(reader["Nombre"]); string Descripcion = (string)(reader["Descripcion"]); int? Id_aplicacion = reader["Id_aplicacion"] as int?; bool Estado = (bool)(reader["Estado"]); string Codigo = (string)(reader["Codigo"]); int? IdPadre = reader["IdPadre"] as int?; ComponenteModel = new ComponenteModel { Id = Id, Nombre = Nombre, Descripcion = Descripcion, Id_aplicacion = Id_aplicacion, Estado = Estado, Codigo = Codigo, IdPadre = IdPadre, }; } } } return(ComponenteModel); } catch (Exception) { return(null); } }
/////////////////////// public List <ComponenteModel> GetComponentesRol(int aRol) { List <ComponenteModel> ComponenteModellist = new List <ComponenteModel>(); try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlCommand command = connection.CreateCommand(); command.Parameters.AddWithValue("@IdRol", aRol); command.CommandType = CommandType.StoredProcedure; command.CommandText = "PermisosUsuarioSelectByIdRol"; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ComponenteModel oRow = new ComponenteModel(); oRow.Id = (int)(reader["Id"]); oRow.Nombre = reader["Nombre"] == DBNull.Value ? null : (string)reader["Nombre"]; oRow.Codigo = reader["Codigo"] == DBNull.Value ? null : (string)reader["Codigo"]; oRow.Descripcion = reader["Descripcion"] == DBNull.Value ? null : (string)reader["Descripcion"]; oRow.Estado = reader["Estado"] == DBNull.Value ? false : Convert.ToInt16(reader["Estado"]) == 1 ? true : false; oRow.IdPadre = reader["IdPadre"] == DBNull.Value ? null : (int?)Convert.ToInt32(reader["IdPadre"]); //oRow.Usuario_creador = reader["USUARIO_CREADOR"] == DBNull.Value ? null : (string)reader["USUARIO_CREADOR"]; //oRow.Usuario_modificador = reader["USUARIO_MODIFICADOR"] == DBNull.Value ? null : (string)reader["USUARIO_MODIFICADOR"]; //oRow.Fecha_creacion = (DateTime)reader["FECHA_CREACION"]; //oRow.Fecha_modificacion = reader["FECHA_MODIFICACION"] == DBNull.Value ? null : reader["FECHA_MODIFICACION"] as DateTime?; ComponenteModellist.Add(oRow); } } return(ComponenteModellist); } catch (SqlException ex) { daLogError daerror = new daLogError(); var e = new LogErrorModel("", "No se pudo obtener componentes ", TipoOperacion.Select, "Capa datos", ex, ex.Number); daerror.InsertarError(e); } catch (Exception ex) { daLogError daerror = new daLogError(); var e = new LogErrorModel("", "No se pudo obtener componentes ", TipoOperacion.Select, "Capa datos", ex); daerror.InsertarError(e); } return(null); }
/// <summary> /// Saves a record to the ComponenteModel table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Insert(ComponenteModel aComponenteModel, 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", aComponenteModel.Nombre); command.Parameters.AddWithValue("@Descripcion", aComponenteModel.Descripcion); command.Parameters.AddWithValue("@Id_aplicacion", aComponenteModel.Id_aplicacion == null ? (object)DBNull.Value : aComponenteModel.Id_aplicacion); command.Parameters.AddWithValue("@Estado", aComponenteModel.Estado); command.Parameters.AddWithValue("@Codigo", aComponenteModel.Codigo); command.Parameters.AddWithValue("@IdPadre", aComponenteModel.IdPadre == null ? (object)DBNull.Value : aComponenteModel.IdPadre); SqlParameter paramId = new SqlParameter("@IDENTITY", SqlDbType.Int); paramId.Direction = ParameterDirection.Output; command.Parameters.Add(paramId); command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_tComponente"; 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); } }
/// <summary> /// Updates a record to the ComponenteModel table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Update(ComponenteModel aComponenteModel) { try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlTransaction sqlTran = connection.BeginTransaction(); SqlCommand command = connection.CreateCommand(); command.Transaction = sqlTran; command.Parameters.AddWithValue("@Id", aComponenteModel.Id); command.Parameters.AddWithValue("@Nombre", aComponenteModel.Nombre); command.Parameters.AddWithValue("@Descripcion", aComponenteModel.Descripcion); command.Parameters.AddWithValue("@Id_aplicacion", aComponenteModel.Id_aplicacion == null ? (object)DBNull.Value : aComponenteModel.Id_aplicacion); command.Parameters.AddWithValue("@Estado", aComponenteModel.Estado); command.Parameters.AddWithValue("@Codigo", aComponenteModel.Codigo); //command.Parameters.AddWithValue("@Id_ComponenteModel", aComponenteModel.Id_componente == null ? (object)DBNull.Value : aComponenteModel.Id_ComponenteModel); command.Parameters.AddWithValue("@USUARIO_CREADOR", aComponenteModel.Usuario_creador); command.Parameters.AddWithValue("@FECHA_CREACION", aComponenteModel.Fecha_creacion); command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", aComponenteModel.Usuario_modificador == null ? (object)DBNull.Value : aComponenteModel.Usuario_modificador); command.Parameters.AddWithValue("@FECHA_MODIFICACION", aComponenteModel.Fecha_modificacion == null ? (object)DBNull.Value : aComponenteModel.Fecha_modificacion); command.CommandType = CommandType.StoredProcedure; command.CommandText = "ComponenteModelUpdate"; 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 List <ComponenteModel> ObtenerTodosComponentes() { List <ComponenteModel> ComponenteModellist = new List <ComponenteModel>(); try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.Parameters.Clear(); command.CommandText = "ComponentesSelectAll"; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ComponenteModel oRow = new ComponenteModel(); oRow.Id = Convert.ToInt32((reader["Id"])); oRow.Nombre = (reader["Nombre"] == DBNull.Value ? null : reader["Nombre"].ToString()); oRow.Descripcion = (reader["Descripcion"] == DBNull.Value ? null : reader["Descripcion"].ToString()); oRow.Codigo = (reader["Codigo"] == DBNull.Value ? null : reader["Codigo"].ToString()); oRow.IdPadre = (reader["IdPadre"] == DBNull.Value ? null : (int?)Convert.ToInt32(reader["IdPadre"])); oRow.Estado = (reader["Estado"] == DBNull.Value ? false : Convert.ToInt16(reader["Estado"]) == 1 ? true : false); ComponenteModellist.Add(oRow); } } return(ComponenteModellist); } catch (SqlException ex) { daLogError daerror = new daLogError(); var e = new LogErrorModel("", "No se pudo obtener componentes ", TipoOperacion.Select, "Capa datos", ex, ex.Number); daerror.InsertarError(e); } catch (Exception ex) { daLogError daerror = new daLogError(); var e = new LogErrorModel("", "No se pudo obtener componentes ", TipoOperacion.Select, "Capa datos", ex); daerror.InsertarError(e); } return(null); }
public ActionResult AddOrEdit(int id = 0, int carrelloId = 0) { ComponenteModel cm = new ComponenteModel("", "", "", carrelloId); if (id == 0) { return(View(cm)); } else { HttpResponseMessage risposta = GlobalVariables.WebApiClient.GetAsync("Componenti/" + id.ToString()).Result; return(View(risposta.Content.ReadAsAsync <ComponenteModel>().Result)); } }
/// <summary> /// Updates a record to the ComponenteModel table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Update(ComponenteModel aComponenteModel, 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", aComponenteModel.Id); command.Parameters.AddWithValue("@Nombre", aComponenteModel.Nombre); command.Parameters.AddWithValue("@Descripcion", aComponenteModel.Descripcion); command.Parameters.AddWithValue("@Id_aplicacion", aComponenteModel.Id_aplicacion == null ? (object)DBNull.Value : aComponenteModel.Id_aplicacion); command.Parameters.AddWithValue("@Estado", aComponenteModel.Estado); command.Parameters.AddWithValue("@Codigo", aComponenteModel.Codigo); command.Parameters.AddWithValue("@IdPadre", aComponenteModel.IdPadre == null ? (object)DBNull.Value : aComponenteModel.IdPadre); command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_tComponente"; 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); } }
private void dtgPermisos_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dtgPermisos.Rows.Count != 0) { int selectIndex = Convert.ToInt32(dtgPermisos.CurrentRow.Cells[0].Value); componenteSelect = componentes.Where(n => n.Id == selectIndex).FirstOrDefault(); lblPermisoSelect.Text = componenteSelect.Nombre; if (componenteSelect.Estado) { permisoEstado.BackColor = Color.Green; } else { permisoEstado.BackColor = Color.Maroon; } } }
public ActionResult AddOrEdit(ComponenteModel componente) { if (componente.ComponenteID == 0) { HttpResponseMessage risposta = GlobalVariables.WebApiClient.PostAsJsonAsync("Componenti", componente).Result; //TempData["Risposta"] = risposta; TempData["SuccessMessage"] = "Salvato con Successo"; } else { HttpResponseMessage risposta = GlobalVariables.WebApiClient.PutAsJsonAsync("Componenti/" + componente.ComponenteID, componente).Result; TempData["SuccessMessage"] = "Modificato con Successo"; } return(RedirectToAction("Show", "Carrelli", new { id = componente.CarrelloID })); }
public bool Editar(ComponenteModel aComponente) { return(ADComponenteManager.Update(aComponente)); }
public bool Crear(ComponenteModel aComponente) { return(ADComponenteManager.Insert(aComponente)); }
public HistoricoUnityOfWork(ComponenteModel context, IServiceProvider serviceProvider) : base(context, serviceProvider) { }
public bool Componente_Editar(ComponenteModel aComponente, ref string error) { return(BLComponente.Editar(aComponente, ref error)); }
public bool Componente_Crear(ComponenteModel aComponente) { return(BLComponente.Crear(aComponente)); }
/// <summary> /// Updates a record to the componente table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Editar(ComponenteModel aComponente, ref string error) { return(ADComponenteManager.Update(aComponente, ref error)); }
/// <summary> /// Saves a record to the componente table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Crear(ComponenteModel aComponente, int id_user) { return(ADComponenteManager.Insert(aComponente, id_user)); }
public GenericUnitOfWork(ComponenteModel context, IServiceProvider serviceProvider) { _context = context; _serviceProvider = serviceProvider; }
public UsuarioUnitOfWork(ComponenteModel context, IServiceProvider serviceProvider) : base(context, serviceProvider) { }
/// <summary> /// Updates a record to the componente table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Editar(ComponenteModel aComponente, int id_user) { return(ADComponenteManager.Update(aComponente, id_user)); }
/// <summary> /// Selects the Single object of ComponenteModel table. /// </summary> public ComponenteModel GetComponenteModel(int aId) { ComponenteModel ComponenteModel = null; try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlCommand command = connection.CreateCommand(); command.Parameters.AddWithValue("@Id", aId); command.CommandType = CommandType.StoredProcedure; command.CommandText = "ComponenteModelSelect"; SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { int Id = (int)(reader["Id"]); string Nombre = (string)(reader["Nombre"]); string Descripcion = (string)(reader["Descripcion"]); int? Id_aplicacion = reader["Id_aplicacion"] as int?; bool Estado = (bool)(reader["Estado"]); string Codigo = (string)(reader["Codigo"]); int? Id_ComponenteModel = reader["Id_ComponenteModel"] as int?; string USUARIO_CREADOR = (string)(reader["USUARIO_CREADOR"]); DateTime FECHA_CREACION = (DateTime)(reader["FECHA_CREACION"]); string USUARIO_MODIFICADOR = (string)(reader["USUARIO_MODIFICADOR"]); DateTime?FECHA_MODIFICACION = reader["FECHA_MODIFICACION"] as DateTime?; ComponenteModel = new ComponenteModel { Id = Id, Nombre = Nombre, Descripcion = Descripcion, Id_aplicacion = Id_aplicacion, Estado = Estado, Codigo = Codigo, Id_componente = Id_ComponenteModel, Usuario_creador = USUARIO_CREADOR, Fecha_creacion = FECHA_CREACION, Usuario_modificador = USUARIO_MODIFICADOR, Fecha_modificacion = FECHA_MODIFICACION, }; } } } return(ComponenteModel); } catch (Exception) { return(null); } }
public bool Componente_Editar(ComponenteModel aComponente) { return(BLComponente.Editar(aComponente)); }
public bool Componente_Crear(ComponenteModel aComponente, int id_user, ref string error) { return(BLComponente.Crear(aComponente, id_user)); }