public void Commit() { _row = sy_Usuarios.GetByPk(this._idUsuario); string encriptada = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64(this._claveNueva2); _row.Clave = encriptada; _data.sy_Usuarios.ImportRow(_row); }
//German 20110228 - Tarea 0000076 void txtConexionEncriptada_Leave(object sender, EventArgs e) { if (txtConexionEncriptada.Text.Trim() != "") { string connection = txtConexionEncriptada.Text; string desencriptada = new mz.erp.security.dll.Encryption.Symmetric().DecryptStringBase64(connection); txtConexion.Text = desencriptada; } }
private void txtConexion_Leave(object sender, System.EventArgs e) { //string connection = "User ID=sa;password=03461441874;Initial Catalog=ErpPrincipalT1;Data Source=10.1.254.100"; //string encriptada = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64( connection ); //MessageBox.Show(new mz.erp.security.dll.Encryption.Symmetric().DecryptStringBase64( "I4lho3MHyFsPUahKcMcBUg==")); if (txtConexion.Text.Trim() != "") { string connection = txtConexion.Text; string encriptada = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64(connection); txtConexionEncriptada.Text = encriptada; } }
public static bool LogInXPersona(string IdPersona, string Password) { string UserName = businessrules.sy_Usuarios.GetUsuario(IdPersona); sy_UsuariosDataset.sy_UsuariosRow _row = sy_Usuarios.GetByPk(UserName); if (_row != null) { string keyEcrypted = new mz.erp.security.dll.Encryption.Symmetric().DecryptStringBase64(_row.Clave); if (Password.CompareTo(keyEcrypted) == 0) { return(true); } } return(false); }
public void Init() { // TODO: agregar la implementación PrepararDatosImpresionComprobantes.Init //User ID=sa;password=03461441874;Initial Catalog=Prueba;Data Source=sservidor //_claveBD = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64("User ID=sa;password=gosp;Initial Catalog=ErpPrincipal2183;Data Source=sservidor"); _claveBD = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64("User ID=sa;password=gosp;Initial Catalog=erpprincipalPrueba;Data Source=Sservidor"); _claveBD = new mz.erp.security.dll.Encryption.Symmetric().DecryptStringBase64(_row.Clave); //_claveBD=_row.Clave; _idUsuario = _row.IdUsuario; if (this._taskName.CompareTo("ReestablecerContrasenia") == 0) { _enabledSetPreviousPassword = false; } }
public static bool LogIn(string UserName, string Password) { sy_UsuariosDataset.sy_UsuariosRow _row = sy_Usuarios.GetByPk(UserName); if (_row != null) { string keyEcrypted = new mz.erp.security.dll.Encryption.Symmetric().DecryptStringBase64(_row.Clave); //string keyEcrypted = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64(Password); //Console.WriteLine(keyEcrypted); if (Password.CompareTo(keyEcrypted) == 0) //if (Password.CompareTo(_row.Clave)==0 ) { _loguinOk = true; _nombre = _row.Nombre; //ARREGLAR!!!! _idConexion = 1; _idEmpresa = 1; _idPersona = _row.IdPersona; _idSucursal = Variables.GetValueLong("Debug.IdSucursal"); _password = Password; _idPuesto = Convert.ToInt32(systemframework.ApplicationConfiguration.Puesto); DataRow row = mz.erp.businessrules.sy_Puestos.GetByPk(_idPuesto); if (row != null) { _puesto = Convert.ToString(row["Descripcion"]); } else { _puesto = string.Empty; } _grupo = _row.Equipo; string perfilesSuperiores = Variables.GetValueString("Seguridad.Perfiles.PerfilesSuperiores"); _perfilesSuperioresList = mz.erp.systemframework.Util.Parse(perfilesSuperiores, ","); _cajasNivelControl = Variables.GetValueString("Cajas.Seguridad.NivelControl", _cajasNivelControl).ToUpper(); dataaccess.Variables.SetSecurity(_idEmpresa, _idSucursal, _idPerfil, _idPuesto, _idUsuario); ClaseTarea.Load(); ControllerTarea.Load(); return(_loguinOk); } } return(false); }
protected override void DumpControls() { /* * _row = sy_Usuarios.GetByPk(this._idUsuario); * string encriptada = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64( this._claveNueva2 ); * _row.Clave = encriptada; * _data.sy_Usuarios.ImportRow(_row); * * */ System.Data.DataTable tableUsuarios = _data.Tables["sy_Usuarios"]; System.Data.DataTable tableUsuariosPerfiles = _data.Tables["sy_PerfilesUsuariosEmpresas"]; System.Data.DataRow rowUsuarios = tableUsuarios.Rows[0]; rowUsuarios["IdUsuario"] = txtNombreUsuario.Text; //rowUsuarios["Clave"] = ultraTextEditor1.Text; string encriptada = new mz.erp.security.dll.Encryption.Symmetric().EncryptStringBase64(ultraTextEditor1.Text); rowUsuarios["Clave"] = encriptada; string IdPersona = Convert.ToString(mzCmbPersona.DataValue); if (IdPersona != null && !IdPersona.Equals(string.Empty)) { rowUsuarios["IdPersona"] = IdPersona; System.Data.DataRow row = mz.erp.businessrules.tsh_Personas.GetByPk(IdPersona); if (row != null) { rowUsuarios["Nombre"] = row["Nombre"]; } else { rowUsuarios["Nombre"] = txtNombreUsuario.Text; } } rowUsuarios["VencimientoClave"] = mz.erp.businessrules.Sistema.DateTime.Now; rowUsuarios["HabilitacionCuenta"] = mz.erp.businessrules.Sistema.DateTime.Now; rowUsuarios["Expiracion"] = mz.erp.businessrules.Sistema.DateTime.Now; rowUsuarios["Activo"] = chkActivo.Checked; //Viviana rowUsuarios["Equipo"] = this.equipo.Value; if (!ultraTextEditor1.Text.Equals(uteConfirmaPassword.Text)) { rowUsuarios.SetColumnError("Clave", "Las claves no coinciden"); } //if(this.State.Equals("NEW")) //{ for (int i = 0; i < perfiles.Count; i++) //por cada item { bool ok = false; Perfil p = (Perfil)perfiles[i]; if (p.Tildado) //si esta tildado --> lo agrego (si no está) { foreach (System.Data.DataRow row in tableUsuariosPerfiles.Rows) { if (row.RowState != System.Data.DataRowState.Deleted) { if ((long)row["IdPerfil"] == Convert.ToInt64(p.IdPerfil)) { row["IdUsuario"] = txtNombreUsuario.Text; ok = true; break; } } } if (!ok) { System.Data.DataRow row = mz.erp.businessrules.sy_PerfilesUsuariosEmpresas.NewRow(); row["IdUsuario"] = txtNombreUsuario.Text; row["IdPerfil"] = p.IdPerfil; row["IdEmpresa"] = Security.IdEmpresa; tableUsuariosPerfiles.LoadDataRow(row.ItemArray, false); } } else //si no esta tildado { if (p.Tildado != p.EstadoInicial) // y es distinto del estado anterior -->(borrarlo de la base) { foreach (System.Data.DataRow row in tableUsuariosPerfiles.Rows) { if (row.RowState != System.Data.DataRowState.Deleted) { string IdPerfil = Convert.ToString(row["IdPerfil"]); string IdUsuario = Convert.ToString(row["IdUsuario"]); if (p.IdPerfil == IdPerfil && txtNombreUsuario.Text == IdUsuario) { //borro la tupla row.Delete(); break; } } } } } } //} //Modifico los responsables de las secciones sy_UsuariosExDataset.tlg_ResponsablesDepositosSeccionesDataTable tableResponsablesSecciones = (sy_UsuariosExDataset.tlg_ResponsablesDepositosSeccionesDataTable)_data.Tables["tlg_ResponsablesDepositosSecciones"]; string IdUsu = (string)rowUsuarios["IdUsuario"]; foreach (TreeNode nodeD in treeViewSecciones.Nodes) { string IdDeposito = (string)idsTree[nodeD]; foreach (TreeNode nodeS in nodeD.Nodes) { string IdSeccion = (string)idsTree[nodeS]; sy_UsuariosExDataset.tlg_ResponsablesDepositosSeccionesRow rowRS = tableResponsablesSecciones.FindByIdUsuarioIdDepositoIdSeccion(IdUsu, IdDeposito, IdSeccion); if (nodeS.Checked) //si esta tildado --> lo agrego (si no está) { if (rowRS == null) { rowRS = tableResponsablesSecciones.Newtlg_ResponsablesDepositosSeccionesRow(); rowRS.IdUsuario = IdUsu; rowRS.IdDeposito = IdDeposito; rowRS.IdSeccion = IdSeccion; rowRS.Activo = true; rowRS.FechaCreacion = DateTime.Now; rowRS.IdConexionCreacion = Security.IdConexion; tableResponsablesSecciones.LoadDataRow(rowRS.ItemArray, false); } } else //si no esta tildado --> lo borro (si está) { if (rowRS != null) { rowRS.Delete(); } } } } }
protected override void FillControls() { //para levantar if (_data != null) { System.Data.DataTable tableUsuarios = _data.Tables["sy_Usuarios"]; System.Data.DataTable tableUsuariosPerfiles = _data.Tables["sy_PerfilesUsuariosEmpresas"]; System.Data.DataRow rowUsuarios = tableUsuarios.Rows[0]; _idUsuario = (string)rowUsuarios["IdUsuario"]; _nombre = (string)rowUsuarios["Nombre"]; txtNombreUsuario.Text = _idUsuario; string clave = Convert.ToString(rowUsuarios["Clave"]); if (clave != null && !clave.Equals(string.Empty)) { clave = new mz.erp.security.dll.Encryption.Symmetric().DecryptStringBase64(clave); } uteConfirmaPassword.Text = clave; ultraTextEditor1.Text = clave; chkActivo.Checked = Convert.ToBoolean(rowUsuarios["Activo"]); /*foreach(System.Data.DataRow row in tableUsuariosPerfiles.Rows)//por cadausuario * { * for(int i=0; i < perfiles.Count; i++) //por cada item * { * Perfil p = (Perfil)perfiles[i]; * p.EstadoInicial= (Convert.ToInt64(p.IdPerfil) == (long)row["IdPerfil"]); //lo tilda segun si esta o no entre los perfiles * p.Tildado = p.EstadoInicial; * } * }*/ if (this.State.Equals("EDIT")) { this.equipo.Value = rowUsuarios["Equipo"]; foreach (System.Data.DataRow row in tableUsuariosPerfiles.Rows) //por cadausuario { string IdUsuario = Convert.ToString(row["IdUsuario"]); if (_idUsuario == IdUsuario) { for (int i = 0; i < perfiles.Count; i++) //por cada item { Perfil p = (Perfil)perfiles[i]; long IdPerfil1 = (long)row["IdPerfil"]; long IdPerfil2 = Convert.ToInt64(p.IdPerfil); if (IdPerfil1 == IdPerfil2) { p.EstadoInicial = true; p.Tildado = p.EstadoInicial; } } } } for (int i = 0; i < ListaPerfiles.Items.Count; i++) { Perfil p = (Perfil)perfiles[i]; ListaPerfiles.SetSelected(i, true); ListaPerfiles.SetItemChecked(i, p.Tildado); } //Cargo las secciones de las q son responsables _processItem = false; sy_UsuariosExDataset.tlg_ResponsablesDepositosSeccionesDataTable tableResponsablesSecciones = (sy_UsuariosExDataset.tlg_ResponsablesDepositosSeccionesDataTable)_data.Tables["tlg_ResponsablesDepositosSecciones"]; foreach (sy_UsuariosExDataset.tlg_ResponsablesDepositosSeccionesRow rowRS in tableResponsablesSecciones.Rows) { string IdSeccion = rowRS.IdSeccion; TreeNode nodeS = (TreeNode)nodesTree[IdSeccion]; foreach (TreeNode node in treeViewSecciones.Nodes) { int index = node.Nodes.IndexOf(nodeS); if (index != -1) { node.Nodes[index].Checked = true; } } } //si todas las secciones de un deposito estan seleccionadas selecciono el deposito this.seleccionarDeposito(); _processItem = true; } mzCmbPersona.DataValue = (string)rowUsuarios["IdPersona"]; this.ListaPerfiles.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.ListaPerfiles_ItemCheck); treeViewSecciones.AfterCheck += new TreeViewEventHandler(treeViewSecciones_AfterCheck); if (this.State.Equals("EDIT")) //Si es modificacion solo el propio usuario puede editar su contraseña. { ultraTextEditor1.Enabled = Security.IdUsuario.Equals(_idUsuario); uteConfirmaPassword.Enabled = Security.IdUsuario.Equals(_idUsuario); } else //Si es alta se puede ingresar una contraseña para el usuario q se esta creando solo si la variable asi lo indica. { ultraTextEditor1.Enabled = Variables.GetValueBool("Usuarios.Editar.Password"); uteConfirmaPassword.Enabled = Variables.GetValueBool("Usuarios.Editar.Password"); } mzCmbPersona.Enabled = Variables.GetValueBool("Usuarios.Editar.Persona"); txtNombreUsuario.Enabled = Variables.GetValueBool("Usuarios.Editar.NombreDeUsuario"); chkActivo.Enabled = Variables.GetValueBool("Usuarios.Editar.Activo"); equipo.Enabled = Variables.GetValueBool("Usuarios.Editar.Equipo"); ListaPerfiles.Enabled = Variables.GetValueBool("Usuarios.Editar.Perfiles"); treeViewSecciones.Enabled = Variables.GetValueBool("Usuarios.Editar.DepositosSecciones"); //Visibiliza y habilita las solapas de acuerdo a lo configurado en las variabes ultraExplorerBar1.Groups[0].Key = "DatosGenerales"; foreach (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarGroup grupo in this.ultraExplorerBar1.Groups) { grupo.Visible = false; grupo.Container.Enabled = false; } string contenedoresVisibles = Variables.GetValueString("Usuarios.ContenedoresVisibles"); if (!contenedoresVisibles.Equals(string.Empty)) { ArrayList cont = mz.erp.systemframework.Util.Parse(contenedoresVisibles, ","); foreach (string grupo in cont) { if (this.ultraExplorerBar1.Groups.Exists(grupo)) { this.ultraExplorerBar1.Groups[grupo].Visible = true; } } } string contenedoresHabilitados = Variables.GetValueString("Usuarios.ContenedoresHabilitados"); if (!contenedoresHabilitados.Equals(string.Empty)) { ArrayList cont = mz.erp.systemframework.Util.Parse(contenedoresHabilitados, ","); foreach (string grupo in cont) { if (this.ultraExplorerBar1.Groups.Exists(grupo)) { if (this.ultraExplorerBar1.Groups[grupo].Container != null) { this.ultraExplorerBar1.Groups[grupo].Container.Enabled = true; } this.ultraExplorerBar1.Groups[grupo].Enabled = true; } } } } }