예제 #1
0
        public static RentPlayingBoard Edit(RentPlayingBoard rentPlayingBoard, string endTime, bool status,
                                            DataBaseDataContext connection)
        {
            rentPlayingBoard.EndTime = endTime;

            rentPlayingBoard.Status = status;

            connection.SubmitChanges();

            return(rentPlayingBoard);
        }
        public static void Edit(MemberRentPlayingBoard memberRentPlayingBoard, RentPlayingBoard rentPlayingBoard, Member member,
                                string type, DataBaseDataContext connection)
        {
            memberRentPlayingBoard.Type = type;

            memberRentPlayingBoard.RentPlayingBoard = rentPlayingBoard;

            memberRentPlayingBoard.Member = member;

            connection.SubmitChanges();
        }
예제 #3
0
        public static RentPlayingBoard Insert(PlayingBoardType playingBoardType, DateTime registerDate,
                                              string startTime, string endTime, bool status, DataBaseDataContext connection)
        {
            RentPlayingBoard rentPlayingBoard = new RentPlayingBoard(registerDate, startTime, endTime, status);

            rentPlayingBoard.PlayingBoardType = playingBoardType;

            connection.RentPlayingBoards.InsertOnSubmit(rentPlayingBoard);

            connection.SubmitChanges();

            return(rentPlayingBoard);
        }
        public static MemberRentPlayingBoard Insert(RentPlayingBoard rentPlayingBoard, Member member,
                                                    string type, DataBaseDataContext connection)
        {
            MemberRentPlayingBoard memberRentPlayingBoard = new MemberRentPlayingBoard(type);

            memberRentPlayingBoard.RentPlayingBoard = rentPlayingBoard;

            memberRentPlayingBoard.Member = member;

            connection.MemberRentPlayingBoards.InsertOnSubmit(memberRentPlayingBoard);

            connection.SubmitChanges();

            return(memberRentPlayingBoard);
        }
예제 #5
0
        public static void Edit(RentPlayingBoard rentPlayingBoard, PlayingBoardType playingBoardType,
                                DateTime registerDate, string startTime, string endTime, bool status,
                                DataBaseDataContext connection)
        {
            rentPlayingBoard.RegisterDate = registerDate;

            rentPlayingBoard.StartTime = startTime;

            rentPlayingBoard.EndTime = endTime;

            rentPlayingBoard.Status = status;

            rentPlayingBoard.PlayingBoardType = playingBoardType;

            connection.SubmitChanges();
        }
        public static void LoadFilteredGridByRentPlayingBoard(RadGridView grid, RentPlayingBoard rentPlayingBoard,
                                                              DataBaseDataContext connection)
        {
            var myQuery = connection.MemberRentPlayingBoards.Where(a => a.RentPlayingBoard == rentPlayingBoard)
                          .Select(a => new
            {
                id   = a.ID,
                type = a.Type
            });

            grid.DataSource = myQuery;

            grid.Columns[1].IsVisible = false;

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

            for (int i = 0; i < grid.RowCount; i++)
            {
                grid.Rows[i].Cells[0].Value = i + 1;
            }
        }
        public static void LoadFilteredComboBoxByRentPlayingBoard(ComboBox cmbBox, RentPlayingBoard rentPlayingBoard,
                                                                  DataBaseDataContext connection)
        {
            IQueryable <MemberRentPlayingBoard> myQuery = connection.MemberRentPlayingBoards.
                                                          Where(a => a.RentPlayingBoard == rentPlayingBoard);

            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;
        }
예제 #8
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();
        }
예제 #9
0
        public static void Delete(RentPlayingBoard rentPlayingBoard, DataBaseDataContext connection)
        {
            connection.RentPlayingBoards.DeleteOnSubmit(rentPlayingBoard);

            connection.SubmitChanges();
        }
예제 #10
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();
        }