コード例 #1
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            var xArchivo = @"c:\ErpBapSoftNet_Config\BapConfig.cfg";

            if (File.Exists(xArchivo))
            {
                System.IO.File.Delete(xArchivo);
            }

            if (!File.Exists(xArchivo))
            {
                var DIR = new DirectoryInfo(@"c:\ErpBapSoftNet_Config");
                if (!DIR.Exists)
                {
                    DIR.Create();
                }
                mCfg = new ConfigXml(xArchivo, true);
                mCfg.SetValue("AdmConexion", "servername", _servername.ToString());
                mCfg.SetValue("AdmConexion", "database", _database.ToString());
                mCfg.SetValue("AdmConexion", "user", _user.ToString());
                mCfg.SetValue("AdmConexion", "password", _password.ToString());

                mCfg.SetValue("EmpConexion", "servername", _servername2.ToString());
                mCfg.SetValue("EmpConexion", "database", _database2.ToString());
                mCfg.SetValue("EmpConexion", "user", _user2.ToString());
                mCfg.SetValue("EmpConexion", "password", _password2.ToString());

                mCfg.SetValue("Paramlocal", "cajanume", cmb_ncaja.Text);
                mCfg.SetValue("Paramlocal", "perimes", perimes.Text);

                mCfg.Save();
                MessageBox.Show("Registro Modificado ...!!!");
                _bloqueo(false);
                var frm = new MainMercaderia();
                frm.StatusBar();
            }
        }
コード例 #2
0
        private void FijarParametrosLocales()
        {
            var xArchivo = @"c:\ErpBapSoftNet_Config\BapConfig.cfg";

            if (File.Exists(xArchivo))
            {
                System.IO.File.Delete(xArchivo);
            }

            if (!File.Exists(xArchivo))
            {
                var DIR = new DirectoryInfo(@"c:\ErpBapSoftNet_Config");
                if (!DIR.Exists)
                {
                    DIR.Create();
                }
                mCfg = new ConfigXml(xArchivo, true);
                mCfg.SetValue("AdmConexion", "servername", _servername.ToString());
                mCfg.SetValue("AdmConexion", "database", _database.ToString());
                mCfg.SetValue("AdmConexion", "user", _user.ToString());
                mCfg.SetValue("AdmConexion", "password", _password.ToString());

                mCfg.SetValue("EmpConexion", "servername", _servername2.ToString());
                mCfg.SetValue("EmpConexion", "database", _database2.ToString());
                mCfg.SetValue("EmpConexion", "user", _user2.ToString());
                mCfg.SetValue("EmpConexion", "password", _password2.ToString());

                mCfg.SetValue("Paramlocal", "cajanume", "01");
                //mCfg.SetValue("Paramlocal", "perimes", VariablesPublicas.perimes);
                mCfg.SetValue("Paramlocal", "perimes", perimes);

                mCfg.Save();
                MessageBox.Show("Se fijaron parametros locales por default.  Verifique ...!!!");
            }
        }
コード例 #3
0
        public String empConexion(string Empresa)
        {
            string servername = "";
            string database = "";
            string user = "";
            string password = "";
            string sconstring = "";

            XmlDocument xDoc = new XmlDocument();

            //La ruta del documento XML permite rutas relativas
            //respecto del ejecutable!
            //string xArchivo = System.IO.Directory.GetCurrentDirectory() + @"\BapConfig.cfg";
            string xArchivo = @"c:\ErpBapSoftNet_Config\BapConfig.cfg";

            if (!File.Exists(xArchivo))
            {
                DirectoryInfo DIR = new DirectoryInfo(@"c:\ErpBapSoftNet_Config");
                if (!DIR.Exists) DIR.Create();

                mCfg = new ConfigXml(xArchivo, true);
                mCfg.SetValue("AdmConexion", "servername", blf.Encrypt_CBC("ERPSERVER"));
                mCfg.SetValue("AdmConexion", "database", blf.Encrypt_CBC("bapAdmin"));
                mCfg.SetValue("AdmConexion", "user", blf.Encrypt_CBC("bapsoft")); //pieers
                mCfg.SetValue("AdmConexion", "password", blf.Encrypt_CBC("peru@09121824")); //ECuxmXuo

                mCfg.SetValue("EmpConexion", "servername", blf.Encrypt_CBC("ERPSERVER"));
                mCfg.SetValue("EmpConexion", "database", blf.Encrypt_CBC("bapEmpresa"));
                mCfg.SetValue("EmpConexion", "user", blf.Encrypt_CBC("bapsoft")); //pieers
                mCfg.SetValue("EmpConexion", "password", blf.Encrypt_CBC("peru@09121824")); //ECuxmXuo

                mCfg.Save();
            }

            xDoc.Load(xArchivo);

            XmlNodeList configuration = xDoc.GetElementsByTagName("configuration");
            XmlNodeList lista = ((XmlElement)configuration[0]).GetElementsByTagName("EmpConexion");

            foreach (XmlElement nodo in lista)
            {

                int i = 0;

                XmlNodeList nservername =
                nodo.GetElementsByTagName("servername");

                XmlNodeList ndatabase =
                nodo.GetElementsByTagName("database");

                XmlNodeList nuser =
                nodo.GetElementsByTagName("user");

                XmlNodeList npassword =
                nodo.GetElementsByTagName("password");

                servername = blf.Decrypt_CBC(nservername[i].InnerText);
                database = blf.Decrypt_CBC(ndatabase[i].InnerText);
                user = blf.Decrypt_CBC(nuser[i].InnerText);
                password = blf.Decrypt_CBC(npassword[i].InnerText);

                //Console.WriteLine("Elemento nombre ... {0} {1} {2}",
                //                             nservername[i].InnerText,
                //                             ndatabase[i].InnerText,
                //                             nuser[i++].InnerText);

            }

            sconstring = "Data Source=" + servername + ";Initial Catalog=" + database+Empresa + ";User ID=" + user + ";Password="******"";

            //Console.WriteLine("Cadena de conexion ... {0}", sconstring);
            return (sconstring);
        }