Exemplo n.º 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridCabinet.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridCabinet.Text);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region Cabinet Casting

            int cabinetID = int.Parse(gridCabinet.SelectedRows[0].Cells[1].Value.ToString());

            if (!Cabinet.Validation(cabinetID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Cabinet cabinet = Cabinet.Get(cabinetID, myConnection);

            #endregion

            txtTitle.Text = cabinet.Title;

            FormManagement.EnableYesNo(this.Controls);

            txtTitle.Focus();

            myConnection.Dispose();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridPhone.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridPhone.Text);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region Phone Casting

            int phoneID = int.Parse(gridPhone.SelectedRows[0].Cells[1].Value.ToString());

            if (!Phone.Validation(phoneID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Phone phone = Phone.Get(phoneID, myConnection);

            #endregion

            txtTitle.Text = phone.Title;

            FormManagement.EnableYesNo(this.Controls);

            txtTitle.Focus();
        }
Exemplo n.º 4
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridLevel.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridLevel.Text);
                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region Level Casting

            int levelID = int.Parse(gridLevel.SelectedRows[0].Cells[1].Value.ToString());

            if (!Level.Validation(levelID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Level level = Level.Get(levelID, myConnection);

            #endregion

            txtTitle.Text = level.Title;

            //FormsManagement.EnableYesNo(btnSave, btnEdit, btnDelete, btnYes, btnNo, gridLevel);
            FormManagement.EnableYesNo(this.Controls);
            txtTitle.Focus();
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
        private void btnNo_Click(object sender, EventArgs e)
        {
            ClearTextBox();

            //FormsManagement.DisableYesNo(btnSave, btnEdit, btnDelete, btnYes, btnNo, gridLevel);
            FormManagement.DisableYesNo(this.Controls);
        }
Exemplo n.º 7
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridBankAccount.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridBankAccount.Text);
                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region BankAccount Casting

            int bankAccountId = int.Parse(gridBankAccount.SelectedRows[0].Cells[1].Value.ToString());

            if (!BankAccount.Validation(bankAccountId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            BankAccount bankAccount = BankAccount.Get(bankAccountId, myConnection);

            #endregion

            txtBankTitle.Text = bankAccount.BankTitle;

            txtCardNumber.Text = bankAccount.CardNumber;

            txtAccountNumber.Text = bankAccount.AccountNumber;

            FormManagement.EnableYesNo(this.Controls);

            txtBankTitle.Focus();
        }
Exemplo n.º 8
0
        private void btnNo_Click(object sender, EventArgs e)
        {
            FormManagement.DisableYesNo(this.Controls);

            ClearTextBox();

            txtFirstName.Focus();
        }
Exemplo n.º 9
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();
        }
        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 PlayingBoardTitle Casting

            int playingBoardTitleID = int.Parse(gridPlayingBoardTitle.SelectedRows[0].Cells[1].Value.ToString());

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

                return;
            }

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

            #endregion

            if (myConnection.PlayingBoardTitles.Any(a => a.Title == txtTitle.Text.Trim() && a.ID != playingBoardTitleID))
            {
                DataValidationMesaage.DuplicateData(txtTitle.Text);

                return;
            }

            PlayingBoardTitle.Edit(playingBoardTitle, txtTitle.Text.Trim(),
                                   myConnection);

            DataValidationMesaage.EditMessage();

            ClearTextBox();

            txtTitle.Focus();

            PlayingBoardTitle.LoadGrid_By_PlayingBoardGroupTitle(gridPlayingBoardTitle,
                                                                 FrmPlayingBoard.SelectedPlayingBoardGroupTitle, myConnection);

            FormManagement.DisableYesNo(this.Controls);

            //myConnection.Dispose();
        }
        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 SocialNetworkType Casting

            int socialNetworkTypeID = int.Parse(gridSocialNetworkType.SelectedRows[0].Cells[1].Value.ToString());

            if (!SocialNetworkType.Validation(socialNetworkTypeID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            SocialNetworkType socialNetworkType = SocialNetworkType.Get(socialNetworkTypeID, myConnection);

            #endregion

            if (myConnection.SocialNetworkTypes.Any(a => a.Title == txtTitle.Text.Trim() && a.ID != socialNetworkType.ID))
            {
                DataValidationMesaage.DuplicateData(txtTitle.Text);

                return;
            }

            SocialNetworkType.Edit(socialNetworkType, txtTitle.Text.Trim(), myConnection);

            DataValidationMesaage.EditMessage();

            clearTextBox();

            txtTitle.Focus();

            SocialNetworkType.LoadGrid(gridSocialNetworkType, myConnection);

            FormManagement.DisableYesNo(this.Controls);
        }
Exemplo n.º 12
0
        private void btnYes_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            #region Level Casting

            int levelID = int.Parse(gridLevel.SelectedRows[0].Cells[1].Value.ToString());

            if (!Level.Validation(levelID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Level level = Level.Get(levelID, myConnection);

            #endregion

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

                return;
            }
            if (myConnection.Levels.Any(a => a.Title == txtTitle.Text.Trim() && a.ID != levelID))
            {
                DataValidationMesaage.DuplicateData(txtTitle.Text);

                return;
            }
            Level.Edit(level, txtTitle.Text.Trim(), myConnection);

            if (myConnection.Levels.Any(a => a.ID != levelID && a.Title == txtTitle.Text.Trim()))
            {
                DataValidationMesaage.EditMessage();
            }

            ClearTextBox();

            Level.LoadGrid(gridLevel, myConnection);

            //FormsManagement.DisableYesNo(btnSave, btnEdit, btnDelete, btnYes, btnNo, gridLevel);
            FormManagement.DisableYesNo(this.Controls);
        }
Exemplo n.º 13
0
        private void btnYes_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            #region Cabinet Casting

            int cabinetID = int.Parse(gridCabinet.SelectedRows[0].Cells[1].Value.ToString());

            if (!Cabinet.Validation(cabinetID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Cabinet cabinet = Cabinet.Get(cabinetID, myConnection);

            #endregion

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

                return;
            }

            if (myConnection.Cabinets.Any(a => a.Title == txtTitle.Text.Trim() && a.ID != cabinet.ID))
            {
                DataValidationMesaage.DuplicateData(txtTitle.Text);

                return;
            }

            Cabinet.Edit(cabinet, txtTitle.Text.Trim(), cabinet.IsAvailable, myConnection);

            DataValidationMesaage.EditMessage();

            clearTextBox();

            Cabinet.LoadGridColorful(gridCabinet, myConnection);

            FormManagement.DisableYesNo(this.Controls);

            myConnection.Dispose();
        }
Exemplo n.º 14
0
        private void btnYes_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            #region BankAccount Casting

            int bankAccountId = int.Parse(gridBankAccount.SelectedRows[0].Cells[1].Value.ToString());

            if (!BankAccount.Validation(bankAccountId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            BankAccount bankAccount = BankAccount.Get(bankAccountId, myConnection);

            #endregion

            if (string.IsNullOrWhiteSpace(txtBankTitle.Text.Trim()) || string.IsNullOrEmpty(txtBankTitle.Text.Trim()))
            {
                DataValidationMesaage.BlankTextBox("عنوان بانک");

                return;
            }

            if (myConnection.BankAccounts.Any(a => a.BankTitle.Equals(txtBankTitle.Text.Trim()) && a.ID != bankAccountId))
            {
                DataValidationMesaage.DuplicateData("عنوان بانک");

                return;
            }
            BankAccount.Edit(bankAccount, txtBankTitle.Text.Trim(), txtCardNumber.Text.Trim(),
                             txtAccountNumber.Text.Trim(), myConnection);

            DataValidationMesaage.EditMessage();

            ClearTextBoxes();

            BankAccount.LoadGrid(gridBankAccount, myConnection);

            FormManagement.DisableYesNo(this.Controls);

            myConnection.Dispose();
        }
Exemplo n.º 15
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 Team Casting

            int teamID = int.Parse(gridTeam.SelectedRows[0].Cells[1].Value.ToString());

            if (!Team.Validation(teamID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Team team = Team.Get(teamID, myConnection);

            #endregion

            if (myConnection.Teams.Any(a => a.Title == txtTitle.Text.Trim() && a.ID != team.ID))
            {
                DataValidationMesaage.DuplicateData(txtTitle.Text);

                return;
            }

            Team.Edit(team, txtTitle.Text.Trim(), myConnection);

            DataValidationMesaage.EditMessage();

            clearTextBox();

            Team.LoadGrid(gridTeam, myConnection);

            FormManagement.DisableYesNo(this.Controls);
        }
Exemplo n.º 16
0
        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();
        }
Exemplo n.º 17
0
        private void btnNo_Click(object sender, EventArgs e)
        {
            ClearTextBoxes();

            FormManagement.DisableYesNo(this.Controls);
        }
 private void gridSocialNetworkType_KeyDown(object sender, KeyEventArgs e)
 {
     FormManagement.KeyDelToRemove(e, btnDelete);
 }
Exemplo n.º 19
0
        private void btnNo_Click(object sender, EventArgs e)
        {
            FormManagement.DisableYesNo(this.Controls);

            txtTitle.Focus();
        }
Exemplo n.º 20
0
        private void btnYes_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFirstName.Text) || string.IsNullOrEmpty(txtLastName.Text) ||
                string.IsNullOrEmpty(txtNationalCode.Text) ||
                string.IsNullOrWhiteSpace(txtFirstName.Text) || string.IsNullOrWhiteSpace(txtLastName.Text) ||
                string.IsNullOrWhiteSpace(txtNationalCode.Text))
            {
                MessageBox.Show("کاربر گرامی مقادیر نام یا نام خانوادگی یا کد ملی نمی توانند خالی باشند ", "اخطار در ورود اطلاعات", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region Level Casting

            int levelId = ((Level)cmbLevel.SelectedItem).ID;

            if (!Level.Validation(levelId, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Level level = Level.Get(levelId, myConnection);

            #endregion

            #region Member Casting

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

            if (!Member.Validation(memeberId, myConnection))

            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Member member = Member.Get(memeberId, myConnection);

            #endregion

            #region PhoneNumber Casting

            string gridPhoneNumber = gridMember.SelectedRows[0].Cells[9].Value.ToString();

            PhoneNumber phoneNumber =
                myConnection.PhoneNumbers.FirstOrDefault(a => a.Number == gridPhoneNumber && a.Member == member);

            if (phoneNumber != null && !PhoneNumber.Validation(phoneNumber.ID, myConnection))

            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            #endregion

            #region SocialNetworkAccount Casting

            string gridSocialAccount = gridMember.SelectedRows[0].Cells[8].Value.ToString();

            SocialNetworkAccount socialNetworkAccount =
                myConnection.SocialNetworkAccounts.FirstOrDefault(
                    a => a.Account == gridSocialAccount && a.Member == member);

            if (socialNetworkAccount != null && !SocialNetworkAccount.Validation(socialNetworkAccount.ID, myConnection))

            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            #endregion

            #region Phone Casting

            int phoneId = ((Phone)cmbPhone.SelectedItem).ID;

            if (!Phone.Validation(phoneId, myConnection))
            {
                //TODO Fix Message

                DataValidationMesaage.NoDataInBank();

                return;
            }

            Phone phone = Phone.Get(phoneId, myConnection);

            #endregion

            #region SocialNetwork Casting

            int socialNetworkTypeID = ((SocialNetworkType)cmbSocialNetworkType.SelectedItem).ID;

            if (!Phone.Validation(socialNetworkTypeID, myConnection))
            {
                //TODO Fix Message

                DataValidationMesaage.NoDataInBank();

                return;
            }

            SocialNetworkType socialNetworkType = SocialNetworkType.Get(socialNetworkTypeID, myConnection);

            #endregion

            bool query = myConnection.PhoneNumbers.Any(a => a.Number == CorrectPhoneNumber() &&
                                                       a.Member == member && a.ID != phoneNumber.ID);
            if (query)
            {
                DataValidationMesaage.DuplicateData("شماره تماس برای این کاربر");

                return;
            }

            query =
                myConnection.SocialNetworkAccounts.Any(
                    a =>
                    a.Account == txtSocialAccount.Text.Trim() && a.Member == member &&
                    a.ID != socialNetworkAccount.ID);

            if (query)
            {
                DataValidationMesaage.DuplicateData("اکانت شبکه های اجتماعی برای این کاربر");

                return;
            }

            query = myConnection.Members.Any(a => a.NationalCode == txtNationalCode.Text.Trim() && a.ID != memeberId);

            if (query)
            {
                DataValidationMesaage.DuplicateData("کاربر با این کد ملی");

                return;
            }

            if (!flag)
            {
                Image picImage = Properties.Resources.profile;

                picBox.Image = picImage;

                picImage.Save(_memory, picBox.Image.RawFormat);

                _myArray = _memory.GetBuffer();
            }

            if (flag)
            {
                _image.Save(_memory, picBox.Image.RawFormat);

                _myArray = _memory.GetBuffer();
            }


            Phone.Edit(phone, cmbPhone.Text.Trim(), myConnection);

            PhoneNumber.Edit(phoneNumber, phone, member, true, CorrectPhoneNumber(), myConnection);

            SocialNetworkType.Edit(socialNetworkType, cmbSocialNetworkType.Text.Trim(), myConnection);

            SocialNetworkAccount.Edit(socialNetworkAccount, socialNetworkType, member, true, txtSocialAccount.Text.Trim(), myConnection);

            //TODO How to check Has Cabinet or not?

            Member.Edit(member, txtCode.Text.Trim(), txtFirstName.Text.Trim(), txtLastName.Text.Trim(),
                        txtNationalCode.Text.Trim(), BTM.Date.ConvertToGorgianDate(txtBirthDate.Text.Trim()),
                        cmbType.Text.Trim(), cmbSex.Text.Trim(), _myArray, level, myConnection);

            DataValidationMesaage.EditMessage();

            ClearTextBox();

            txtFirstName.Focus();

            Member.LoadGridJoinSocialNetworkAccountJoinPhoneNumber(gridMember, myConnection);

            FormManagement.DisableYesNo(this.Controls);
        }
Exemplo n.º 21
0
 private void gridPhone_KeyDown(object sender, KeyEventArgs e)
 {
     FormManagement.KeyDelToRemove(e, btnDelete);
 }
Exemplo n.º 22
0
 private void txtTitle_KeyDown(object sender, KeyEventArgs e)
 {
     FormManagement.KeyEnterToSaveChanges(e, btnYes, btnSave);
 }
Exemplo n.º 23
0
        private void btnNo_Click(object sender, EventArgs e)
        {
            FormManagement.DisableYesNoIncludingComboBox(this.Controls);

            txtNumber.Focus();
        }
Exemplo n.º 24
0
 private void gridPlayingBoardGroupTitle_KeyDown(object sender, KeyEventArgs e)
 {
     FormManagement.KeyDelToRemove(e, btnDelete);
 }
Exemplo n.º 25
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridMember.SelectedRows.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList(gridMember.Text);

                return;
            }

            DataBaseDataContext myConnection = Setting.DataBase;

            #region Member Casting

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

            if (!Member.Validation(memeberId, myConnection))

            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            Member member = Member.Get(memeberId, myConnection);

            #endregion

            #region PhoneNumber Casting

            string gridPhoneNumber = gridMember.SelectedRows[0].Cells[9].Value.ToString();

            PhoneNumber phoneNumber =
                myConnection.PhoneNumbers.FirstOrDefault(a => a.Number == gridPhoneNumber && a.Member == member);

            if (!PhoneNumber.Validation(phoneNumber.ID, myConnection))

            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            #endregion

            #region SocialNetworkAccount Casting

            string gridSocialAccount = gridMember.SelectedRows[0].Cells[8].Value.ToString();

            SocialNetworkAccount socialNetworkAccount =
                myConnection.SocialNetworkAccounts.FirstOrDefault(
                    a => a.Account == gridSocialAccount && a.Member == member);

            if (!SocialNetworkAccount.Validation(socialNetworkAccount.ID, myConnection))

            {
                DataValidationMesaage.NoDataInBank();

                return;
            }

            #endregion

            #region Fill TextBoxes

            txtCode.Text = member.Code;

            txtFirstName.Text = member.FirstName;

            txtLastName.Text = member.LastName;

            txtBirthDate.Text = BTM.Date.ConvertToPersianDate(member.BirthDate);

            txtNationalCode.Text = member.NationalCode;

            cmbSex.SelectedItem = member.Sex;

            cmbType.SelectedItem = member.Type;

            cmbLevel.SelectedItem = member.Level;

            cmbPhone.SelectedItem = phoneNumber.Phone;

            txtPhoneNumber.Text = phoneNumber.Number;

            cmbSocialNetworkType.SelectedItem = socialNetworkAccount.SocialNetworkType;

            txtSocialAccount.Text = socialNetworkAccount.Account;

            byte[] myBytes = member.Image;

            if (myBytes != null)
            {
                _memoryStream = new MemoryStream(myBytes);

                picBox.Image = Image.FromStream(_memoryStream);
            }

            #endregion

            FormManagement.EnableYesNo(this.Controls);

            btnImageSelect.Enabled = true;

            txtFirstName.Focus();

            myConnection.Dispose();
        }