private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (txtPath.Text == string.Empty)
            {
                MessageBox.Show("请输入模板地址");
                return;
            }
            else
            {
                if (File.Exists(txtPath.Text) == false)
                {
                    MessageBox.Show("模板不存在,请重新输入模板地址");
                    return;
                }
            }
            //保存模板地址
            //写入配置.config
            XmlDocument doc = new XmlDocument();
            //获得配置文件的全路径
            string strFileName = System.AppDomain.CurrentDomain.BaseDirectory + "WES.exe.config";

            doc.Load(strFileName);

            //找出名称为“add”的所有元素
            string strKeyTemplate = "Template";

            XmlNodeList nodes = doc.GetElementsByTagName("add");

            for (int i = 0; i < nodes.Count; i++)
            {
                //获得将当前元素的key属性
                XmlAttribute att = nodes[i].Attributes["key"];
                //根据元素的第一个属性来判断当前的元素是不是目标元素
                if (att != null)
                {
                    if (att.Value == strKeyTemplate)
                    {
                        att       = nodes[i].Attributes["value"];
                        att.Value = txtPath.Text.Trim();
                    }
                }
            }
            //保存上面的修改
            doc.Save(strFileName);

            if (form != null)
            {
                form.BasicDBGetData(txtPath.Text.Trim());
            }
            this.Close();
        }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            //从型号重量数据库进入
            if (form != null)
            {
                Model.BasicDBSetting dbSetting = new Model.BasicDBSetting();
                dbSetting.strServer   = txtServer.Text.Trim();
                dbSetting.strUserName = txtUserName.Text;
                dbSetting.strUserName = txtPwd.Text;
                dbSetting.strUrl      = txtUrl.Text.Trim();
                dbSetting.strFolder   = txtFileFolder.Text.Trim();

                form.BasicDBGetData(string.Empty);
            }

            this.Close();
        }
Exemple #3
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            bool IsTest = TestServerConnect();

            if (IsTest)
            {
                SaveSerVerInfo();

                //Uri地址
                string strUrl = txtUrl.Text.Trim();
                int    index  = strUrl.LastIndexOf("?");
                strUrl = index != -1 ? strUrl.Substring(0, index) : strUrl;

                //修改WeightCenterDesignAndEstimateSoft.exe.config
                XmlDocument doc = new XmlDocument();
                //获得配置文件的全路径
                string configFile = System.AppDomain.CurrentDomain.BaseDirectory + "WeightCenterDesignAndEstimateSoft.exe.config";
                doc.Load(configFile);

                XmlNodeList nodeList = doc.SelectNodes("//applicationSettings//WeightCenterDesignAndEstimateSoft.Properties.Settings//setting//value");
                if (nodeList != null && nodeList.Count > 0)
                {
                    if (strUrl != string.Empty)
                    {
                        nodeList[0].InnerText = strUrl + ".xmlserviceHttpSoap11Endpoint/";
                        doc.Save(configFile);
                    }
                }

                //从型号重量数据库进入
                if (form != null)
                {
                    Model.BasicDBSetting dbSetting = new Model.BasicDBSetting();
                    dbSetting.strServer   = txtServer.Text.Trim();
                    dbSetting.strUserName = txtUserName.Text;
                    dbSetting.strUserName = txtPwd.Text;
                    dbSetting.strUrl      = txtUrl.Text.Trim();
                    dbSetting.strFolder   = txtFileFolder.Text.Trim();

                    form.BasicDBGetData(dbSetting);
                }

                this.Close();
            }
        }