Exemplo n.º 1
0
        private void btnsaveSrc_Click(object sender, EventArgs e)
        {
            string conString = "Data Source=" + txtserverSrc.Text + ";Database=" + cbbdataSrc.Text + ";User Id=" + txtuserSrc.Text + ";Password="******"; pooling=false";

            if (!ConnectSQL.CheckConnect(conString))
            {
                MessageBox.Show("Lưu thất bại");
                return;
            }
            else
            {
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;

                XmlWriter writer = XmlWriter.Create(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\configSrc.xml", settings);

                writer.WriteStartDocument();
                writer.WriteComment("This file is generated by the program.");
                writer.WriteStartElement("Root");
                writer.WriteStartElement("LVConfig");
                writer.WriteElementString("SrcServerName", txtserverSrc.Text);
                writer.WriteElementString("SrcUserName", txtuserSrc.Text);
                writer.WriteElementString("SrcPassword", txtpassSrc.Text);
                writer.WriteElementString("SrcDatabase", cbbdataSrc.Text);
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
                MessageBox.Show("Lưu thành công");
            }
        }
Exemplo n.º 2
0
        private void btnnext_Click(object sender, EventArgs e)
        {
            try
            {
                string conString = "Data Source=" + txtserver.Text + ";Database=" + cbbDatabase.Text + ";User Id=" + txtUsername.Text + ";Password="******"; pooling=false";

                if (!ConnectSQL.CheckConnect(conString))
                {
                    MessageBox.Show("Connect Fail");
                    return;
                }
                else
                {
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;

                    XmlWriter writer = XmlWriter.Create(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\configDsc.xml", settings);

                    writer.WriteStartDocument();
                    writer.WriteComment("This file is generated by the program.");
                    writer.WriteStartElement("Root");
                    writer.WriteStartElement("LVConfig");
                    writer.WriteElementString("ServerName", txtserver.Text);
                    writer.WriteElementString("UserName", txtUsername.Text);
                    writer.WriteElementString("Password", txtPassword.Text);
                    writer.WriteElementString("Database", cbbDatabase.Text);
                    writer.WriteElementString("ChkSave", chkSavepass.Checked.ToString());
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                    writer.Flush();
                    writer.Close();

                    ListTable frmTbl = new ListTable();
                    Hide();
                    frmTbl.Show();
                }
            }
            catch (Exception es)
            {
                MessageBox.Show("Connect Fail!");
            }
        }