bool IsRoundAlreadyStarted()
        {
            short count = 0;
            int   round = 0;

            foreach (DataRow item in table.Rows)
            {
                TournamentMatch tournamentMatch = new TournamentMatch(Cxt.Instance, item);

                if (tournamentMatch.TournamentMatchStatusE == TournamentMatchStatusE.InProgress)
                {
                    if (tournamentMatch.Round != round)
                    {
                        if (count > 1)
                        {
                            break;
                        }
                        round = tournamentMatch.Round;
                        count++;
                    }
                }
            }

            if (count > 1)
            {
                MessageForm.Error(Msg.GetMsg(MsgE.ErrorTournamentNextRoundStarted, ""));
                //RsPanel.ShowMessage(Msg.GetMsg(MsgE.ErrorTournamentMultipleRounds), true);
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 2
0
 public void Copy()
 {
     try
     {
         StringBuilder sb = new StringBuilder();
         for (int i = 0; i < _list.SelectedItems.Count; ++i)
         {
             ListViewItem item = _list.SelectedItems[i];
             sb.Append(item.Tag as string);
             sb.AppendLine();
             sb.AppendFormat("({0})", item.SubItems[2].Text);
             if (i < _list.SelectedItems.Count - 1)
             {
                 sb.AppendLine();
             }
         }
         var s = sb.ToString();
         if (!string.IsNullOrEmpty(s))
         {
             Clipboard.SetText(s);
         }
     }
     catch (Exception ex)
     {
         MessageForm.Error(string.Format(Strings.MainForm.ClipboardErrorFmt, ex.Message));
     }
 }
Exemplo n.º 3
0
        public bool RestartGame()
        {
            if (DbGame == null)
            {
                return(false);
            }

            GameType wGameType = GameTime.GetGameType(Convert.ToInt32(cmbWhiteMin.Text), Convert.ToInt32(cmbWhiteSec.Text));
            GameType bGameType = GameTime.GetGameType(Convert.ToInt32(cmbBlackMin.Text), Convert.ToInt32(cmbBlackSec.Text));

            if (this.DbGame.GameTypeIDE != wGameType || this.DbGame.GameTypeIDE != bGameType)
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorRestartGameTime, "");
                return(false);
            }

            int wMin = Convert.ToInt32(cmbWhiteMin.Text) * 60;
            int wSec = Convert.ToInt32(cmbWhiteSec.Text);

            int bMin = Convert.ToInt32(cmbBlackMin.Text) * 60;
            int bSec = Convert.ToInt32(cmbBlackSec.Text);

            ProgressForm frm = ProgressForm.Show(this, "Restarting Game...");

            SocketClient.RestartGameWithSetup(ResetGameE.Asked, this.DbGame.GameID, notationViewerUc1.SelectedMoveID, ChallengerUserID, OpponentUserID, wMin, wSec, bMin, bSec, IsTournamentDirector);

            frm.Close();
            return(true);
        }
Exemplo n.º 4
0
        private new void Update()
        {
            if (String.IsNullOrEmpty(txtOldPassword.Text))
            {
                MessageForm.Error(this, MsgE.ErrorEmptyOldPassword);
                return;
            }
            else if (UCrypto.Encrypt(txtOldPassword.Text) != Ap.CurrentUser.Password)
            {
                MessageForm.Error(this, MsgE.ErrorWrongOldPassword);
                return;
            }

            DataSet ds     = SocketClient.ChangePassword(txtPassword.Text, txtPasswordHint.Text);
            bool    update = false;

            if (ds != null && ds.Tables.Count > 0)
            {
                Kv kv = new Kv(ds.Tables[0]);
                update = kv.GetBool("Updated");
            }

            if (update)
            {
                MessageForm.Show(this, MsgE.InfoUpdatePassword);

                Ap.CurrentUser.Password     = UCrypto.Encrypt(txtPassword.Text);
                Ap.CurrentUser.PasswordHint = txtPasswordHint.Text;
            }
            else
            {
                MessageForm.Error(this, MsgE.ErrorUpdatePassword);
            }
            this.Close();
        }
Exemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            double amount = 0;

            if (!Double.TryParse(txtAmount.Text.Trim(), out amount))
            {
                MessageForm.Error("Please enter correct amount.");
                return;
            }

            Kv kv = new Kv();

            kv.Set("TournamentID", this.Tournament.TournamentID);
            kv.Set("PrizePosition", GetPrizeIndex(cmbPrize.Text));
            kv.Set("TournamentPrizeCategoryID", Convert.ToInt32(cmbCategory.SelectedValue));
            kv.Set("PrizeAmount", amount);

            DataSet ds = SocketClient.AddPrize(kv);

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                TournamentPrize = new TournamentPrize(Ap.Cxt, ds.Tables[0].Rows[0]);
            }
            txtAmount.Text = "";
            RefreshGrid();
        }
Exemplo n.º 6
0
        void UpdateReplacePlayer()
        {
            int userID2 = 0;

            userID2 = ValidateReplacePlayer();

            if (userID2 == -1 || userID2 == 0)
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorReplacePlayerSelection, "");
                return;
            }

            DataSet ds = SocketClient.UpdateReplacePlayer(this.Tournament.TournamentID, this.UserID, userID2);

            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    Kv kv = new Kv(ds.Tables[0]);
                    if (kv.GetInt32("Result") > 0)
                    {
                        MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"));
                        return;
                    }
                }
            }

            TournamentRegisterPlayer TournamentRegisterPlayer = (TournamentRegisterPlayer)this.ParentForm;

            TournamentRegisterPlayer.DialogResult = DialogResult.OK;
        }
Exemplo n.º 7
0
        private void LoginUser(string loginId, string password)
        {
            try
            {
                if (!String.IsNullOrEmpty(txtLoginId.Text) && !String.IsNullOrEmpty(txtPassword.Text))
                {
                    DataSet ds = SocketClient.LoginUser(loginId, password, Options.Instance.ApplicationCode);

                    if (ds != null && ds.Tables.Count > 0)
                    {
                        Kv kv = new Kv(ds.Tables[0]);

                        int statusID = User.LoginMsg(kv, false);

                        Srv.SetCurrentUser(kv);

                        if (IsValidUser(kv, statusID))
                        {
                            return;
                        }

                        if (Ap.CurrentUser.UserStatusIDE != UserStatusE.Gone)
                        {
                            UserStatus frm = new UserStatus();
                            frm.ShowDialog();
                            return;
                        }

                        SocketClient.LoginUser(Ap.CurrentUserID, UserStatusE.Blank);

                        if (chkRemindPassword.Checked)
                        {
                            Options.Instance.LoginID  = loginId;
                            Options.Instance.Password = password;
                        }
                        else
                        {
                            Options.Instance.LoginID  = "";
                            Options.Instance.Password = "";
                        }
                        Options.Instance.Save();

                        LoadOnlineClient();
                    }
                    else
                    {
                        MessageForm.Error(this, MsgE.ErrorServerConnection);
                    }
                }
                else
                {
                    MessageForm.Error(this, MsgE.ErrorEmptyIdPassword);
                }
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Show(ex);
            }
        }
Exemplo n.º 8
0
        private void btnChangePicture_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            //dlg.Filter = "BMP Images (*.bmp)|*.bmp";
            dlg.Filter           = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
            dlg.InitialDirectory = Ap.FolderImages;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                FileInfo f  = new FileInfo(dlg.FileName);
                long     s1 = f.Length;
                if (s1 <= 204800)
                //if (s1 <= 4194304)
                {
                    Image uImage = Image.FromFile(dlg.FileName);
                    ImageType = System.IO.Path.GetExtension(dlg.FileName);
                    UserImage = UImage.GetImageBytes(dlg.FileName);
                    MemoryStream memoryStream = new MemoryStream(ResizeImageFile(UserImage, pbUser.Height));
                    Bitmap       img          = new Bitmap(memoryStream);
                    pbUser.Image = img;
                    memoryStream.Close();
                }
                else
                {
                    //MessageForm.Error("Image size not more than 4Mb");
                    MessageForm.Error(this, MsgE.ErrorImageRange);
                }
            }
        }
Exemplo n.º 9
0
        private void ValidateEngine()
        {
            try
            {
                if (!IsEngineAlreadyLoaded(engineFileName))
                {
                    UCIEngineValidator ev = new UCIEngineValidator(sourceFilePath, this.Game);
                    ev.NameReceived   += new UCIEngine.NameReceivedHandler(ev_NameReceived);
                    ev.AuthorReceived += new UCIEngine.AuthorReceivedHandler(ev_AuthorReceived);
                    ev.UciValidated   += new EventHandler(ev_UciValidated);
                    ev.UciInvalidated += new EventHandler(ev_UciInvalidated);

                    ev.Validate();
                }
                else
                {
                    frmProgress.Close();
                    btnBrowse.Enabled = true;
                    MessageForm.Error(this, MsgE.ErrorUciEngine);
                }
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                frmProgress.Close();
                btnBrowse.Enabled = true;
                MessageForm.Error(this, MsgE.ErrorInvalidUciEngine);
            }
        }
        private int GetTournamentMatchID()
        {
            int counter = 0, tournamentMatchID = 0;

            foreach (DataGridViewRow row in dgvMatches.Rows)
            {
                if (row.Cells["Select"].Value != null)
                {
                    if ((bool)row.Cells["Select"].Value)
                    {
                        counter++;
                        if (counter > 1)
                        {
                            MessageForm.Error(this.ParentForm, MsgE.ErrorTournamentMultipleMatchSelection);
                            return(0);
                        }
                        tournamentMatchID = Convert.ToInt32(GridTable.Rows[row.Index]["TournamentMatchID"]);
                    }
                }
            }

            if (counter == 0)
            {
                if (IsTournamentDirector)
                {
                    MessageForm.Error(this.ParentForm, MsgE.ErrorTournamentMultipleMatchSelection);
                }
                else
                {
                    MessageForm.Error(this.ParentForm, MsgE.ErrorTournamentMatchNotInprogress);
                }
            }

            return(tournamentMatchID);
        }
        private void UpdateMatchStatus(TournamentMatchStatusE tournamentMatchStatusID, string matchStatus)
        {
            if (this.Tournament == null)
            {
                return;
            }
            if (this.Tournament.TournamentID == 0)
            {
                return;
            }

            string matchIDs = string.Empty;

            foreach (DataGridViewRow row in dgvMatches.Rows)
            {
                if (row.Cells["Select"].Value != null)
                {
                    if ((bool)row.Cells["Select"].Value)
                    {
                        if (GridTable.Rows[row.Index]["WhiteUserID"].ToString() != "2" && GridTable.Rows[row.Index]["BlackUserID"].ToString() != "2")
                        {
                            matchIDs += "," + GridTable.Rows[row.Index]["TournamentMatchID"].ToString();
                        }
                    }
                }
            }

            if (matchIDs.Length > 0)
            {
                matchIDs = matchIDs.Remove(0, 1);

                if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmItemTask, "update match status to ", matchStatus) != DialogResult.Yes)
                {
                    return;
                }

                ProgressForm frmProgress = ProgressForm.Show(this, "Updating match status...");
                DataSet      ds          = SocketClient.UpdateTournamentMatchStatus(tournamentMatchStatusID, this.Tournament.TournamentID, matchIDs);
                frmProgress.Close();

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        Kv kv = new Kv(ds.Tables[0]);
                        if (kv.GetInt32("Result") > 0)
                        {
                            MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"));
                            return;
                        }
                    }
                }
                RefreshGrid();
            }
            else
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorTournamentMatchStartRequest);
            }
        }
Exemplo n.º 12
0
        private bool StartTournament()
        {
            bool isTrue = false;

            if (this.Tournament == null)
            {
                return(false);
            }

            if (this.Tournament.TournamentID == 0)
            {
                return(false);
            }

            if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmItemTask, "start", "tournament " + "'" + this.Tournament.Name + "'") == DialogResult.Yes)
            {
                ProgressForm frmProgress = ProgressForm.Show(this, "Creating matches...");

                this.Tournament.TournamentStatusIDE = TournamentStatusE.InProgress;
                DataSet ds = SocketClient.TournamentStart(this.Tournament.TournamentID, this.Tournament.TournamentStatusIDE);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        Kv kv = new Kv(ds.Tables[0]);
                        if (kv.GetInt32("Result") > 0)
                        {
                            frmProgress.Close();
                            if ((int)MsgE.ErrorTournamentUserExist == kv.GetInt32("Result") && this.Tournament.TournamentTypeIDE == TournamentTypeE.Knockout)
                            {
                                MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"), this.Tournament.Name, 4);
                            }
                            else
                            {
                                MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"), this.Tournament.Name, 2);
                            }

                            this.Tournament.TournamentStatusIDE = TournamentStatusE.Scheduled;
                            return(false);
                        }
                    }

                    tsbRescheduleTask.Visible = true;
                    frmProgress.Close();

                    MessageForm.Show(this.ParentForm, MsgE.ConfirmTournamentStarted, this.Tournament.Name);
                    isTrue = true;
                }
                else
                {
                    MessageForm.Error(this.ParentForm, MsgE.ErrorTournamentUserExist, this.Tournament.Name);

                    return(false);
                }
            }
            return(isTrue);
        }
Exemplo n.º 13
0
        public CResolution(int a, int b)
        {
            Screen screen = Screen.PrimaryScreen;


            int iWidth  = a;
            int iHeight = b;


            DEVMODE1 dm = new DEVMODE1();

            dm.dmDeviceName = new String(new char[32]);
            dm.dmFormName   = new String(new char[32]);
            dm.dmSize       = (short)Marshal.SizeOf(dm);

            if (0 != User_32.EnumDisplaySettings(null, User_32.ENUM_CURRENT_SETTINGS, ref dm))
            {
                dm.dmPelsWidth  = iWidth;
                dm.dmPelsHeight = iHeight;

                int iRet = User_32.ChangeDisplaySettings(ref dm, User_32.CDS_TEST);

                if (iRet == User_32.DISP_CHANGE_FAILED)
                {
                    MessageForm.Error("unable to process your request. sorry for inconvenience.");
                }
                else
                {
                    iRet = User_32.ChangeDisplaySettings(ref dm, User_32.CDS_UPDATEREGISTRY);

                    switch (iRet)
                    {
                    case User_32.DISP_CHANGE_SUCCESSFUL:
                    {
                        break;

                        //successfull change
                    }

                    case User_32.DISP_CHANGE_RESTART:
                    {
                        MessageForm.Show("Description: You Need To Reboot For The Change To Happen.\n If You Feel Any Problem After Rebooting Your Machine\nThen Try To Change Resolution In Safe Mode.");
                        break;
                        //windows 9x series you have to restart
                    }

                    default:
                    {
                        MessageForm.Show("Description: Failed To Change The Resolution.");
                        break;
                        //failed to change
                    }
                    }
                }
            }
        }
Exemplo n.º 14
0
        public void Save()
        {
            MsgE msgE;

            if (!Validate(out msgE))
            {
                MessageForm.Error(this.ParentForm, msgE);
                return;
            }

            SaveTournament();
        }
Exemplo n.º 15
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtEmail.Text))
            {
                Regex reg = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
                Match mt  = reg.Match(txtEmail.Text);
                if (!mt.Success)
                {
                    MessageForm.Error(this, MsgE.ErrorInvalidEmail);
                    return;
                }
            }
            if (!String.IsNullOrEmpty(txtURL.Text))
            {
                Regex reg = new Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?");
                Match mt  = reg.Match(txtURL.Text);
                if (!mt.Success)
                {
                    MessageForm.Error(this, MsgE.ErrorInvalidURL);
                    return;
                }
            }

            if (IsNew)
            {
                if (ShowConfirmDialog)
                {
                    if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmItemTask, "save", "user") == DialogResult.Yes)
                    {
                        Save();
                    }
                }
                else
                {
                    Save();
                }
            }
            else
            {
                if (ShowConfirmDialog)
                {
                    if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmItemTask, "update", "user") == DialogResult.Yes)
                    {
                        Update();
                    }
                }
                else
                {
                    Update();
                }
            }
        }
Exemplo n.º 16
0
        private void DeleteTeams()
        {
            if (dgvTeam.Rows.Count == 0)
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorNoSelection, "team");

                return;
            }

            try
            {
                int i = 0;

                string tournamentTeamIds = string.Empty;

                foreach (DataGridViewRow row in dgvTeam.Rows)
                {
                    if (row.Cells[0].Value != null)
                    {
                        if ((bool)row.Cells[0].Value)
                        {
                            int teamId = BaseItem.ToInt32(TeamGridTable.Rows[i]["TeamID"]);

                            tournamentTeamIds += "," + teamId.ToString();
                        }
                    }
                    i++;
                }

                if (tournamentTeamIds.Length > 0)
                {
                    tournamentTeamIds = tournamentTeamIds.Remove(0, 1);

                    ProgressForm frmProgress = ProgressForm.Show(this, "Removing Teams...");

                    SocketClient.DeleteTournamentTeam(tournamentTeamIds, this.Tournament.TournamentID);

                    frmProgress.Close();

                    RefreshTeamGrid();
                    RefreshPlayerGrid();
                }
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Show(ex);
            }
        }
Exemplo n.º 17
0
        private int ValidateTeam(App.Model.Db.Tournament t)
        {
            int teamID = 0;

            if (t.TournamentTypeIDE == TournamentTypeE.Scheveningen)
            {
                if (cbTeam.Items.Count == 0)
                {
                    MessageForm.Error(this.ParentForm, MsgE.ErrorNoSelection, "team");
                    return(-1);
                }
                return(Convert.ToInt32(cbTeam.SelectedValue));
            }
            return(teamID);
        }
Exemplo n.º 18
0
        private void LoginGuest()
        {
            try
            {
                DataSet ds = SocketClient.LoginGuest();

                if (ds != null && ds.Tables.Count > 0)
                {
                    Kv kv = new Kv(ds.Tables[0]);

                    int statusID = User.LoginMsg(kv, true);

                    Srv.SetCurrentUser(kv);

                    //if (IsValidUser(kv, statusID))
                    //{
                    //    return;
                    //}
                    //if (LoginMsg(kv1))
                    //{
                    //    return;
                    //}

                    //Srv.SetCurrentUser(kv);

                    SocketClient.LoginUser(Ap.CurrentUserID, UserStatusE.Blank);

                    Options.Instance.LoginID  = "Guest";
                    Options.Instance.Password = "";
                    Options.Instance.Save();

                    ApWin.StartupForm.Visible = false;
                    this.Visible = false;
                    this.Close();
                    OnlineClient frm = new OnlineClient();
                    frm.Show();
                }
                else
                {
                    MessageForm.Error(this, MsgE.ErrorServerConnection);
                }
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Show(ex);
            }
        }
Exemplo n.º 19
0
        void SaveTournamentRegisteredUsers(StatusE statusID, TournamentUserStatusE tournamentUserStatusID)
        {
            int    i       = 0;
            string userIDs = string.Empty;
            int    teamID  = 0;

            if (dgvRegisterPlayer.Rows.Count == 0)
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorNoSelection, "player");

                return;
            }

            try
            {
                foreach (DataGridViewRow row in dgvRegisterPlayer.Rows)
                {
                    if (dgvRegisterPlayer[0, row.Index].Value != null)
                    {
                        if ((bool)dgvRegisterPlayer[0, row.Index].Value)
                        {
                            if (this.Tournament.TournamentTypeE == TournamentTypeE.Scheveningen)
                            {
                                teamID = Convert.ToInt32(GridTable.Rows[i]["TeamID"]);
                            }

                            int userID = BaseItem.ToInt32(GridTable.Rows[i]["UserID"]);

                            userIDs += "," + userID.ToString();
                        }
                    }
                    i++;
                }

                if (userIDs.Length > 0)
                {
                    userIDs = userIDs.Remove(0, 1);
                }


                SocketClient.SaveTournamentRegisteredUsers(statusID, tournamentUserStatusID, this.Tournament.TournamentID, userIDs, teamID, GetEloBeforeRating);
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Show(ex);
            }
        }
Exemplo n.º 20
0
        private void DeletePlayers()
        {
            if (dgvPlayer.Rows.Count == 0)
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorNoSelection, "player");

                return;
            }

            try
            {
                int    i       = 0;
                string userIDs = string.Empty;

                foreach (DataGridViewRow row in dgvPlayer.Rows)
                {
                    if (row.Cells[0].Value != null)
                    {
                        if ((bool)row.Cells[0].Value)
                        {
                            int userID = BaseItem.ToInt32(PlayerGridTable.Rows[i]["UserID"]);
                            userIDs += "," + userID.ToString();
                        }
                    }
                    i++;
                }

                if (userIDs.Length > 0)
                {
                    userIDs = userIDs.Remove(0, 1);

                    ProgressForm frmProgress = ProgressForm.Show(this, "Removing Players...");

                    SocketClient.SaveTournamentRegisteredUsers(StatusE.Deleted, TournamentUserStatusE.Declined, this.Tournament.TournamentID, userIDs, SelectedTeamID, 0);

                    frmProgress.Close();

                    RefreshPlayerGrid();
                }
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Show(ex);
            }
        }
Exemplo n.º 21
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtBanReason.Text != string.Empty)
            {
                KvUserData.UserID        = this.userID;
                KvUserData.BanStartDate  = dtpStartDate.Text;
                KvUserData.BanStartTime  = dtpStartTime.Text;
                KvUserData.BanReason     = txtBanReason.Text;
                KvUserData.BanMachineKey = WmiHelper.GetMachineKey();
                if (rbDate.Checked)
                {
                    KvUserData.BanEndDate = dtpEndDate.Text;
                    KvUserData.BanEndTime = dtpEndTime.Text;
                }
                else if (rbForever.Checked)
                {
                    KvUserData.BanEndDate = "";
                    KvUserData.BanEndTime = "";
                }
                else if (rbDuration.Checked)
                {
                    KvUserData.BanEndDate = dtServerTime.ToString();
                    if (cbDays.Text.Trim().Length > 0)
                    {
                        dtServerTime          = dtServerTime.AddDays(Convert.ToInt32(cbDays.Text));
                        KvUserData.BanEndTime = dtServerTime.ToString();
                    }
                    if (cbHours.Text.Trim().Length > 0)
                    {
                        dtServerTime          = dtServerTime.AddHours(Convert.ToInt32(cbHours.Text));
                        KvUserData.BanEndTime = dtServerTime.ToString();
                    }
                }

                DialogResult dr = MessageForm.Confirm(this.ParentForm, MsgE.ConfirmBanUser, userName);
                if (dr == DialogResult.Yes)
                {
                    DataSet ds = SocketClient.BanUser(KvUserData);
                }
                SubmitClicked(dr);
            }
            else
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorBanReason);
            }
        }
Exemplo n.º 22
0
        bool IsValidUser(Kv kv, int statusID)
        {
            bool      isTrue = false;
            Kv        kv1    = new Kv(kv.GetDataTable("Msg"));
            DataTable dt     = kv1.DataTable;
            int       msgID  = Convert.ToInt32(dt.Rows[0][0]);
            string    serverMaintainceDateTime = KeyValues.Instance.GetKeyValue(KeyValueE.ServerMaintainceDateTime).Value;

            if (statusID == 5)
            {
                MessageForm.Error(this, MsgE.ErrorBannedForever, Ap.CurrentUser.UserName);
                isTrue = true;
            }
            else if (statusID == 0)
            {
                DateTime dt1 = Convert.ToDateTime(dt.Rows[0][1]);
                DateTime dt2 = Convert.ToDateTime(dt.Rows[0][2]);
                MessageForm.Error(this, MsgE.InfoBaned, dt1.ToString(), dt2.ToString());
                isTrue = true;
            }
            else if (statusID == 7)
            {
                MessageForm.Error(this, MsgE.WrongIdPassowrd);
                isTrue = true;
            }
            else if (statusID == 8)
            {
                MessageForm.Error(this, MsgE.NoRoles);
            }
            else if (serverMaintainceDateTime != string.Empty)
            {
                isTrue = true;
                MessageForm.Error(this.ParentForm, MsgE.ErrorServerMaintainceMode, serverMaintainceDateTime);
            }
            else if (statusID == 6)
            {
                MessageForm.Error(this, MsgE.BlockIp);
                isTrue = true;
            }
            else
            {
                isTrue = false;
            }
            return(isTrue);
        }
Exemplo n.º 23
0
 private void btnDeActive_Click(object sender, EventArgs e)
 {
     if (lstActiveEngine.Count > 0 && lstActivateEngine.SelectedItem != null)
     {
         InfinitySettings.EngineManager.Engine selectedItem = (InfinitySettings.EngineManager.Engine)lstActivateEngine.SelectedItem;
         string _defaultEngine = this.Game.DefaultEngine.EngineName + ".exe";
         if (_defaultEngine != selectedItem.EngineTitle)
         {
             lstActiveEngine.Remove(selectedItem);
             lstDeActiveEngine.Add(selectedItem);
             RefreshLists();
         }
         else
         {
             MessageForm.Error(this, MsgE.ErrorEngineActive, selectedItem.Name);
         }
     }
 }
Exemplo n.º 24
0
 private void convertInfinityChessDatabaseicdToPGNToolStripMenuItem_Click(object sender, EventArgs e)
 {
     fileName = txtFile.Text;
     if (fileName.EndsWith(Files.DatabaseExtension))
     {
         Icd = new IcdManager(this.Game);
         Icd.OnProgressBarInitialized += new IcdManager.ProgressBarInitHandler(Icd_OnProgressBarInitialized);
         Icd.OnProgressChanged        += new IcdManager.ProgressChangedEventHandler(Icd_OnProgressChanged);
         Icd.OnProgressWorkCompleted  += new IcdManager.ProgressWorkCompletedHandler(Icd_OnProgressWorkCompleted);
         UFile.Delete(fileName.Replace(".icd", ".pgn"));
         Icd.ConvertIcdToPgn(fileName);
     }
     else
     {
         MessageForm.Error(Msg.GetMsg(MsgE.ErrorInvalidFileFormat));
         return;
     }
 }
Exemplo n.º 25
0
 public void LoadBook()
 {
     try
     {
         ProgressForm frm = ProgressForm.Show(this, "Loading Book....");
         if (!this.Game.Book.Load(Options.Instance.CurrentBookFilePath))
         {
             MessageForm.Error(this.ParentForm, MsgE.ErrorInvalidFileFormat);
         }
         frm.Close();
     }
     catch (FormatException ex)
     {
         TestDebugger.Instance.WriteError(ex);
         MessageForm.Error(this.ParentForm, MsgE.ErrorInvalidFileFormat);
         return;
     }
 }
Exemplo n.º 26
0
        private void LoadImportGameData()
        {
            if (!databaseFileName.EndsWith(Files.DatabaseExtension))
            {
                MessageForm.Error(this, MsgE.ErrorInvalidFileFormat);
                this.Close();
                return;
            }
            try
            {
                ProgressForm frmProgress = ProgressForm.Show(this, "Loading Database...");

                database = new Database(databaseFileName, this.Game);

                frmProgress.Close();

                if (database.GamesCount > 0)
                {
                    numFromGameNo.Value = 1;
                    numToGameNo.Value   = database.GamesCount;

                    numFromGameNo.Maximum = database.GamesCount;
                    numToGameNo.Maximum   = database.GamesCount;
                }
                else
                {
                    numFromGameNo.Maximum = 0;
                    numToGameNo.Maximum   = 0;

                    numFromGameNo.Value = 0;
                    numToGameNo.Value   = 0;
                }

                fromGameNo = (int)numFromGameNo.Value;
                toGameNo   = (int)numToGameNo.Value;
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Error(this, MsgE.ErrorInvalidFileFormat, ex);
                this.Close();
            }
        }
Exemplo n.º 27
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTo.Text))
            {
                return;
            }

            DataSet ds = SocketClient.CheckUserId(txtTo.Text);

            if (ds != null && ds.Tables.Count > 0)
            {
                Kv kv1 = new Kv();
                kv1 = new Kv(ds.Tables[0]);
                bool isExist = kv1.GetBool("IsExist");
                if (!isExist)
                {
                    MessageForm.Error(this, MsgE.ErrorUserNotExist, txtTo.Text);
                    return;
                }
            }
            else
            {
                MessageForm.Error(this, MsgE.ErrorServerConnection);
                return;
            }

            UserMessageDataKv messageKv = new UserMessageDataKv();

            messageKv.UserIDFrom    = Ap.CurrentUserID;
            messageKv.UserIDTo      = 0;
            messageKv.UserNameTo    = txtTo.Text;
            messageKv.Subject       = txtSubject.Text;
            messageKv.Text          = editor1.BodyHtml;
            messageKv.EmailTime     = DateTime.Now;
            messageKv.Size          = UStr.ToBytes(editor1.BodyHtml).Length;
            messageKv.StatusIDFromE = StatusE.Active;
            messageKv.StatusIDToE   = StatusE.Active;
            SocketClient.SendEmail(messageKv);

            MessageForm.Show(this, MsgE.InfoEmailSend);

            this.Close();
        }
Exemplo n.º 28
0
        private void tsbDelete_Click(object sender, EventArgs e)
        {
            string ids = string.Empty;

            if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmItemDelete, "tournament") != DialogResult.Yes)
            {
                return;
            }

            if (dgvTournamentList.Rows.Count == 0)
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorNoSelection, "tournament");

                return;
            }

            foreach (DataGridViewRow row in dgvTournamentList.Rows)
            {
                if (row.Cells[0].Value != null)
                {
                    if ((bool)row.Cells[0].Value)
                    {
                        int tid = Convert.ToInt32(table.Rows[row.Index]["TournamentId"]);

                        if (string.IsNullOrEmpty(ids))
                        {
                            ids = tid.ToString();
                        }
                        else
                        {
                            ids += "," + tid.ToString();
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(ids))
            {
                SocketClient.DeleteTournament(ids);
                RefreshGrid();
            }
        }
Exemplo n.º 29
0
        bool IC1ReportImportFilter.Import(string rptFile, List <C1FlexReport> reportList)
        {
            _rptList         = reportList;
            _crystalFileName = rptFile;

            if (!DoImport(FlexCRI, false))
            {
                MessageForm.Error(Strings.CrystalFilter.ErrNoCrystal);
                return(false);
            }

            // show warnings...
            if (_messages.Count > 0)
            {
                ImportMessagesForm.DoShowMessages(_messages, Strings.CrystalFilter.MessageTitle,
                                                  Strings.CrystalFilter.ImportErrors);
            }

            // return false (don't erase list)
            return(false);
        }
Exemplo n.º 30
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtPassword.Text) && String.IsNullOrEmpty(txtRetypePassword.Text))
            {
                MessageForm.Error(this, MsgE.ErrorEnterPassword);
                return;
            }
            else if (txtPassword.Text.Length < 5)
            {
                MessageForm.Error(this, MsgE.ErrorPasswordLimit);
                return;
            }
            else if (txtPassword.Text != txtRetypePassword.Text)
            {
                MessageForm.Error(this, MsgE.ErrorPasswordMismatch);
                return;
            }
            else if (txtPassword.Text.Contains(" "))
            {
                MessageForm.Error(this, MsgE.ErrorSpacing);
                return;
            }

            //Regex reg = new Regex(@"^[a-zA-Z0-9]+$");
            //Match mt = reg.Match(txtPassword.Text);
            //if (!mt.Success)
            //{
            //    MessageForm.Show("Invalid Password Entered");
            //    return;
            //}

            if (IsNew)
            {
                Save();
            }
            else
            {
                Update();
            }
        }