Esempio n. 1
0
        public static void Edit(RaspBerryPlayingBoard raspBerryPlayingBoard, PlayingBoard playingBoard, RaspberryPin raspberryPin,
                                DataBaseDataContext connection)
        {
            raspBerryPlayingBoard.RaspberryPin = raspberryPin;

            raspBerryPlayingBoard.PlayingBoard = playingBoard;

            connection.SubmitChanges();
        }
        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);
                }
            }
        }
Esempio n. 3
0
        //public static List<int> ReservedPins = new List<int>
        //{1, 2, 4, 6, 9, 14, 17, 20, 25, 27, 28, 30, 34};

        //public static List<int> GpioPins = new List<int>()
        //{3, 5, 7, 8, 10, 11, 12, 13, 15, 16, 18, 19, 21, 22, 23, 24, 26, 29, 31, 32, 33, 35, 36, 37};

        public static RaspBerryPlayingBoard Insert(RaspberryPin raspberryPin, PlayingBoard playingBoard, DataBaseDataContext connection)
        {
            RaspBerryPlayingBoard raspBerryPlayingBoard = new RaspBerryPlayingBoard();

            raspBerryPlayingBoard.RaspberryPin = raspberryPin;

            raspBerryPlayingBoard.PlayingBoard = playingBoard;

            connection.RaspBerryPlayingBoards.InsertOnSubmit(raspBerryPlayingBoard);

            connection.SubmitChanges();

            return(raspBerryPlayingBoard);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lstRaspberryRelays.SelectedItems.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList("لیست دستگاه ها و رله ها");

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region RaspBerryPlayingBoard Cast

            int playingBoardId = (int)((RaspBerryPlayingBoard)lstRaspberryRelays.SelectedItems[0].Tag).PlayingBoardID;

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

                return;
            }

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

            DialogResult message = DataValidationMesaage.ConfirmDeleteData(raspBerryPlayingBoard.RaspberryPin.PinNumber);

            if (message == DialogResult.Yes)
            {
                raspBerryPlayingBoard.RaspberryPin.IsAvailable = true;

                RaspBerryPlayingBoard.Delete(raspBerryPlayingBoard, myConnection);

                myConnection.SubmitChanges();

                DataValidationMesaage.DeleteMessage();

                RaspberryPin.LoadComboBoxAvailables(cmbRaspberryRelay, myConnection);

                RaspBerryPlayingBoard.ShowList(lstRaspberryRelays, myConnection);
            }

            myConnection.Dispose();
        }
Esempio n. 5
0
        public static void Delete(RaspBerryPlayingBoard raspBerryPlayingBoard, DataBaseDataContext connection)
        {
            connection.RaspBerryPlayingBoards.DeleteOnSubmit(raspBerryPlayingBoard);

            connection.SubmitChanges();
        }
Esempio n. 6
0
        private void btnPayment_Click(object sender, EventArgs e)
        {
            if (gridMember.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridMember.Text);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region RentPlayingBoard Cast

            int rentid = memberRentPlayingBoard.RentPlayingBoardID;

            if (!RentPlayingBoard.Validation(rentid, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            RentPlayingBoard rentPlayingBoard = RentPlayingBoard.Get(rentid, myConnection);

            #endregion

            if (radioOther.Checked)
            {
                #region Member Cast

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

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

                    return;
                }

                _member = Member.Get(id, myConnection);

                #endregion
            }

            if (radioMySelf.Checked)
            {
                #region Member Cast

                int id = memberRentPlayingBoard.Member.ID;

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

                    return;
                }

                _member = Member.Get(id, myConnection);

                #endregion
            }

            RentPlayingBoard myRentPlayingBoard = RentPlayingBoard.Edit(rentPlayingBoard,
                                                                        DateTime.Now.ToString("HH:mm:ss"), false, myConnection);

            MemberRentPlayingBoard closerMemberRentPlayingBoard = MemberRentPlayingBoard.Insert(myRentPlayingBoard, _member, "Closer", myConnection);

            myRentPlayingBoard.PlayingBoardType.PlayingBoard.IsAvailable = true;

            int playingBoardID = myRentPlayingBoard.PlayingBoardType.PlayingBoardID;

            #region Raspberry Check and Turn off

            if (myConnection.RaspBerryPlayingBoards.Any(a => a.PlayingBoardID.Equals(playingBoardID)))
            {
                if (!RaspBerryPlayingBoard.Validation_By_PlayingBoardID(playingBoardID, myConnection))
                {
                    DataValidationMesaage.NoDataInBank();

                    return;
                }

                #region RaspBerryPlayingBoard Cast

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

                #endregion

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

            #endregion

            bool isCredit = true && cmbIsCredit.SelectedText.Equals("نسیه");

            bool isCard = true && radioCard.Checked;

            if (string.IsNullOrWhiteSpace(txtPrice.Text.Trim()) || string.IsNullOrEmpty(txtPrice.Text.Trim()))
            {
                DataValidationMesaage.BlankTextBox("مبلغ پرداختی");

                return;
            }

            if (isCard)
            {
                if (string.IsNullOrWhiteSpace(txtCardPaymentIdentity.Text.Trim()) || string.IsNullOrEmpty(txtCardPaymentIdentity.Text.Trim()))
                {
                    DataValidationMesaage.BlankTextBox("شناسه پرداخت");

                    return;
                }

                if (myConnection.CardSerialPayments.Any(a => a.CardPaymentIdentity.Equals(txtCardPaymentIdentity.Text.Trim())))
                {
                    DataValidationMesaage.DuplicateData("شناسه پرداخت");

                    return;
                }
            }

            Payment payment = Payment.Insert(int.Parse(txtPrice.Text.Trim()), DateTime.Now, isCredit, isCard, "", closerMemberRentPlayingBoard.ID, _member, myConnection);

            if (isCard)
            {
                CardSerialPayment.Insert(txtCardPaymentIdentity.Text.Trim(), txtCardNumber.Text.Trim(),
                                         txtAccountNumber.Text.Trim(), payment, (BankAccount)cmbBankAccount.SelectedItem, myConnection);
            }

            myConnection.SubmitChanges();



            MessageBox.Show("بازی تمام شد.");

            DialogResult message = MessageBox.Show(
                "پرداخت انجام شد و میز بازی بسته شد. آیا مایل هستید پنجره جاری بسته شود؟ ",
                "کاربر گرامی", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (message == DialogResult.Yes)
            {
                this.Close();
            }
            myConnection.Dispose();
        }
Esempio n. 7
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);
        }