Example #1
0
        private void FrmProfile_Load(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            Phone.LoadComboBox(cmbPhone, myConnection);

            PhoneNumber.ShowListByMember(lstPhoneNumber, FrmMember.MemberProfile, myConnection);

            SocialNetworkType.LoadComboBox(cmbSocialAccount, myConnection);

            SocialNetworkAccount.ShowListByMember(lstSocialNetwork, FrmMember.MemberProfile, myConnection);

            lblCode.Text = FrmMember.MemberProfile.Code;

            lblFirstName.Text = FrmMember.MemberProfile.FirstName;

            lblLastName.Text = FrmMember.MemberProfile.LastName;

            lblBirthDate.Text = BTM.Date.ConvertToPersianDate(FrmMember.MemberProfile.BirthDate);

            lblNationalCode.Text = FrmMember.MemberProfile.NationalCode;

            byte[] myBytes = FrmMember.MemberProfile.Image;

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

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

            if (lstPhoneNumber.Items.Count == 1)
            {
                btnPhoneDelete.Enabled = false;
            }

            if (lstSocialNetwork.Items.Count == 1)
            {
                btnSocialAccountDelete.Enabled = false;
            }

            myConnection.Dispose();
        }
Example #2
0
        private void btnSocialAccountDelete_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (lstSocialNetwork.SelectedItems.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList("لیست اکانت های شبکه های اجتماعی");

                return;
            }

            #region Member Casting

            int memberId = FrmMember.MemberProfile.ID;

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

                return;
            }

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

            #endregion

            #region SocialNetworkType Casting

            int socialNetworkTypeId = ((SocialNetworkType)cmbSocialAccount.SelectedItem).ID;

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

                return;
            }

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

            #endregion

            #region SocialNetworkAccount Casting

            SocialNetworkAccount socialNetworkAccount = (SocialNetworkAccount)lstSocialNetwork.SelectedItems[0].Tag;

            if (!SocialNetworkAccount.Validation(socialNetworkAccount.ID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }
            socialNetworkAccount = SocialNetworkAccount.Get(socialNetworkAccount.ID, myConnection);

            #endregion

            DialogResult messageResult =
                DataValidationMesaage.ConfirmDeleteData(lstSocialNetwork.SelectedItems[0].SubItems[1].Text);

            if (messageResult == DialogResult.Yes)
            {
                if (socialNetworkAccount.Status)
                {
                    #region NextSocialNetworkAccount Casting

                    int nextSocialNetworkAccountIndex = (int.Parse(lstSocialNetwork.SelectedItems[0].Text)) %
                                                        lstSocialNetwork.Items.Count;

                    SocialNetworkAccount nextSocialNetworkAccount =
                        (SocialNetworkAccount)lstSocialNetwork.Items[nextSocialNetworkAccountIndex].Tag;

                    if (!SocialNetworkAccount.Validation(nextSocialNetworkAccount.ID, myConnection))
                    {
                        DataValidationMesaage.NoDataInBank();

                        return;
                    }
                    nextSocialNetworkAccount = SocialNetworkAccount.Get(nextSocialNetworkAccount.ID, myConnection);

                    var query = myConnection.SocialNetworkAccounts.Where(a => a.Member == member);

                    foreach (var item in query)
                    {
                        item.Status = false;

                        myConnection.SubmitChanges();
                    }

                    #endregion

                    nextSocialNetworkAccount.Status = true;

                    myConnection.SubmitChanges();
                }
                SocialNetworkAccount.Delete(socialNetworkAccount, myConnection);

                SocialNetworkAccount.ShowListByMember(lstSocialNetwork, FrmMember.MemberProfile, myConnection);

                if (lstSocialNetwork.Items.Count == 1)
                {
                    btnPhoneDelete.Enabled = false;
                }
            }

            txtSocialAccount.Clear();

            myConnection.Dispose();
        }
Example #3
0
        private void btnSocialAccountEdit_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (lstSocialNetwork.SelectedItems.Count == 0)
            {
                DataValidationMesaage.NoSelectedItemFromList("لیست اکانت های شبکه های اجتماعی");

                return;
            }

            #region Member Casting

            int memberId = FrmMember.MemberProfile.ID;

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

                return;
            }

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

            #endregion

            #region SocialNetworkType Casting

            int socialNetworkTypeId = ((SocialNetworkType)cmbSocialAccount.SelectedItem).ID;

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

                return;
            }

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

            #endregion

            #region SocialNetworkAccount Casting

            SocialNetworkAccount socialNetworkAccount = (SocialNetworkAccount)lstSocialNetwork.SelectedItems[0].Tag;

            if (!SocialNetworkAccount.Validation(socialNetworkAccount.ID, myConnection))
            {
                DataValidationMesaage.NoDataInBank();

                return;
            }
            socialNetworkAccount = SocialNetworkAccount.Get(socialNetworkAccount.ID, myConnection);

            #endregion

            DialogResult message = MessageBox.Show("در صورت تایید اکانت فعلی فعال گردیده و مابقی غیرفعال میگردند",
                                                   "کاربر گرامی", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (message == DialogResult.Yes)
            {
                if (lstSocialNetwork.SelectedItems.Count == 0)
                {
                    DataValidationMesaage.NoSelectedItemFromList("لیست اکانت های شبکه های اجتماعی");

                    return;
                }


                var query = myConnection.SocialNetworkAccounts.Where(a => a.Member == member);

                foreach (var item in query)
                {
                    item.Status = false;

                    myConnection.SubmitChanges();
                }

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

                txtSocialAccount.Clear();

                SocialNetworkAccount.ShowListByMember(lstSocialNetwork, member, myConnection);
            }

            myConnection.Dispose();
        }
Example #4
0
        private void btnSocialAccountSave_Click(object sender, EventArgs e)
        {
            DataBaseDataContext myConnection = Setting.DataBase;

            if (string.IsNullOrWhiteSpace(txtSocialAccount.Text) || string.IsNullOrEmpty(txtSocialAccount.Text))
            {
                DataValidationMesaage.BlankTextBox("اکانت شبکه های اجتماعی");

                return;
            }

            #region Member Casting

            int memberId = FrmMember.MemberProfile.ID;

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

                return;
            }

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

            #endregion

            #region SocialNetworkType Casting

            int socialNetworkTypeId = ((SocialNetworkType)cmbSocialAccount.SelectedItem).ID;

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

                return;
            }

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

            #endregion

            if (myConnection.SocialNetworkAccounts.Any(
                    a => a.Account == txtSocialAccount.Text.Trim() && a.Member == member &&
                    a.SocialNetworkType == socialNetworkType))
            {
                DataValidationMesaage.DuplicateData(txtSocialAccount.Text.Trim());

                return;
            }

            var query = myConnection.SocialNetworkAccounts.Where(a => a.Member == member);

            foreach (var item in query)
            {
                item.Status = false;

                myConnection.SubmitChanges();
            }



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

            DataValidationMesaage.AcceptMessage(socialNetworkAccount.Account);

            SocialNetworkAccount.ShowListByMember(lstSocialNetwork, member, myConnection);

            txtSocialAccount.Clear();

            if (lstSocialNetwork.Items.Count > 1)
            {
                btnSocialAccountDelete.Enabled = true;
            }

            myConnection.Dispose();
        }