private void btnGrabar_Click(object sender, System.EventArgs e) { try { Cursor = Cursors.WaitCursor; if (!ValidarIngreso()) { ProfileBL objBL_Perfil = new ProfileBL(); ProfileBE objPerfil = new ProfileBE(); objPerfil.IdProfile = IdProfile; objPerfil.NameProfile = txtDescripcion.Text; objPerfil.FlagState = chkEstado.Checked; objPerfil.Login = Parametros.strUsuarioLogin; objPerfil.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objPerfil.IdCompany = Parametros.intEmpresaId; if (pOperacion == Operacion.Nuevo) objBL_Perfil.Inserta(objPerfil, pListaAccess); else objBL_Perfil.Actualiza(objPerfil, pListaAccess); this.Close(); } } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void tlbMenu_DeleteClick() { try { Cursor = Cursors.WaitCursor; if (XtraMessageBox.Show("Be sure to delete the record?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (!ValidarIngreso()) { ProfileBE objE_Perfil = new ProfileBE(); objE_Perfil.IdProfile = int.Parse(gvPerfil.GetFocusedRowCellValue("IdProfile").ToString()); objE_Perfil.Login = Parametros.strUsuarioLogin; objE_Perfil.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objE_Perfil.IdCompany = Parametros.intEmpresaId; ProfileBL objBL_Perfil = new ProfileBL(); objBL_Perfil.Elimina(objE_Perfil); XtraMessageBox.Show("The record was successfully deleted.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); Cargar(); } } Cursor = Cursors.Default; } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Elimina(ProfileBE pItem) { try { ProfileDL Profile = new ProfileDL(); Profile.Elimina(pItem); } catch (Exception ex) { throw ex; } }
public void Elimina(ProfileBE pItem) { Database db = DatabaseFactory.CreateDatabase("cnERPBD"); DbCommand dbCommand = db.GetStoredProcCommand("usp_Profile_Elimina"); db.AddInParameter(dbCommand, "pIdProfile", DbType.Int32, pItem.IdProfile); db.AddInParameter(dbCommand, "pLogin", DbType.String, pItem.Login); db.AddInParameter(dbCommand, "pMachine", DbType.String, pItem.Machine); db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany); db.ExecuteNonQuery(dbCommand); }
public void Inserta(ProfileBE pItem, List <AccessBE> pListaAccess) { try { using (TransactionScope ts = new TransactionScope()) { ProfileDL objProfile = new ProfileDL(); AccessDL objAccess = new AccessDL(); Int32 intIdProfile = 0; intIdProfile = objProfile.Inserta(pItem); foreach (AccessBE item in pListaAccess) { if (item.TipOper == Convert.ToInt32(Operacion.Nuevo)) //Nuevo { item.IdProfile = intIdProfile; item.Login = pItem.Login; item.Machine = pItem.Machine; item.IdCompany = pItem.IdCompany; objAccess.Inserta(item); } if (item.TipOper == Convert.ToInt32(Operacion.Modificar)) //Modificar { item.Login = pItem.Login; item.Machine = pItem.Machine; item.IdCompany = pItem.IdCompany; objAccess.Actualiza(item); } if (item.TipOper == Convert.ToInt32(Operacion.Eliminar)) //Eliminar { item.Login = pItem.Login; item.Machine = pItem.Machine; item.IdCompany = pItem.IdCompany; objAccess.Elimina(item); } } ts.Complete(); } } catch (Exception ex) { throw ex; } }
public Int32 Inserta(ProfileBE pItem) { Int32 intIdProfile = 0; Database db = DatabaseFactory.CreateDatabase("cnERPBD"); DbCommand dbCommand = db.GetStoredProcCommand("usp_Profile_Inserta"); db.AddOutParameter(dbCommand, "pIdProfile", DbType.Int32, pItem.IdProfile); db.AddInParameter(dbCommand, "pNameProfile", DbType.String, pItem.NameProfile); db.AddInParameter(dbCommand, "pFlagState", DbType.Boolean, pItem.FlagState); db.AddInParameter(dbCommand, "pLogin", DbType.String, pItem.Login); db.AddInParameter(dbCommand, "pMachine", DbType.String, pItem.Machine); db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany); db.ExecuteNonQuery(dbCommand); intIdProfile = (int)db.GetParameterValue(dbCommand, "pIdProfile"); return(intIdProfile); }
public List <ProfileBE> ListaTodosActivo() { Database db = DatabaseFactory.CreateDatabase("cnERPBD"); DbCommand dbCommand = db.GetStoredProcCommand("usp_Profile_ListaTodosActivo"); IDataReader reader = db.ExecuteReader(dbCommand); List <ProfileBE> Profilelist = new List <ProfileBE>(); ProfileBE Profile; while (reader.Read()) { Profile = new ProfileBE(); Profile.IdProfile = Int32.Parse(reader["idProfile"].ToString()); Profile.NameProfile = reader["NameProfile"].ToString(); Profile.FlagState = Boolean.Parse(reader["FlagState"].ToString()); Profilelist.Add(Profile); } reader.Close(); reader.Dispose(); return(Profilelist); }
public ProfileBE Selecciona(int idProfile) { Database db = DatabaseFactory.CreateDatabase("cnERPBD"); DbCommand dbCommand = db.GetStoredProcCommand("usp_Profile_Selecciona"); db.AddInParameter(dbCommand, "pidProfile", DbType.Int32, idProfile); IDataReader reader = db.ExecuteReader(dbCommand); ProfileBE Profile = null; while (reader.Read()) { Profile = new ProfileBE(); Profile.IdProfile = Int32.Parse(reader["idProfile"].ToString()); Profile.NameProfile = reader["NameProfile"].ToString(); Profile.FlagState = Boolean.Parse(reader["FlagState"].ToString()); } reader.Close(); reader.Dispose(); return(Profile); }
public void InicializarModificar() { if (gvPerfil.RowCount > 0) { ProfileBE objPerfil = new ProfileBE(); objPerfil.IdProfile = int.Parse(gvPerfil.GetFocusedRowCellValue("IdProfile").ToString()); objPerfil.NameProfile = gvPerfil.GetFocusedRowCellValue("NameProfile").ToString(); objPerfil.FlagState = Convert.ToBoolean(gvPerfil.GetFocusedRowCellValue("FlagState").ToString()); frmManPerfilEdit objManPerfilEdit = new frmManPerfilEdit(); objManPerfilEdit.pOperacion = frmManPerfilEdit.Operacion.Modificar; objManPerfilEdit.IdProfile = objPerfil.IdProfile; objManPerfilEdit.pPerfilBE = objPerfil; objManPerfilEdit.StartPosition = FormStartPosition.CenterParent; objManPerfilEdit.ShowDialog(); Cargar(); } else { MessageBox.Show("Could not edit"); } }