Example #1
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);
            }
        }
Example #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("导出失败!");
            }
        }
Example #3
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("连接失败!");
     }
 }
Example #4
0
        /// <summary>
        /// 开始换文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 开始转换_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(文件夹路径.Text) || 文件夹路径.Text == "无" || string.IsNullOrWhiteSpace(文件路径.Text) || 文件路径.Text == "无")
            {
                MessageCommon.ShowWar("请选择文件路径!!");
            }
            var fileMode = GetFileMode();                  // 获取转换模式

            if (fileMode.FileMode == FileEnum.JsonToExcel) // json转Excel
            {
                JsonToExcels();
            }
            else if (fileMode.FileMode == FileEnum.ExcelToJson)// Excel转Json
            {
                ExcelToJsons();
            }
            else if (fileMode.FileMode == FileEnum.XMLToExcel)// Xml转Excel
            {
                XmlToExcels();
            }
            else if (fileMode.FileMode == FileEnum.ExcelToXML)// Excel转Xml
            {
                ExcelToXmls();
            }
        }
Example #5
0
 /// <summary>
 /// 导出文件
 /// </summary>
 /// <param name="fileUrl">保存位置</param>
 /// <param name="files">文件类型</param>
 public bool ExportFile(string fileUrl, string files)
 {
     if (dt == null && dt.Rows.Count > 0)
     {
         MessageCommon.ShowErr("结果集不能为空!");
     }
     if (files == FileEnum.JsonFiles)
     {
         JsonUtilities jsonUtilities = new JsonUtilities();
         return(jsonUtilities.SaveJson(dt, fileUrl));
     }
     else if (files == FileEnum.ExcelFiles)
     {
         ExcelUtilities excelUtilities = new ExcelUtilities();
         return(excelUtilities.ToExcel(dt, fileUrl));
     }
     else if (files == FileEnum.XMLFiles)
     {
         XmlUtilities xmlUtilities = new XmlUtilities();
         string       xml          = xmlUtilities.ConvertDataTableToXML(dt);
         return(xmlUtilities.SaveXml(xml, fileUrl));
     }
     else
     {
         return(false);
     }
 }
Example #6
0
        void HandleMessage(MessageCommon msg)
        {
            switch (msg.message_type)
            {
            case MessageCommon.FantasyFighterMessage.Login:
                fighter.name = (msg as FantasyLoginMessage).username;
                events(fighter.name + " connected");
                //MessageBox.Show( (msg as FantasyLoginMessage).username + " connected" );
                break;

            case MessageCommon.FantasyFighterMessage.ChangeWeapon:
                fighter.weapon = (msg as FantasyFighterWeapon).weapon;
                arena.NotifyPeers(this);
                events(fighter.name + " new weapon " + fighter.weapon);
                break;

            case MessageCommon.FantasyFighterMessage.ChangeStance:
                fighter.stance = (msg as FantasyFighterStance).stance;
                arena.NotifyPeers(this);
                events(fighter.name + " new stance " + fighter.weapon);
                break;

            case MessageCommon.FantasyFighterMessage.CreateArena:
                FantasyArena      created = FantasyArenaList.CreateArena((msg as FantasyArenaCreate).arena_name);
                FantasyArenaAdded added   = new FantasyArenaAdded(created.name);
                Byte[]            output  = added.Serialize();
                foreach (FantasyFighterPlayer player in FantasyServer.lobby_fighters)
                {
                    player.Send(output);
                }
                break;

            case MessageCommon.FantasyFighterMessage.JoinArena:
                arena = FantasyArenaList.JoinArena(this, (msg as FantasyArenaJoin).arena_name);

                {
                    FantasyFighterProtocol.FantasyArenaJoined send = new FantasyFighterProtocol.FantasyArenaJoined(arena.name);
                    Send(send.Serialize());
                }
                break;

            case MessageCommon.FantasyFighterMessage.ListArenas:
            {
                FantasyFighterProtocol.FantasyArenaList send = new FantasyFighterProtocol.FantasyArenaList(FantasyArenaList.GetNames());
                Send(send.Serialize());
            }
            break;
            }
        }
Example #7
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("转换失败");
                }
            }
        }
Example #8
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("转换失败");
                }
            }
        }
Example #9
0
        /// <summary>
        /// 打开文件
        /// </summary>
        /// <returns></returns>
        private string OpenFileDialog()
        {
            //初始化一个OpenFileDialog类
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = "c:\\";                      //默认打开路径
            //openFileDialog.Filter = "文本文件|*.txt|word文件|*.doc;*.docx|所有文件|*.*";//过滤文件格式
            openFileDialog.Filter           = GetFilter(FileClass).Filter; //过滤文件格式
            openFileDialog.FilterIndex      = 2;                           //格式索引
            openFileDialog.RestoreDirectory = false;                       //每次打卡文件是否恢复默认路径

            //判断用户是否正确的选择了文件
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //fileDialog.FileName:文件的全路径,如“C:\Users\lenovo\Desktop\新建文件夹\微信图片_20190401154431.jpg”
                //fileDialog.SafeFileName:文件的名称,如“微信图片_20190401154431.jpg”
                //----------------此处和openFileDialog1.Filter写一个即可
                //获取用户选择文件的后缀名
                string extension = Path.GetExtension(openFileDialog.FileName);
                //声明允许的后缀名
                //string[] str = new string[] { ".gif", ".jpge", ".jpg" };
                string[] str = GetFilter(FileClass).Extension;
                if (!((IList)str).Contains(extension))
                {
                    MessageCommon.ShowErr("请上传正确的文件类型!");
                }
                else
                {
                    //获取用户选择的文件,并判断文件大小不能超过20K,fileInfo.Length是以字节为单位的
                    //FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                    //if (fileInfo.Length > 20480)
                    //{
                    //    MessageBox.Show("上传的图片不能大于20K");
                    //}
                    //else
                    //{
                    //    //在这里就可以写获取到正确文件后的代码了
                    //}
                    return(openFileDialog.FileName);
                }
            }
            return(string.Empty);
        }
Example #10
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("转换失败");
                }
            }
        }
Example #11
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("转换失败");
                }
            }
        }
Example #12
0
 static void Main()
 {
     try
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Process instance = RunningInstance();
         if (instance == null)
         {
             Application.Run(new 结果集());
         }
         else
         {
             HandleRunningInstance(instance);
         }
     }
     catch (Exception ex)
     {
         MessageCommon.ShowErr("亲!程序已炸!");
         LogUtilities.Error(ex.ToString());
     }
 }
Example #13
0
        private void 查询_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(脚本语句_Value.Text))
            {
                MessageCommon.ShowErr("脚本语句不可为空!");
                return;
            }

            #region 绑定数据
            string sqls = string.Empty;
            // 获取用户选择控件
            foreach (Control c in 数据模式_数据类型.Controls)
            {
                if (c is RadioButton && ((RadioButton)c).Checked == true)
                {
                    sqls = ((RadioButton)c).Name;
                }
            }
            SqlUserDto sqlUsers = new SqlUserDto();
            sqlUsers.Server       = 数据库ID_Value.Text;
            sqlUsers.DataBase     = 库_Value.Text;
            sqlUsers.Uid          = 用户名_Value.Text;
            sqlUsers.Pwd          = 密码_Value.Text;
            sqlUsers.DatabaseType = sqls;
            #endregion
            #region 判断窗体是否已打开
            Form test = Application.OpenForms["SqlDataShow"]; //查找是否打开过about窗体 
            if ((test == null) || (test.IsDisposed))          //如果没有打开过
            {
                sqlData = new SqlDataShow();
                sqlData.BingData(脚本语句_Value.Text, sqlUsers);
                sqlData.Show();   //打开子窗体出来
            }
            else
            {
                sqlData.Activate(); //如果已经打开过就让其获得焦点  
            }
            #endregion
        }
Example #14
0
        void HandleMessage(MessageCommon msg)
        {
            switch (msg.message_type)
            {
            case MessageCommon.FantasyFighterMessage.ChangeWeapon:
            {
                FantasyFighterWeapon Msg = (FantasyFighterWeapon)msg;
                if (Msg.id == Guid.Empty)
                {
                }
                else
                {
                    FighterState fighter = arena.GetFighter(Msg.id);
                    if (fighter != null)
                    {
                        fighter.weapon = Msg.weapon;
                    }
                }
            }
            break;

            case MessageCommon.FantasyFighterMessage.ChangeStance:
            {
                FantasyFighterStance Msg = (FantasyFighterStance)msg;
                if (Msg.id == Guid.Empty)
                {
                }
                else
                {
                    FighterState fighter = arena.GetFighter(Msg.id);
                    if (fighter != null)
                    {
                        fighter.stance = Msg.stance;
                    }
                }
            }
            break;

            case MessageCommon.FantasyFighterMessage.ArenaList:
            {
                FantasyArenaList list = (FantasyArenaList)msg;
                ArenaTable.Rows.Clear();
                foreach (String s in list.arenas)
                {
                    DataRow row = ArenaTable.NewRow();
                    row["name"] = s;
                    ArenaTable.Rows.Add(row);
                }
                ArenaTable.AcceptChanges();
            }
            break;

            case MessageCommon.FantasyFighterMessage.ArenaAdded:
            {
                FantasyArenaAdded list = (FantasyArenaAdded)msg;

                DataRow row = ArenaTable.NewRow();
                row["name"] = list.arenas;
                ArenaTable.Rows.Add(row);

                ArenaTable.AcceptChanges();
            }
            break;

            case MessageCommon.FantasyFighterMessage.ArenaJoined:
            {
                FantasyArenaJoined list = (FantasyArenaJoined)msg;
                arena = new FantasyArena();

                new Arena(this).Show();
            }
            break;
            }
        }