コード例 #1
0
        public static void LoadGrid_By_PlayingBoardGroupTitle(RadGridView grid,
                                                              PlayingBoardGroupTitle playingBoardGroupTitle, DataBaseDataContext connection)
        {
            var myQuery =
                connection.PlayingBoardTitles.OrderByDescending(a => a.ID)
                .Where(a => a.PlayingBoardGroupTitle == playingBoardGroupTitle)
                .Select(a => new
            {
                id    = a.ID,
                title = a.Title
            });

            grid.DataSource = myQuery;

            grid.Columns[1].IsVisible = false;

            grid.Columns[2].HeaderText = "عنوان";

            grid.Columns[2].Width = 420;

            for (int i = 0; i < grid.RowCount; i++)
            {
                grid.Rows[i].Cells[0].Value = i + 1;
            }
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (string.IsNullOrEmpty(txtTitle.Text) || string.IsNullOrWhiteSpace(txtTitle.Text))
            {
                DataValidationMesaage.BlankTextBox("عنوان");

                return;
            }
            if (myConnection.PlayingBoardGroupTitles.Any(a => a.GroupTitle == txtTitle.Text.Trim()))
            {
                DataValidationMesaage.DuplicateData(txtTitle.Text);

                return;
            }

            PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Insert(txtTitle.Text.Trim(), myConnection);

            ClearTextBox();

            DataValidationMesaage.AcceptMessage(playingBoardGroupTitle.GroupTitle);

            PlayingBoardGroupTitle.LoadGrid(gridPlayingBoardGroupTitle, myConnection);

            myConnection.Dispose();
        }
コード例 #3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridPlayingBoardGroupTitle.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridPlayingBoardGroupTitle.Text);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region PlayingBoardGroupTitle Casting

            int playingBoardGroupTitleID = int.Parse(gridPlayingBoardGroupTitle.SelectedRows[0].Cells[1].Value.ToString());

            if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleID, myConnection);

            #endregion

            txtTitle.Text = playingBoardGroupTitle.GroupTitle;

            FormManagement.EnableYesNo(this.Controls);

            txtTitle.Focus();
        }
コード例 #4
0
        public static void LoadComboBox_By_PlayingBoardGroupTitle(ComboBox cmbBox,
                                                                  PlayingBoardGroupTitle playingBoardGroupTitle, DataBaseDataContext connection)
        {
            IQueryable <PlayingBoardTitle> myQuery =
                connection.PlayingBoardTitles.OrderByDescending(a => a.ID).Where(a => a.PlayingBoardGroupTitle == playingBoardGroupTitle)
                .Select(a => a);

            cmbBox.Items.Clear();

            foreach (var item in myQuery)
            {
                cmbBox.Items.Add(item);
            }

            if (!myQuery.Any())
            {
                cmbBox.Items.Add("یک آیتم به ثبت برسانید");

                cmbBox.SelectedIndex = 0;

                return;
            }

            cmbBox.SelectedIndex = 0;
        }
コード例 #5
0
        public static PlayingBoardGroupTitle Insert(string groupTitle, DataBaseDataContext connection)
        {
            PlayingBoardGroupTitle playingBoardGroupTitle = new PlayingBoardGroupTitle(groupTitle);

            connection.PlayingBoardGroupTitles.InsertOnSubmit(playingBoardGroupTitle);

            connection.SubmitChanges();

            return(playingBoardGroupTitle);
        }
コード例 #6
0
        private void FrmSetRaspberryRelays_Load(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            RaspBerryPlayingBoard.ShowList(lstRaspberryRelays, myConnection);

            RaspberryPin.LoadComboBoxAvailables(cmbRaspberryRelay, myConnection);

            PlayingBoardGroupTitle.LoadComboBox(cmbPlayingBoardGroupTitle, myConnection);

            if (myConnection.PlayingBoardGroupTitles.Any())
            {
                #region PlayingBoardGroupTitle Cast

                int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID;

                if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection))
                {
                    DataValidationMesaage.NoDataInBank();

                    return;
                }

                PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId,
                                                                                           myConnection);

                #endregion

                PlayingBoardTitle.LoadComboBox_By_PlayingBoardGroupTitle(cmbPlayingBoardTitle, playingBoardGroupTitle,
                                                                         myConnection);

                if (myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle)))
                {
                    #region PlayingBoardTitle Cast

                    int playingBoardTitleId = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID;

                    if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection))
                    {
                        DataValidationMesaage.NoDataInBank();

                        return;
                    }

                    PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection);

                    #endregion

                    PlayingBoard.LoadComboBoxByFilter(cmbPlayingBoard, playingBoardTitle, myConnection);
                }
            }
        }
コード例 #7
0
        private void FrmPlayingBoard_Load(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            PlayingBoardGroupTitle.LoadComboBox(cmbPlayingBoardGroupTitle, myConnection);

            if (myConnection.PlayingBoardGroupTitles.Any())
            {
                #region PlayingBoardGroupTitle Cast

                int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID;

                if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection))
                {
                    DataValidationMesaage.NoDataInBank();

                    return;
                }

                PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId,
                                                                                           myConnection);

                #endregion

                if (myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle)))
                {
                    #region PlayingBoardTitle Cast

                    int playingBoardTitleId = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID;

                    if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection))
                    {
                        DataValidationMesaage.NoDataInBank();

                        return;
                    }

                    PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection);

                    #endregion

                    PlayingBoard.LoadGridColorful_By_PlayingBoardTitle(gridPlayingBoard, playingBoardTitle, myConnection);
                }
            }

            myConnection.Dispose();
        }
コード例 #8
0
        private void btnYes_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (string.IsNullOrEmpty(txtTitle.Text) || string.IsNullOrWhiteSpace(txtTitle.Text))
            {
                DataValidationMesaage.BlankTextBox("عنوان");

                return;
            }

            #region PlayingBoardGroupTitle Casting

            int playingBoardGroupTitleID = int.Parse(gridPlayingBoardGroupTitle.SelectedRows[0].Cells[1].Value.ToString());

            if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleID, myConnection);

            #endregion

            if (myConnection.PlayingBoardGroupTitles.Any(a => a.GroupTitle == txtTitle.Text.Trim() && a.ID != playingBoardGroupTitleID))
            {
                DataValidationMesaage.DuplicateData(txtTitle.Text);

                return;
            }

            PlayingBoardGroupTitle.Edit(playingBoardGroupTitle, txtTitle.Text.Trim(), myConnection);

            DataValidationMesaage.EditMessage();

            ClearTextBox();

            txtTitle.Focus();

            PlayingBoardGroupTitle.LoadGrid(gridPlayingBoardGroupTitle, myConnection);

            FormManagement.DisableYesNo(this.Controls);

            myConnection.Dispose();
        }
コード例 #9
0
        private void cmbPlayingBoardGroupTitle_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (myConnection.PlayingBoardGroupTitles.Any())
            {
                #region PlayingBoardGroupTitle Cast

                int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID;

                if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection))
                {
                    DataValidationMesaage.NoDataInBank();

                    return;
                }

                PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId,
                                                                                           myConnection);

                #endregion

                PlayingBoardTitle.LoadComboBox_By_PlayingBoardGroupTitle(cmbPlayingBoardTitle, playingBoardGroupTitle,
                                                                         myConnection);

                if (myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle)))
                {
                    #region PlayingBoardTitle Cast

                    int playingBoardTitleId = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID;

                    if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection))
                    {
                        DataValidationMesaage.NoDataInBank();

                        return;
                    }

                    PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection);

                    #endregion

                    PlayingBoard.LoadComboBoxByFilter(cmbPlayingBoard, playingBoardTitle, myConnection);
                }
            }
        }
コード例 #10
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (gridPlayingBoardGroupTitle.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridPlayingBoardGroupTitle.Text);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region PlayingBoardGroupTitle Casting

            int playingBoardGroupTitleID = int.Parse(gridPlayingBoardGroupTitle.SelectedRows[0].Cells[1].Value.ToString());

            if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleID, myConnection);

            #endregion

            if (playingBoardGroupTitle.PlayingBoardTitles.Any())
            {
                DataValidationMesaage.DataInUse(playingBoardGroupTitle.GroupTitle, gridPlayingBoardGroupTitle.Text);

                return;
            }
            DialogResult message = DataValidationMesaage.ConfirmDeleteData(playingBoardGroupTitle.GroupTitle);

            if (message == DialogResult.Yes)
            {
                PlayingBoardGroupTitle.Delete(playingBoardGroupTitle, myConnection);

                DataValidationMesaage.DeleteMessage();

                PlayingBoardGroupTitle.LoadGrid(gridPlayingBoardGroupTitle, myConnection);
            }
        }
コード例 #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (string.IsNullOrWhiteSpace(txtTitle.Text.Trim()) || string.IsNullOrEmpty(txtTitle.Text.Trim()))
            {
                DataValidationMesaage.BlankTextBox("عنوان دستگاه");

                return;
            }

            #region PlayingBoardGroupTitle Cast

            int id = FrmPlayingBoard.SelectedPlayingBoardGroupTitle.ID;

            if (!PlayingBoardGroupTitle.Validation(id, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(id, myConnection);

            #endregion

            if (myConnection.PlayingBoardTitles.Any(a => a.Title == txtTitle.Text.Trim()))
            {
                DataValidationMesaage.DuplicateData("عنوان دستگاه");

                return;
            }

            PlayingBoardTitle.Insert(txtTitle.Text.Trim(), playingBoardGroupTitle, myConnection);

            PlayingBoardTitle.LoadGrid_By_PlayingBoardGroupTitle(gridPlayingBoardTitle, playingBoardGroupTitle,
                                                                 myConnection);

            ClearTextBox();

            //myConnection.Dispose();
        }
コード例 #12
0
        private void btnAddPlayingboardTitle_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            #region PlayingBoardGroupTitle Cast

            int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID;

            if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            SelectedPlayingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId,
                                                                        myConnection);

            #endregion

            FrmPlayingBoardTitle frm = new FrmPlayingBoardTitle();

            frm.ShowDialog();
        }
コード例 #13
0
        private void cmbPlayingBoardGroupTitle_SelectedIndexChanged(object sender, EventArgs e)
        {
            gridPlayingBoard.Rows.Clear();

            DataBaseDataContext myConnection = Setting.DataBase;

            if (myConnection.PlayingBoardGroupTitles.Any())
            {
                btnAddPlayingboardTitle.Visible = true;

                #region PlayingBoardGroupTitle Cast

                int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID;

                if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection))
                {
                    DataValidationMesaage.NoDataInBank();

                    return;
                }

                PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId,
                                                                                           myConnection);

                #endregion

                PlayingBoardTitle.LoadComboBox_By_PlayingBoardGroupTitle(cmbPlayingBoardTitle, playingBoardGroupTitle,
                                                                         myConnection);

                if (myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle)))
                {
                    #region PlayingBoardTitle Cast

                    int playingBoardTitleId = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID;

                    if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection))
                    {
                        DataValidationMesaage.NoDataInBank();

                        return;
                    }

                    PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection);

                    #endregion

                    PlayingBoard.LoadGridColorful_By_PlayingBoardTitle(gridPlayingBoard, playingBoardTitle, myConnection);
                }
            }

            else
            {
                btnAddPlayingboardTitle.Visible = false;

                cmbPlayingBoardTitle.Items.Add("گروه بازی کامل شود");

                cmbPlayingBoardTitle.SelectedIndex = 0;

                return;
            }
        }
コード例 #14
0
 private void FrmPlayingBoardGroupTitle_Load(object sender, EventArgs e)
 {
     PlayingBoardGroupTitle.LoadGrid(gridPlayingBoardGroupTitle, Setting.DataBase);
 }
コード例 #15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (string.IsNullOrEmpty(txtNumber.Text) || string.IsNullOrWhiteSpace(txtNumber.Text))
            {
                DataValidationMesaage.BlankTextBox("شماره دستگاه");

                return;
            }
            if (myConnection.PlayingBoardGroupTitles.Any())
            {
                #region PlayingBoardGroupTitle Cast

                int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID;

                if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection))
                {
                    DataValidationMesaage.NoDataInBank();

                    return;
                }

                PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId,
                                                                                           myConnection);

                #endregion

                if (!myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle)))
                {
                    DataValidationMesaage.BlankComboBox("عنوان دستگاه");

                    return;
                }

                if (
                    myConnection.PlayingBoardTitles.Any(
                        a =>
                        a.Title.Equals(txtNumber.Text.Trim()) &&
                        a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle)))
                {
                    MessageBox.Show("کاربر گرامی مقادیر شماره میز و عنوان بازی نمیتوانند یکسان باشند.",
                                    "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
            }

            #region PlayingBoardTitle Cast

            int id = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID;

            if (!PlayingBoardTitle.Validation(id, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(id, myConnection);

            #endregion

            if (myConnection.PlayingBoards.Any(a => a.PlayingBoardTitle == playingBoardTitle && a.Number.Equals(txtNumber.Text.Trim())))
            {
                DataValidationMesaage.DuplicateData("شماره میز");

                return;
            }

            PlayingBoard playingBoard = PlayingBoard.Insert(playingBoardTitle, txtNumber.Text, true, myConnection);

            DataValidationMesaage.AcceptMessage();

            DialogResult result1 = MessageBox.Show("آیا مایلید برق میز بازی ثبت شده را به صورت سیستمی کنترل نمایید؟", "کاربر گرامی", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result1 == DialogResult.Yes)
            {
                btnRaspberryRelay.PerformClick();
            }


            DialogResult result2 = MessageBox.Show("آیا مایلید برای میز بازی ثبت شده بهاء تعیین نمایید؟", "کاربر گرامی", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result2 == DialogResult.Yes)
            {
                btnPrice.PerformClick();
            }

            clearTextBox();

            PlayingBoard.LoadGridColorful_By_PlayingBoardTitle(gridPlayingBoard, playingBoardTitle, myConnection);
        }
コード例 #16
0
        public static void Delete(PlayingBoardGroupTitle playingBoardGroupTitle, DataBaseDataContext connection)
        {
            connection.PlayingBoardGroupTitles.DeleteOnSubmit(playingBoardGroupTitle);

            connection.SubmitChanges();
        }
コード例 #17
0
        public static void Edit(PlayingBoardGroupTitle playingBoardGroupTitle, string groupTitle, DataBaseDataContext connection)
        {
            playingBoardGroupTitle.GroupTitle = groupTitle;

            connection.SubmitChanges();
        }