Beispiel #1
0
 /// <summary>
 /// 测试连接
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void 测试链接_Click(object sender, EventArgs e)
 {
     try
     {
         string sqls = string.Empty;
         // 获取用户选择控件
         foreach (Control c in 数据模式_数据类型.Controls)
         {
             if (c is RadioButton && ((RadioButton)c).Checked == true)
             {
                 sqls = ((RadioButton)c).Name;
             }
         }
         if (string.IsNullOrWhiteSpace(数据库ID_Value.Text) || string.IsNullOrWhiteSpace(用户名_Value.Text) || string.IsNullOrWhiteSpace(密码_Value.Text) || string.IsNullOrWhiteSpace(库_Value.Text))
         {
             MessageCommon.ShowInf("数据链接信息不能为空!");
             return;
         }
         SqlHelper sqlHelper = sqlHelper = new SqlHelper(数据库ID_Value.Text, 用户名_Value.Text, 密码_Value.Text, 库_Value.Text, sqls);
         if (sqlHelper.SqlTestLink())
         {
             MessageCommon.ShowInf("连接成功!");
         }
         else
         {
             MessageCommon.ShowInf("连接失败!");
         }
     }
     catch (Exception ex)
     {
         MessageCommon.ShowInf("连接失败!");
     }
 }
Beispiel #2
0
        private void 导出_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(数据模式_保存位置.Text))
            {
                MessageCommon.ShowErr("保存路径不能为空!");
                return;
            }
            string files = string.Empty;

            // 获取用户选择控件
            foreach (Control c in 数据模式_文件类型.Controls)
            {
                if (c is RadioButton && ((RadioButton)c).Checked == true)
                {
                    files = ((RadioButton)c).Name;
                }
            }
            if (sqlData.ExportFile(数据模式_保存位置.Text, files))
            {
                MessageCommon.ShowInf("导出成功!");
            }
            else
            {
                MessageCommon.ShowInf("导出失败!");
            }
        }
Beispiel #3
0
        /// <summary>
        /// 保存用户账号数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 记住账号_CheckedChanged(object sender, EventArgs e)
        {
            var mi = (CheckBox)sender;

            if (mi.Checked)
            {
                // 判断是否重复数据
                var cous = sqlUserDtos.Where(m => m.Server == 数据库ID_Value.Text && m.DataBase == 数据库ID_Value.SelectedValue.ToString());
                if (cous.Count() > 0)
                {
                    MessageCommon.ShowInf("重复用户数据!");
                    return;
                }
                #region 添加新地址
                SqlUserDto sqlUsers = new SqlUserDto();
                sqlUsers.Server   = 数据库ID_Value.Text;
                sqlUsers.DataBase = 库_Value.Text;
                sqlUsers.Uid      = 用户名_Value.Text;
                sqlUsers.Pwd      = EncryptionCommon.Encryption(密码_Value.Text);
                sqlUserDtos.Add(sqlUsers);
                #endregion
                JsonUtilities jsonUtilities = new JsonUtilities();
                // 转换json
                string json = jsonUtilities.JsonString <SqlUserDto>(sqlUserDtos);
                jsonUtilities.WipeFileContent(@"../../SqlUser.json", json);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Xml转Excel操作
        /// </summary>
        private void XmlToExcels()
        {
            XmlUtilities xmlUtilities = new XmlUtilities();
            var          data         = xmlUtilities.ConvertXMLToDataSet(文件路径.Text);

            if (data != null && data.Rows.Count > 0)
            {
                ExcelUtilities excelUtilities = new ExcelUtilities();
                if (excelUtilities.ToExcel(data, 文件夹路径.Text))
                {
                    MessageCommon.ShowInf("转换成功");
                }
                else
                {
                    MessageCommon.ShowErr("转换失败");
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// json转Excel操作
        /// </summary>
        private void JsonToExcels()
        {
            JsonUtilities jsonUtilities = new JsonUtilities();
            var           dataTale      = jsonUtilities.JsonToData(文件路径.Text);

            if (dataTale != null && dataTale.Rows.Count > 0)
            {
                ExcelUtilities excelUtilities = new ExcelUtilities();
                if (excelUtilities.ToExcel(dataTale, 文件夹路径.Text))
                {
                    MessageCommon.ShowInf("转换成功");
                }
                else
                {
                    MessageCommon.ShowErr("转换失败");
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Excel转Json操作
        /// </summary>
        private void ExcelToXmls()
        {
            ExcelUtilities excelUtilities = new ExcelUtilities();
            var            data           = excelUtilities.ExcelToDataTable(文件路径.Text);

            if (data != null && data.Rows.Count > 0)
            {
                XmlUtilities xmlUtilities = new XmlUtilities();
                string       xml          = xmlUtilities.ConvertDataTableToXML(data);
                if (xmlUtilities.SaveXml(xml, 文件夹路径.Text))
                {
                    MessageCommon.ShowInf("转换成功");
                }
                else
                {
                    MessageCommon.ShowErr("转换失败");
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Excel转Json操作
        /// </summary>
        private void ExcelToJsons()
        {
            ExcelUtilities excelUtilities = new ExcelUtilities();
            var            data           = excelUtilities.ExcelToDataTable(文件路径.Text);

            if (data != null && data.Rows.Count > 0)
            {
                JsonUtilities jsonUtilities = new JsonUtilities();
                jsonUtilities.SaveJson(data, 文件夹路径.Text);
                if (jsonUtilities.SaveJson(data, 文件夹路径.Text))
                {
                    MessageCommon.ShowInf("转换成功");
                }
                else
                {
                    MessageCommon.ShowErr("转换失败");
                }
            }
        }