private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridPlayingBoard.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridPlayingBoard.Text);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region PlayingBoard Cast

            int playingBoardId = (int)gridPlayingBoard.SelectedRows[0].Cells[1].Value;

            if (!PlayingBoard.Validation(playingBoardId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoard playingBoard = PlayingBoard.Get(playingBoardId, myConnection);

            #endregion

            txtNumber.Text = playingBoard.Number;

            FormManagement.EnableYesNoIncludingComboBox(this.Controls);

            myConnection.Dispose();
        }
        private void تعیینبهاءToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            #region No ListItem Selected

            if (gridPlayingBoard.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridPlayingBoard.Text);

                return;
            }


            #endregion

            DataBaseDataContext myConnection = Setting.DataBase;

            #region PlayingBoard Cast

            int playingBoardId = (int)gridPlayingBoard.SelectedRows[0].Cells[1].Value;

            if (!PlayingBoard.Validation(playingBoardId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            SelectedPlayingBoard = PlayingBoard.Get(playingBoardId, myConnection);

            #endregion

            FrmPlayingBoardType frm = new FrmPlayingBoardType();

            frm.ShowDialog();
        }
Beispiel #3
0
        private void gridPlayingBoard_SelectionChanged(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (gridPlayingBoard.SelectedRows.Count == 0)
            {
                return;
            }

            #region PlayingBoard Cast

            int playingBoardId = int.Parse(gridPlayingBoard.SelectedRows[0].Cells[1].Value.ToString());

            if (!PlayingBoard.Validation(playingBoardId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoard playingBoard = PlayingBoard.Get(playingBoardId, myConnection);

            #endregion

            PlayingBoardType.LoadComboBox_By_PlayingBoard(cmbPlayingBoardType, playingBoard, myConnection);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            #region No ListItem Selected

            if (gridPlayingBoard.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridPlayingBoard.Text);

                return;
            }


            #endregion

            DataBaseDataContext myConnection = Setting.DataBase;

            #region PlayingBoard Cast

            int playingBoardId = (int)gridPlayingBoard.SelectedRows[0].Cells[1].Value;

            if (!PlayingBoard.Validation(playingBoardId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoard playingBoard = PlayingBoard.Get(playingBoardId, myConnection);

            #endregion

            #region Check Data In Use (RaspberryPin)

            if (playingBoard.PlayingBoardTypes.Any() ||
                myConnection.RaspBerryPlayingBoards.Any(a => a.PlayingBoard.Equals(playingBoard)))
            {
                DataValidationMesaage.DataInUse(playingBoard.Number, gridPlayingBoard.Text);

                return;
            }


            #endregion

            DialogResult message = DataValidationMesaage.ConfirmDeleteData(playingBoard.Number);

            if (message == DialogResult.Yes)
            {
                PlayingBoard.Delete(playingBoard, myConnection);

                DataValidationMesaage.DeleteMessage();

                PlayingBoard.LoadGridColorful_By_PlayingBoardTitle(gridPlayingBoard, playingBoard.PlayingBoardTitle,
                                                                   myConnection);
            }

            myConnection.Dispose();
        }
        public static PlayingBoardType Insert(PlayingBoard playingBoard, string type, int price, DataBaseDataContext connection)
        {
            PlayingBoardType playingBoardType = new PlayingBoardType(type, price);

            playingBoard = PlayingBoard.Get(playingBoard.ID, connection);

            playingBoardType.PlayingBoard = playingBoard;

            connection.PlayingBoardTypes.InsertOnSubmit(playingBoardType);

            connection.SubmitChanges();

            return(playingBoardType);
        }
Beispiel #6
0
        private void FrmRent_Load(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            Member.LoadGridBriefly(gridMember, myConnection);

            PlayingBoard.LoadGridAvailables(gridPlayingBoard, myConnection);

            if (myConnection.PlayingBoards.Any(a => a.IsAvailable))
            {
                #region PlayingBoard Cast

                int playingBoardId = int.Parse(gridPlayingBoard.SelectedRows[0].Cells[1].Value.ToString());

                if (!PlayingBoard.Validation(playingBoardId, myConnection))
                {
                    DataValidationMesaage.NoDataInBank();

                    return;
                }

                PlayingBoard playingBoard = PlayingBoard.Get(playingBoardId, myConnection);

                #endregion

                PlayingBoardType.LoadComboBox_By_PlayingBoard(cmbPlayingBoardType, playingBoard, myConnection);
            }
            cmbSearchMemberBy.SelectedIndex = 0;

            cmbSearchPlayingBoardBy.SelectedIndex = 0;

            gridPlayingBoard.ClearSelection();

            gridMember.ClearSelection();

            myConnection.Dispose();
        }
        private void btnYes_Click(object sender, EventArgs e)
        {
            #region Check Blank txtNumber

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

                return;
            }

            #endregion

            DataBaseDataContext myConnection = Setting.DataBase;

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

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

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

                    return;
                }

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

                #endregion

                #region Check Duplicate cmbPlayingBoardTitle and txtNumber
                if (
                    myConnection.PlayingBoards.Any(
                        a =>
                        a.PlayingBoardTitle.Title.Equals(txtNumber.Text.Trim())))
                {
                    MessageBox.Show("کاربر گرامی مقادیر شماره میز و عنوان بازی نمیتوانند یکسان باشند.",
                                    "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }


                #endregion

                #region Check Duplicate Data

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

                    return;
                }

                #endregion

                #region PlayingBoard Cast

                int PlayingBoardId = (int)gridPlayingBoard.SelectedRows[0].Cells[1].Value;

                if (!PlayingBoard.Validation(PlayingBoardId, myConnection))
                {
                    DataValidationMesaage.NoDataInBank();

                    return;
                }

                PlayingBoard playingBoard = PlayingBoard.Get(PlayingBoardId, myConnection);

                #endregion

                PlayingBoard.Edit(playingBoard, playingBoardTitle, txtNumber.Text.Trim(), true, myConnection);

                DataValidationMesaage.EditMessage();

                clearTextBox();

                FormManagement.DisableYesNoIncludingComboBox(this.Controls);

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

            myConnection.Dispose();
        }
Beispiel #8
0
        private void btnGameStart_Click(object sender, EventArgs e)
        {
            if (gridMember.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridMember.Text);

                return;
            }

            if (gridPlayingBoard.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridPlayingBoard.Text);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region PlayingBoard Cast

            int playingBoardId = int.Parse(gridPlayingBoard.SelectedRows[0].Cells[1].Value.ToString());

            if (!PlayingBoard.Validation(playingBoardId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoard playingBoard = PlayingBoard.Get(playingBoardId, myConnection);

            #endregion

            #region Memeber Cast

            int memberId = int.Parse(gridMember.SelectedRows[0].Cells[1].Value.ToString());

            if (!Member.Validation(memberId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Member member = Member.Get(memberId, myConnection);
            #endregion

            if (!myConnection.PlayingBoardTypes.Any(a => a.PlayingBoard == playingBoard))
            {
                MessageBox.Show("برای این میز بازی هیچ قیمتی ثبت نشده است.", "کاربر گرامی", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                return;
            }

            if (myConnection.RaspBerryPlayingBoards.Any(a => a.PlayingBoard == playingBoard))
            {
                #region RaspBerryPlayingBoard Cast

                if (!RaspBerryPlayingBoard.Validation_By_PlayingBoardID(playingBoardId, myConnection))
                {
                    DataValidationMesaage.NoDataInBank();

                    return;
                }

                RaspBerryPlayingBoard raspBerryPlayingBoard = RaspBerryPlayingBoard.Get_By_PlayingBoardID(playingBoardId, myConnection);

                #endregion

                MemberRentPlayingBoard.PowerOnOff(raspBerryPlayingBoard.RaspberryPin, "1", Setting.RaspberryIPAddress, Setting.RaspberryPortNumber);
            }

            #region PlayingBoardType Cast

            int playingBoardTypeID = ((PlayingBoardType)cmbPlayingBoardType.SelectedItem).ID;

            if (!PlayingBoardType.Validation(playingBoardTypeID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoardType playingBoardType = PlayingBoardType.Get(playingBoardTypeID, myConnection);

            #endregion

            MyRentPlayingBoard = RentPlayingBoard.Insert(playingBoardType, DateTime.Now,
                                                         DateTime.Now.ToString("HH:mm:ss"), DateTime.Now.ToString("HH:mm:ss"), true, myConnection);

            MemberRentPlayingBoard.Insert(MyRentPlayingBoard, member, "opener", myConnection);


            playingBoard.IsAvailable = false;

            myConnection.SubmitChanges();

            PlayingBoard.LoadGridAvailables(gridPlayingBoard, myConnection);

            MessageBox.Show("بازی شروع شد.", "کاربر گرامی", MessageBoxButtons.OK,
                            MessageBoxIcon.Asterisk);

            myConnection.Dispose();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (cmbPlayingBoard.SelectedItem == null)
            {
                DataValidationMesaage.NoSelectedItemFromList("لیست میزهای بازی");

                return;
            }

            #region PlayingBoard Cast

            int playingBoardId = ((PlayingBoard)cmbPlayingBoard.SelectedItem).ID;

            if (!PlayingBoard.Validation(playingBoardId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            PlayingBoard playingBoard = PlayingBoard.Get(playingBoardId, myConnection);

            #endregion

            #region RaspberryPin Cast

            int raspberryPinID = ((RaspberryPin)cmbRaspberryRelay.SelectedItem).ID;

            if (!RaspberryPin.Validation(raspberryPinID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            RaspberryPin raspberryPin = RaspberryPin.Get(raspberryPinID, myConnection);

            #endregion

            if (myConnection.RaspBerryPlayingBoards.Any(a => a.PlayingBoard == playingBoard))
            {
                MessageBox.Show("برای این میز بازی یک رله اختصاص داده شده است.", "کاربر گرامی", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                return;
            }

            RaspBerryPlayingBoard.Insert(raspberryPin, playingBoard, myConnection);

            raspberryPin.IsAvailable = false;

            myConnection.SubmitChanges();

            DataValidationMesaage.AcceptMessage();

            RaspberryPin.LoadComboBoxAvailables(cmbRaspberryRelay, myConnection);

            RaspBerryPlayingBoard.ShowList(lstRaspberryRelays, myConnection);
        }