コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            PlayingBoard playingBoard = FrmPlayingBoard.SelectedPlayingBoard;

            if (int.Parse(txtPrice.Text.Trim()).Equals(0) || string.IsNullOrWhiteSpace(txtPrice.Text.Trim()) || string.IsNullOrEmpty(txtPrice.Text.Trim()))
            {
                DataValidationMesaage.BlankTextBox("بهای میز");

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            if (
                myConnection.PlayingBoardTypes.Any(
                    a => a.Type == cmbType.SelectedItem.ToString() && a.PlayingBoard == playingBoard))
            {
                DataValidationMesaage.DuplicateData(cmbType.SelectedItem.ToString());

                return;
            }


            PlayingBoardType.Insert(playingBoard, cmbType.SelectedItem.ToString(),
                                    int.Parse(txtPrice.Text.Trim()), myConnection);

            DataValidationMesaage.AcceptMessage();

            PlayingBoardType.ShowList_By_PlayingBoard(playingBoard, lstPlayingBoardTypes, myConnection);

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

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            PlayingBoardType playingBoardType = (PlayingBoardType)lstPlayingBoardTypes.SelectedItems[0].Tag;

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

                return;
            }

            cmbType.SelectedItem = playingBoardType.Type;

            txtPrice.Text = playingBoardType.Price.ToString();

            FormManagement.EnableYesNo(this.Controls);

            myConnection.Dispose();
        }
コード例 #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);
        }
コード例 #4
0
        private void btnYes_Click(object sender, EventArgs e)
        {
            PlayingBoard playingBoard = FrmPlayingBoard.SelectedPlayingBoard;

            if (int.Parse(txtPrice.Text.Trim()).Equals(0) || string.IsNullOrWhiteSpace(txtPrice.Text.Trim()) || string.IsNullOrEmpty(txtPrice.Text.Trim()))
            {
                DataValidationMesaage.BlankTextBox("بهای میز");

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            PlayingBoardType playingBoardType = (PlayingBoardType)lstPlayingBoardTypes.SelectedItems[0].Tag;

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

                return;
            }

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

            if (
                myConnection.PlayingBoardTypes.Any(
                    a =>
                    a.Type == cmbType.SelectedItem.ToString() && a.PlayingBoard == playingBoard &&
                    a.ID != playingBoardType.ID))
            {
                DataValidationMesaage.DuplicateData(cmbType.SelectedItem.ToString());

                return;
            }

            if (myConnection.PlayingBoardTypes.Any(a =>
                                                   a.PlayingBoard == playingBoard &&
                                                   !a.PlayingBoard.IsAvailable))
            {
                DataValidationMesaage.DataInUse("میز بازی", lstPlayingBoardTypes.Text);

                return;
            }

            PlayingBoardType.Edit(playingBoardType, cmbType.SelectedItem.ToString(),
                                  int.Parse(txtPrice.Text.Trim()), myConnection);

            DataValidationMesaage.EditMessage();

            PlayingBoardType.ShowList_By_PlayingBoard(playingBoard, lstPlayingBoardTypes, myConnection);

            FormManagement.DisableYesNo(this.Controls);

            myConnection.Dispose();

            clearTextBox();
        }
コード例 #5
0
        public static void Edit(PlayingBoardType playingBoardType,
                                string type, int price, DataBaseDataContext connection)
        {
            playingBoardType.Type = type;

            playingBoardType.Price = price;

            connection.SubmitChanges();
        }
コード例 #6
0
        private void FrmPlayBoard_Load(object sender, EventArgs e)
        {
            cmbType.SelectedIndex = 0;

            DataBaseDataContext myConnection = Setting.DataBase;

            lblTitle.Text = FrmPlayingBoard.SelectedPlayingBoard.PlayingBoardTitle.PlayingBoardGroupTitle.GroupTitle
                            + " " + FrmPlayingBoard.SelectedPlayingBoard.PlayingBoardTitle.Title
                            + " " + FrmPlayingBoard.SelectedPlayingBoard.Number;

            PlayingBoardType.ShowList_By_PlayingBoard(FrmPlayingBoard.SelectedPlayingBoard, lstPlayingBoardTypes,
                                                      myConnection);
        }
コード例 #7
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);
        }
コード例 #8
0
        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);
        }
コード例 #9
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();
        }
コード例 #10
0
        public static void LoadFilteredGrid(RadGridView grid, PlayingBoardType playingBoardType,
                                            DataBaseDataContext connection)
        {
            var myQuery = connection.RentPlayingBoards.Where(a => a.PlayingBoardType == playingBoardType)
                          .Select(a => new
            {
                id           = a.ID,
                registerDate = a.RegisterDate,
                startTime    = a.StartTime,
                endTime      = a.EndTime,
                status       = a.Status
            });

            grid.DataSource = myQuery;

            grid.Columns[1].IsVisible = false;

            grid.Columns[2].HeaderText = "تاریخ";

            grid.Columns[2].Width = 200;

            grid.Columns[2].HeaderText = "زمان شروع";

            grid.Columns[2].Width = 100;

            grid.Columns[2].HeaderText = "زمان پایان";

            grid.Columns[2].Width = 100;

            grid.Columns[2].HeaderText = "وضعیت";

            grid.Columns[2].Width = 100;


            for (int i = 0; i < grid.RowCount; i++)
            {
                grid.Rows[i].Cells[0].Value = i + 1;
            }
        }
コード例 #11
0
        public static void LoadComboBox_By_PlayingBoardType(ComboBox cmbBox, PlayingBoardType playingBoardType,
                                                            DataBaseDataContext connection)
        {
            IQueryable <RentPlayingBoard> myQuery = connection.RentPlayingBoards.Where(a => a.PlayingBoardType == playingBoardType);

            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;
        }
コード例 #12
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();
        }
コード例 #13
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lstPlayingBoardTypes.SelectedItems.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(lstPlayingBoardTypes.Text);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            PlayingBoardType playingBoardType = (PlayingBoardType)(lstPlayingBoardTypes.SelectedItems[0].Tag);

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

                return;
            }

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

            DialogResult message = DataValidationMesaage.ConfirmDeleteData(playingBoardType.Type);

            if (message == DialogResult.Yes)
            {
                PlayingBoardType.Delete(playingBoardType, myConnection);

                DataValidationMesaage.DeleteMessage();

                PlayingBoardType.ShowList_By_PlayingBoard(FrmPlayingBoard.SelectedPlayingBoard, lstPlayingBoardTypes,
                                                          myConnection);
            }

            myConnection.Dispose();
        }
コード例 #14
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();
        }
コード例 #15
0
        public static void Delete(PlayingBoardType playingBoardType, DataBaseDataContext connection)
        {
            connection.PlayingBoardTypes.DeleteOnSubmit(playingBoardType);

            connection.SubmitChanges();
        }