protected void btnRegister_Click(object sender, EventArgs e)
        {
            int type = Convert.ToInt32(lstTypes.SelectedValue);
            BLL.MemberTypeSpecDuration bllSpec = new MemberTypeSpecDuration();
            if (!bllSpec.LoadByMemberTypeSpecID(type))
                return;
            int val = 0;//Convert.ToInt32(bllSpec.Points);
            if (BLL.Member.CurrentMember.Credit_Point < val)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Error3", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام العملية.'); });", true);
                return;
            }
            MembershipCreateStatus objstatus;
            MembershipUser objUser = Membership.CreateUser(UserName.Text, Password.Text, Email.Text, Question.Text, Answer.Text.Trim(), true, out objstatus);
            bool success = true;
            switch (objstatus)
            {
                case MembershipCreateStatus.DuplicateUserName:
                    ErrorMessage.Text = GetLocalResourceObject("duplicateUsername").ToString();
                    ErrorMessage.Visible = true;
                    success = false;
                    break;
                case MembershipCreateStatus.InvalidPassword:
                    ErrorMessage.Text = GetLocalResourceObject("invalidPass").ToString();
                    ErrorMessage.Visible = true;
                    success = false;
                    break;
                case MembershipCreateStatus.ProviderError:
                case MembershipCreateStatus.UserRejected:
                    ErrorMessage.Text = GetLocalResourceObject("generalError").ToString();
                    ErrorMessage.Visible = true;
                    success = false;
                    break;
                default:
                    break;
            }
            if (success)
            {
                Member member = new Member();
                member.AddNew();
                member.Answer = Answer.Text.Trim();
                member.UserID = new Guid(objUser.ProviderUserKey.ToString());
                member.Name = objUser.UserName;
                member.IsOnLine = false;
                member.Status = 1;
                member.Save();
                try
                {
                    MailMessage msg = new MailMessage();
                    string body = GetLocalResourceObject("body").ToString();
                    string mail = GetLocalResourceObject("mail").ToString();

                    member.ActivationCode = Guid.NewGuid();
                    member.Save();
                    string mailto = objUser.Email;
                    msg.To.Add(mailto);
                    msg.From = new MailAddress(mail);
                    msg.Subject = GetLocalResourceObject("subject").ToString();
                    msg.IsBodyHtml = true;
                    msg.BodyEncoding = System.Text.Encoding.Unicode;

                    msg.Body = string.Format(body, objUser.UserName, member.ActivationCode.ToString());

                    SmtpClient client = new SmtpClient(GetLocalResourceObject("mailserver").ToString(), 25);

                    client.UseDefaultCredentials = false;

                    client.Credentials = new System.Net.NetworkCredential(mail, GetLocalResourceObject("mailpass").ToString());
                    client.Send(msg);

                    member.MemberType.MemberTypeSpecDurationID = bllSpec.ID;
                    member.MemberType.CreateBy = BLL.Member.CurrentMember.MemberID;
                    member.MemberType.StartDate = DateTime.Now;
                    member.MemberType.EndDate = DateTime.Now.AddMonths(Convert.ToInt32(lstTypeDuration.SelectedValue));
                    member.MemberType.Save();

                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Success1", @"$(document).ready(function () { notify('success', 'تم ترقية الإسم بنجاح.'); });", true);

                    BLL.MemberLog log = new BLL.MemberLog();
                    log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.ChangeMemberType() { MemberName = member.Name, NewTypeName = member.MemberType.MemberTypeSpecDuration.MemberTypeSpec.Name, NewTypeExpiryDate = member.MemberType.EndDate, Points = val }, member.MemberID, null);
                }
                catch (Exception)
                {

                }

                uiPanelDone.Visible = true;
                uiPanelRegister.Visible = false;
                ClearFields();
            }
        }
        protected void uiLinkButtonConfirm_Click(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();
            if (user.PasswordQuestion == uiDropDownListQuestion.SelectedValue && BLL.Member.CurrentMember.Answer == uiTextBoxAnswer.Text.Trim())
            {
                if (!String.IsNullOrEmpty(hdnMember.Value))
                {
                    Member upgrademember = new Member();
                    upgrademember.LoadByPrimaryKey(Convert.ToInt32(hdnMember.Value));

                    try
                    {
                        int durationID = Convert.ToInt32(hdnDuration.Value);
                        int specID = Convert.ToInt32(hdnSpec.Value);
                        BLL.MemberTypeSpecDuration bllMemberTypeSpecDuration = new MemberTypeSpecDuration();
                        bllMemberTypeSpecDuration.Where.TypeDurationID.Value = durationID;
                        bllMemberTypeSpecDuration.Where.MemberTypeSpecID.Value = specID;
                        bllMemberTypeSpecDuration.Query.Load();
                        int points = bllMemberTypeSpecDuration.Points;

                        if (BLL.Member.CurrentMember.Credit_Point < points)
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Error3", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام العملية.'); });", true);
                            return;
                        }

                        BLL.Member.CurrentMember.Credit_Point -= points;
                        BLL.Member.CurrentMember.Save();

                        //delete old records
                        BLL.MemberType bllMemberType = new MemberType();
                        bllMemberType.DeleteMemberTypes(upgrademember.MemberID);

                        upgrademember.MemberType.MemberTypeSpecDurationID = bllMemberTypeSpecDuration.ID;
                        upgrademember.MemberType.CreateBy = BLL.Member.CurrentMember.MemberID;
                        upgrademember.MemberType.StartDate = DateTime.Now;
                        upgrademember.MemberType.EndDate = DateTime.Now.AddMonths(bllMemberTypeSpecDuration.TypeDuration.MonthesNumber);
                        upgrademember.MemberType.Save();

                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Success1", @"$(document).ready(function () { notify('success', 'تم ترقية الإسم بنجاح.'); });", true);

                        BLL.MemberLog log = new BLL.MemberLog();
                        log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.ChangeMemberType() { MemberName = upgrademember.Name, NewTypeName = upgrademember.MemberType.MemberTypeSpecDuration.MemberTypeSpec.Name, NewTypeExpiryDate = upgrademember.MemberType.EndDate, Points = points }, upgrademember.MemberID, null);

                        lblPoints.Text = BLL.Member.CurrentMember.Credit_Point.ToString();

                        NotifyMember(upgrademember.MemberID, bllMemberTypeSpecDuration.MemberTypeSpecID);

                        LoadBalance();
                    }
                    catch (Exception ex)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Error11", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أعد المحاولة.'); });", true);
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Error4", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أعد المحاولة.'); });", true);
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Error5", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك تأكد من السؤال والإجابة السرى.'); });", true);
                return;
            }
        }
        protected void uiLinkButtonSaveMember_Click(object sender, EventArgs e)
        {
            int type = Convert.ToInt32(uiRadioButtonListTypes.SelectedValue);
            BLL.MemberTypeSpecDuration bllSpec = new MemberTypeSpecDuration();
            if (!bllSpec.LoadByMemberTypeSpecID(type))
                return;
            int val = 0;//Convert.ToInt32(bllSpec.Points);
            if (BLL.Member.CurrentMember.Credit_Point < val)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "balanceError", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام العملية.'); });", true);
                return;
            }

            Member member = new Member();
            if (!member.LoadByPrimaryKey(Convert.ToInt32(hdnMember.Value)))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "NoacountError", @"$(document).ready(function () { notify('error', 'حدث خطأ . لا يوجد حساب بهذا الإسم.'); });", true);
                return;
            }

            BLL.MembershipBLL membership = new BLL.MembershipBLL();
            string msg;
            string oldname = member.Name;
            if (!string.IsNullOrEmpty(uiTextBoxNewName.Text))
            {
                if (membership.ChangeUsername(oldname, uiTextBoxNewName.Text, Membership.ApplicationName, out msg))
                {
                    member.Name = uiTextBoxNewName.Text;
                    member.Save();
                }
                else
                {
                    uiTextBoxNewName.Text = oldname;
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "changeName", @"$(document).ready(function () { notify('error', 'حدث خطأ ." + msg + ".'); });", true);
                    return;
                }
            }
            member.MemberType.MemberTypeSpecDurationID = bllSpec.ID;
            member.MemberType.CreateBy = BLL.Member.CurrentMember.MemberID;
            member.MemberType.StartDate = DateTime.Now;
            member.MemberType.EndDate = DateTime.Now.AddMonths(Convert.ToInt32(uiDropDownListTypeDuration.SelectedValue));
            member.MemberType.OldName = oldname;
            member.MemberType.Save();

            Page.ClientScript.RegisterStartupScript(this.GetType(), "Success1", @"$(document).ready(function () { notify('success', 'تم ترقية الإسم بنجاح.'); });", true);

            uiPanelUpgradeSuccess.Visible = true;
            uiPanelUpgrade.Visible = false;
            clearUpgradeFields();

            BLL.MemberLog log = new BLL.MemberLog();
            log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.ChangeMemberType() { MemberName = member.Name,OldName=oldname, NewTypeName = member.MemberType.MemberTypeSpecDuration.MemberTypeSpec.Name, NewTypeExpiryDate = member.MemberType.EndDate, Points = val }, member.MemberID, null);

            Chat2Connect.usercontrols.MemberTypes.NotifyMember(member.MemberID, type);
            Chat2Connect.usercontrols.MemberTypes.NotifyMember(member.MemberID, member.UserName);
        }