Exemple #1
0
        private void CmdAceptar_Click(object sender, EventArgs e)
        {
            CLNBTN_Qy Query           = null;
            CLNBTN_Es Encrip          = new CLNBTN_Es(_st_User, _st_FileLog, _st_Lic);
            CLNBTN_Ul Utils           = new CLNBTN_Ul(_st_User, _st_FileLog, _st_Lic);
            Boolean   blL_ValidaClave = false;
            String    stL_Encrip      = "";
            int       inL_DiasClave   = 0;

            try
            {
                //
                LblMensaje.Text  = "";
                inPr_NumIntentos = inPr_NumIntentos + 1;
                if (inPr_NumIntentos > MAX_INTENTOS)
                {
                    LblMensaje.Text = MENSAJE_3;
                }
                else
                {
                    //
                    switch (ObjPr_InfoBD.get_DataBaseConn_Type())
                    {
                    case CLNBTN_IQy.inConnect_Type.TYPE_1_CONNECT_USER_SQL:
                        //
                        blL_ValidaClave = true;
                        break;

                    case CLNBTN_IQy.inConnect_Type.TYPE_4_CONNECT_USER_INFO_EXT:
                        //
                        blL_ValidaClave = true;
                        break;
                    }
                    if (blL_ValidaClave)
                    { // del if ( blL_ValidaClave )
                        // Asigna informacion
                        Query = new CLNBTN_Qy(_st_User, _st_FileLog, _st_Lic);
                        //
                        // Hace la conexion
                        Query.setDataBaseInfo(ObjPr_InfoBD);
                        Query.ConnectDataBase();
                        //
                        if (Query.getIs_Connected())
                        {
                            blL_ValidaClave = false;
                            if (ObjPr_InfoBD.getUserApp_PWD().Length == 0)
                            {
                                blL_ValidaClave = true;
                            }
                            else
                            {
                                if (ObjPr_InfoBD.getUserApp_PWD() == TxtClave.Text)
                                {
                                    blL_ValidaClave = true;
                                }
                                else
                                {
                                    LblMensaje.Text = MENSAJE_18;
                                }
                            }
                            if (blL_ValidaClave)
                            {
                                blL_ValidaClave = false;
                                if (TxtClave1.Text == TxtClave2.Text)
                                {
                                    if (TxtClave.Text == TxtClave1.Text)
                                    {
                                        LblMensaje.Text = MENSAJE_20;
                                    }
                                    else
                                    {
                                        blL_ValidaClave = true;
                                    }
                                }
                                else
                                {
                                    LblMensaje.Text = MENSAJE_19;
                                }
                            }
                            if (blL_ValidaClave)
                            {
                                // Define DataTable, para los Datos del Query
                                DataTable DatTable = null;
                                //
                                Query.ToDo_SELECT("*");
                                Query.ToDo_FROM("t00usuarios");
                                Query.ToDo_WHERE("A00USUARIOWIN", "'" + ObjPr_InfoBD.getUser() + "'");
                                Query.ToDo_EXECUTE_SQL(ref DatTable);
                                if (DatTable != null)
                                { // del if (Query.Rs.State != 0)
                                    for (int inL_Row = 0; inL_Row < DatTable.Rows.Count; inL_Row++)
                                    {
                                        // Toma la informacion de la fila
                                        DataRow Info_Fila = DatTable.Rows[inL_Row];
                                        inL_DiasClave = 0;
                                        //if (!DBNull.Value.Equals(Info_Fila["A00DIAS_CLAVE"].ToString()))
                                        //{
                                        if (Info_Fila["A00DIAS_CLAVE"].ToString().Length > 0)
                                        {
                                            inL_DiasClave = Convert.ToInt16(Info_Fila["A00DIAS_CLAVE"].ToString());
                                        }
                                        //}
                                    }
                                }
                                Query.ToDo_CLOSE();
                                //
                                stL_Encrip = Encrip.File2Es(TxtClave1.Text.Trim(), "", "FT/yQYmins06srbyMggYjcEY/ns2slWTURobdSariTY=+-6aUVQ2SZO7QHT6kUHtr2zRbupap5KPu4jeO9GE+UMnk=", "", _st_Lic);
                                Query.ToDo_UPDATE("t00usuarios");
                                Query.ToDo_SET("A00ESTADO", ESTADO_ACTIVO);
                                Query.ToDo_SET("A00CLAVE", stL_Encrip);
                                Query.ToDo_SET("A00FECHA_CLAVE", Utils.BringMeServerDate(ObjPr_InfoBD, true));
                                if (inL_DiasClave == 0)
                                {
                                    Query.ToDo_SET("A00DIAS_CLAVE", "30");
                                }
                                Query.ToDo_WHERE("A00USUARIOWIN", " '" + ObjPr_InfoBD.getUser() + "' ");
                                Query.ToDo_EXECUTE_SQL();
                                if (Query.getSuccessQueryExecution())
                                {
                                    ObjPr_InfoBD.setUserApp_PWD(TxtClave1.Text);
                                    ObjPr_InfoBD.setUserApp_PWD_Enc(stL_Encrip);
                                    MessageBox.Show(MENSAJE_21, MENSAJE_5);
                                }
                                Query.ToDo_CLOSE();
                                //
                                blPr_AceptoInformacion = true;
                                // Cierra la forma
                                this.Hide();
                            }
                        }
                    } // del if ( blL_ValidaClave )
                }
            }
            catch (System.AccessViolationException ex_0)
            {
                CLNBTN_Lg objL_Log = new CLNBTN_Lg(_st_User, _st_FileLog, _bl_OutLineConsole, _bl_OutFileLog, _bl_OutWindow);
                objL_Log.WriteOutErrorMessage(_st_Relac, _st_RelacSon, "FrmChgPwd(2). System.AccessViolationException", "", ex_0.Message.ToString());
            }
            catch (Exception ex)
            {
                CLNBTN_Lg objL_Log = new CLNBTN_Lg(_st_User, _st_FileLog, _bl_OutLineConsole, _bl_OutFileLog, _bl_OutWindow);
                objL_Log.WriteOutErrorMessage(_st_Relac, _st_RelacSon, "FrmChgPwd(2). Exception", "", ex.Message.ToString());
            }
        }
Exemple #2
0
        public void GetParam(String LicName, String WinTittle, String UserName, String LogFile, String ConfFile, String AppInfo_Name, String AppInfo_Ver, String AppInfo_Cia, String InfBdFile, String DBName4Work, ref CLNBTN_IQy Obj_BaseDeDatos, String DBSectionName = "")
        {
            // Toma los parametros.
            String stL_Aux      = "";
            String stL_Mensaje1 = "";
            String stL_Mensaje2 = "";

            CLNBTN_IQy.inDB_Types     inL_TipoBD       = 0;
            CLNBTN_IQy.inConnect_Type inL_TipoConexion = 0;
            CLNBTN_Es ObjL_Encrip = null;

            //
            try
            {
                CLNBTN_Gp ObL_Lic = new CLNBTN_Gp(LicName);
                _st_Lic = ObL_Lic.getLicName();
                if (_st_Lic.Length == 0)
                {
                    MessageBox.Show("Invalid Lic To work");
                }
                // Toma la seccion de la base de datos con la cual va a trabajar.
                stPr_Seccion_BaseDeDatos = DBSectionName;
                // Si viene vacia, toma la seccion SYS_BD_ZERO
                if (stPr_Seccion_BaseDeDatos.Length == 0)
                {
                    stPr_Seccion_BaseDeDatos = SECCION_BD_0;
                }
                // Guarda textos originales.
                stPr_Servidor_Ori = cmbServidores.Text;
                stPr_Usuario_Ori  = TxtUsuario.Text;
                stPr_Clave_Ori    = TxtClave.Text;
                //
                inPr_NumIntentos = 0;
                LblMensaje.Text  = "";
                //
                this.Text              = WinTittle;
                _st_User               = UserName;
                _st_FileLog            = LogFile;
                stPr_ArchivoConfigApp  = ConfFile;
                stPr_Archivo_InfoBds   = InfBdFile;
                stPr_NombreBd_XTrabajo = DBName4Work;
                // Crea instancia para la clase que maneja las configuraciones
                ObjPr_Conf = new CLNBTN_Cg(stPr_ArchivoConfigApp, _st_User, _st_FileLog, _st_Lic);
                //
                ObjPr_Utils = new CLNBTN_Ul(_st_User, _st_FileLog, _st_Lic);
                //
                stPr_Nombre_App        = AppInfo_Name;
                stPr_Version_App       = AppInfo_Ver;
                stPr_NombreEmpresa_App = AppInfo_Cia;
                // Coloca aplicacion y version
                this.LblModuloVersion.Text = stPr_Nombre_App + " " + stPr_Version_App;
                this.LblNombreCia.Text     = stPr_NombreEmpresa_App;
                // La informacion de la base de datos para manejar la conexion con la base de datos.
                ObjPr_InfoBD = new CLNBTN_IQy(_st_Lic);
                ObjPr_InfoBD = Obj_BaseDeDatos;
                //
                // Ejemplo del archivo de configuracion
                //       [SYS_BD_ZERO]
                //Name=Administracion
                //Engine=0
                //Security=4
                //Path=
                //URL=
                //Server=
                //IPAddress=
                //;
                ///////////////////////////////////////////////////////////////
                // Halla Informacion de la base de datos
                ///////////////////////////////////////////////////////////////
                stL_Mensaje1 = "";
                // Nombre de la base de datos.
                stL_Aux = "";
                stL_Aux = ObjPr_Conf.ReadAKeyFromSection(stPr_Seccion_BaseDeDatos, "Name");
                if (stL_Aux.Length == 0)
                {
                    stL_Mensaje1 = MENSAJE_1;
                }
                else
                {
                    ObjPr_InfoBD.setDataBaseName(stL_Aux);
                }
                // tipo de Motor de Base de Datos
                stL_Aux = "";
                stL_Aux = ObjPr_Conf.ReadAKeyFromSection(stPr_Seccion_BaseDeDatos, "Engine");
                if (stL_Aux.Length == 0)
                {
                    stL_Mensaje1 = MENSAJE_1;
                }
                else
                {
                    inL_TipoBD = (CLNBTN_IQy.inDB_Types)(Convert.ToInt32(stL_Aux));
                    //
                    ObjPr_InfoBD.setDataBaseEngine_Type(inL_TipoBD);
                }
                // Tipo de Conexion
                stL_Aux = "";
                stL_Aux = ObjPr_Conf.ReadAKeyFromSection(stPr_Seccion_BaseDeDatos, "Security");
                if (stL_Aux.Length == 0)
                {
                    stL_Mensaje1 = MENSAJE_1;
                }
                else
                {
                    inL_TipoConexion = (CLNBTN_IQy.inConnect_Type)(Convert.ToInt32(stL_Aux));
                    //
                    ObjPr_InfoBD.setDataBaseConn_Type(inL_TipoConexion);
                }
                //
                // Path de la base de datos.
                stL_Aux = "";
                stL_Aux = ObjPr_Conf.ReadAKeyFromSection(stPr_Seccion_BaseDeDatos, "Path");
                ObjPr_InfoBD.setDataBasePath(stL_Aux);
                // URL
                stL_Aux = "";
                stL_Aux = ObjPr_Conf.ReadAKeyFromSection(stPr_Seccion_BaseDeDatos, "URL");
                ObjPr_InfoBD.setServer_URL(stL_Aux);
                // Nombre de Servidor
                stL_Aux = "";
                stL_Aux = ObjPr_Conf.ReadAKeyFromSection(stPr_Seccion_BaseDeDatos, "Server");
                if (stL_Aux.Length == 0)
                {
                    //stL_Mensaje1 = MENSAJE_1;
                }
                else
                {
                    ObjPr_InfoBD.setServerName(stL_Aux);
                }
                // Ip Address
                stL_Aux = "";
                stL_Aux = ObjPr_Conf.ReadAKeyFromSection(stPr_Seccion_BaseDeDatos, "IPAddress");
                ObjPr_InfoBD.setServer_IP_Address(stL_Aux);
                //
                CmdCambiarClave.Enabled = false;
                //
                switch (ObjPr_InfoBD.get_DataBaseConn_Type())
                { // Inicio del switch (ObjPr_InfoBD.getTipoConexion())
                //
                case CLNBTN_IQy.inConnect_Type.TYPE_1_CONNECT_USER_SQL:
                    // Usuario y clave de la bd, vienen en archivo de configuraciones
                    TxtUsuario.Text = _st_User;
                    break;

                case CLNBTN_IQy.inConnect_Type.TYPE_2_CONNECT_USER_APP:
                    // Usuario de la aplicacion, mismo usuario de la base de datos
                    TxtUsuario.Text = _st_User;
                    break;

                case CLNBTN_IQy.inConnect_Type.TYPE_3_CONNECT_USER_WIN:
                    // Usuario Windows es el mismo usuario de la base de datos
                    TxtUsuario.Text         = _st_User;
                    TxtUsuario.Enabled      = false;
                    GrpClave.Visible        = false;
                    TxtClave.Text           = "";
                    CmdCambiarClave.Visible = false;
                    break;

                case CLNBTN_IQy.inConnect_Type.TYPE_4_CONNECT_USER_INFO_EXT:
                    // Conexion tipo Fenix.
                    TxtUsuario.Text = _st_User;
                    if (File.Exists(stPr_Archivo_InfoBds))
                    {
                        ObjPr_InfoBDS_Fenix = new CLNBTN_Cg(stPr_Archivo_InfoBds, _st_User, _st_FileLog, _st_Lic);
                        ObjL_Encrip         = new CLNBTN_Es(_st_User, _st_FileLog, _st_Lic);
                        // Halla y DesEncripta la informacion del servidor
                        stL_Aux = "";
                        stL_Aux = ObjPr_InfoBDS_Fenix.ReadAKeyFromSection(SECCION_BD_CONNECT_INFO, "ServerName");
                        if (stL_Aux.Length != 0)
                        {
                            stL_Aux = ObjL_Encrip.File2Des(stL_Aux, "", "FT/yQYmins06srbyMggYjcEY/ns2slWTURobdSariTY=+-6aUVQ2SZO7QHT6kUHtr2zRbupap5KPu4jeO9GE+UMnk=", "", _st_Lic);
                            ObjPr_InfoBD.setServerName(stL_Aux);
                            blPr_ServidorYaDefinido = true;
                        }
                        // Halla y DesEncripta la informacion de la base de datos
                        stL_Aux = "";
                        stL_Aux = ObjPr_InfoBDS_Fenix.ReadAKeyFromSection(SECCION_BD_CONNECT_INFO, "DBName");
                        if (stL_Aux.Length != 0)
                        {
                            stL_Aux = ObjL_Encrip.File2Des(stL_Aux, "", "FT/yQYmins06srbyMggYjcEY/ns2slWTURobdSariTY=+-6aUVQ2SZO7QHT6kUHtr2zRbupap5KPu4jeO9GE+UMnk=", "", _st_Lic);
                            ObjPr_InfoBD.setDataBaseName(stL_Aux);
                        }
                        // Halla y DesEncripta la informacion del usuario
                        stL_Aux = "";
                        stL_Aux = ObjPr_InfoBDS_Fenix.ReadAKeyFromSection(SECCION_BD_CONNECT_INFO, "UID");
                        if (stL_Aux.Length != 0)
                        {
                            stL_Aux = ObjL_Encrip.File2Des(stL_Aux, "", "FT/yQYmins06srbyMggYjcEY/ns2slWTURobdSariTY=+-6aUVQ2SZO7QHT6kUHtr2zRbupap5KPu4jeO9GE+UMnk=", "", _st_Lic);
                            ObjPr_InfoBD.setDataBase_UserID(stL_Aux);
                        }
                        // Halla y DesEncripta la informacion de la clave
                        stL_Aux = "";
                        stL_Aux = ObjPr_InfoBDS_Fenix.ReadAKeyFromSection(SECCION_BD_CONNECT_INFO, "PWDID");
                        if (stL_Aux.Length != 0)
                        {
                            stL_Aux = ObjL_Encrip.File2Des(stL_Aux, "", "FT/yQYmins06srbyMggYjcEY/ns2slWTURobdSariTY=+-6aUVQ2SZO7QHT6kUHtr2zRbupap5KPu4jeO9GE+UMnk=", "", _st_Lic);
                            ObjPr_InfoBD.setDataBase_UserPWD(stL_Aux);
                        }
                    }
                    break;

                default:
                    //
                    stL_Mensaje2 = MENSAJE_2;
                    break;
                } // Fin de switch (ObjPr_InfoBD.getTipoConexion())
                //
                if (stL_Mensaje1.Length > 0)
                {
                    LblMensaje.Text = stL_Mensaje1;
                }
                if (stL_Mensaje2.Length > 0)
                {
                    if (LblMensaje.Text.Length == 0)
                    {
                        LblMensaje.Text = stL_Mensaje2;
                    }
                    else
                    {
                        LblMensaje.Text = LblMensaje.Text + NEW_LINE + stL_Mensaje2;
                    }
                }
            }
            catch (System.AccessViolationException ex_0)
            {
                CmdCancelar.Enabled = true;
                CLNBTN_Lg objL_Log = new CLNBTN_Lg(_st_User, _st_FileLog, _bl_OutLineConsole, _bl_OutFileLog, _bl_OutWindow);
                objL_Log.WriteOutErrorMessage(_st_Relac, _st_RelacSon, "GetParam. System.AccessViolationException", "", ex_0.Message.ToString());
            }
            catch (Exception ex)
            {
                CmdCancelar.Enabled = true;
                CLNBTN_Lg objL_Log = new CLNBTN_Lg(_st_User, _st_FileLog, _bl_OutLineConsole, _bl_OutFileLog, _bl_OutWindow);
                objL_Log.WriteOutErrorMessage(_st_Relac, _st_RelacSon, "GetParam. Exception", "", ex.Message.ToString());
            }
        }
Exemple #3
0
        public void GetParam(String LicName, String WinTittle, String UserName, String LogFile, String ConfFile, String AppInfo_Name, String AppInfo_Ver, String AppInfo_Cia, ref CLNBTN_IQy Obj_BaseDeDatos)
        {
            // Toma los parametros.
            String stL_Aux = "";

            try
            {
                CLNBTN_Gp ObL_Lic = new CLNBTN_Gp(LicName);
                _st_Lic = ObL_Lic.getLicName();
                if (_st_Lic.Length == 0)
                {
                    MessageBox.Show("Invalid Lic To work");
                }
                // Guarda textos originales.
                stPr_Clave_Ori  = TxtClave.Text;
                stPr_Clave1_Ori = TxtClave1.Text;
                stPr_Clave2_Ori = TxtClave2.Text;
                //
                inPr_NumIntentos = 0;
                LblMensaje.Text  = "";
                //
                this.Text             = WinTittle;
                _st_User              = UserName;
                _st_FileLog           = LogFile;
                stPr_ArchivoConfigApp = ConfFile;
                //
                stPr_Nombre_App        = AppInfo_Name;
                stPr_Version_App       = AppInfo_Ver;
                stPr_NombreEmpresa_App = AppInfo_Cia;
                // Coloca aplicacion y version
                this.LblModuloVersion.Text = stPr_Nombre_App + " " + stPr_Version_App;
                this.LblNombreCia.Text     = stPr_NombreEmpresa_App;
                //
                // Crea instancia para la clase que maneja las configuraciones
                ObjPr_Conf = new CLNBTN_Cg(stPr_ArchivoConfigApp, _st_User, _st_FileLog, _st_Lic);
                //
                ObjPr_Utils = new CLNBTN_Ul(_st_User, _st_FileLog, _st_Lic);
                //
                // Lee el esquema de color
                stL_Aux = "";
                stL_Aux = ObjPr_Conf.ReadAKeyFromSection(SECCION_ID_APP, "Color");
                if (stL_Aux.Length == 0)
                {
                    stL_Aux = "0";
                }
                // La informacion de la base de datos para manejar la conexion con la base de datos.
                ObjPr_InfoBD = new CLNBTN_IQy(_st_Lic);
                ObjPr_InfoBD = Obj_BaseDeDatos;
                //
                if (ObjPr_InfoBD.getUserApp_PWD().Length == 0)
                {
                    GrpClave.Visible = false;
                }
                //
                HabilitaBotones();
                CmdCancelar.Enabled = true;
                //
            }
            catch (System.AccessViolationException ex_0)
            {
                CmdCancelar.Enabled = true;
                CLNBTN_Lg objL_Log = new CLNBTN_Lg(_st_User, _st_FileLog, _bl_OutLineConsole, _bl_OutFileLog, _bl_OutWindow);
                objL_Log.WriteOutErrorMessage(_st_Relac, _st_RelacSon, "GetParam. System.AccessViolationException", "", ex_0.Message.ToString());
            }
            catch (Exception ex)
            {
                CmdCancelar.Enabled = true;
                CLNBTN_Lg objL_Log = new CLNBTN_Lg(_st_User, _st_FileLog, _bl_OutLineConsole, _bl_OutFileLog, _bl_OutWindow);
                objL_Log.WriteOutErrorMessage(_st_Relac, _st_RelacSon, "GetParam. Exception", "", ex.Message.ToString());
            }
        }