protected void uiGridViewCurrentUsers_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "EditUser")
     {
         SiteUsers objData = new SiteUsers();
         objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
         CurrentSiteUsers = objData;
         uiTextBoxFullName.Text = objData.UserFullName;
         uiTextBoxUserName.Text = objData.UserName;
         uiTextBoxTele.Text = objData.Telephone;
         uiFCKeditorPage.Value = Server.HtmlDecode(objData.UserPage);
         uiTextBoxMail.Text = objData.Email;
         uiTextBoxJob.Text = objData.Job;
         uiTextBoxInfo.Text = objData.OtherInfo;
         if(!objData.IsColumnNull("IsApproved"))
             uiCheckBoxApproved.Checked = objData.IsApproved;
         uiPanelViewAllPages.Visible = false;
         uiPanelEdit.Visible = true;
     }
     else if (e.CommandName == "DeleteUser")
     {
         SiteUsers objData = new SiteUsers();
         objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
         objData.MarkAsDeleted();
         objData.Save();
         BindData();
         BindDataRequests();
     }
 }
        protected void uiLinkButtonUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                SiteUsers objData = new SiteUsers();
                objData.AddNew();
                objData.UserFullName = uiTextBoxFullName.Text;
                objData.UserName = uiTextBoxUserName.Text;
                objData.Telephone = uiTextBoxTele.Text;
                objData.Email = uiTextBoxMail.Text;
                objData.Job = uiTextBoxJob.Text;
                objData.OtherInfo = uiTextBoxInfo.Text;
                if (!string.IsNullOrEmpty(uiTextBoxPassword.Text))
                    objData.UserPassword = uiTextBoxPassword.Text;
                objData.Save();
                clearFields();

                try
                {

                    MailMessage msg2 = new MailMessage();
                    string mailtouser = uiTextBoxMail.Text;
                    string mail = ConfigurationManager.AppSettings["mail"];
                    msg2.To.Add(mailtouser);
                    msg2.From = new MailAddress(mail);
                    msg2.Subject = " رسالة تأكيد لطلب عضوية";
                    msg2.IsBodyHtml = true;
                    msg2.BodyEncoding = System.Text.Encoding.Unicode;

                    msg2.Body = "<div style='direction:rtl;'>";
                    msg2.Body = "تم إرسال طلبك لنا وسوف يتم الرد عليك قريباً .";
                    msg2.Body += "</div>";

                    SmtpClient client2 = new SmtpClient(ConfigurationManager.AppSettings["mailserver"], 25);
                    //SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                    //client.EnableSsl = true;
                    client2.UseDefaultCredentials = false;

                    client2.Credentials = new System.Net.NetworkCredential(mail, ConfigurationManager.AppSettings["mailpass"]);
                    client2.Send(msg2);
                    divmsg.Visible = true;
                }
                catch (Exception ex)
                {
                    //uiLabelMessage.Visible = true;
                    //uiLabelMessage.Text = "حدث خطأ . من فضلك حاول مرة أخرى .";
                }

                divmsg.Visible = true;
            }
            catch (Exception)
            {
                uiLabelError.Visible = true;
            }
        }
 protected void uiLinkButtonUpdate_Click(object sender, EventArgs e)
 {
     SiteUsers objData = new SiteUsers();
     objData = (SiteUsers)Session["CurrentUser"];
     objData.UserFullName = uiTextBoxFullName.Text;
     objData.UserName = uiTextBoxUserName.Text;
     objData.Telephone = uiTextBoxTele.Text;
     objData.Email = uiTextBoxMail.Text;
     objData.Job = uiTextBoxJob.Text;
     objData.OtherInfo = uiTextBoxInfo.Text;
     if (!string.IsNullOrEmpty(uiTextBoxPassword.Text))
         objData.UserPassword = uiTextBoxPassword.Text;
     objData.Save();
     uiLabelSucc.Visible = true;
     LoadUserProfile();
 }
 protected void uiLinkButtonUpdate_Click(object sender, EventArgs e)
 {
     SiteUsers objData = new SiteUsers();
     if (CurrentSiteUsers != null)
         objData = CurrentSiteUsers;
     else
     {
         objData.AddNew();
     }
     objData.UserFullName = uiTextBoxFullName.Text;
     objData.UserName = uiTextBoxUserName.Text;
     objData.Telephone = uiTextBoxTele.Text;
     objData.UserPage = Server.HtmlEncode(uiFCKeditorPage.Value);
     objData.Email = uiTextBoxMail.Text;
     objData.Job = uiTextBoxJob.Text;
     objData.OtherInfo = uiTextBoxInfo.Text;
     objData.IsApproved = uiCheckBoxApproved.Checked;
     if (!string.IsNullOrEmpty(uiTextBoxPassword.Text))
         objData.UserPassword = uiTextBoxPassword.Text;
     objData.Save();
     CurrentSiteUsers = null;
     uiPanelViewAllPages.Visible = true;
     uiPanelEdit.Visible = false;
     BindData();
     BindDataRequests();
 }