public void BindRole()
        {
            try
            {
                objRole = new Role();
                objBL_UserLoginDetails = new BL_UserLoginDetails();
                lstRole = new List<Role>();
                lstRole = objBL_Role.SelectRoleall(Convert.ToInt32(Session["CompanyID"].ToString()));

                if (lstRole.Count > 0)
                {
                    foreach (var items in lstRole)
                    {
                        ddlrole.DataValueField = "PK_RoleID";
                        ddlrole.DataTextField = "RoleName";
                    }
                    ddlrole.DataSource = lstRole;
                    ddlrole.DataBind();
                }
                ddlrole.Items.Insert(0, "-- Select --");
            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("CreateProfile.aspx:BindRole() - " + ex.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //String originalPath = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).OriginalString;
                //String parentDirectory = originalPath.Substring(0, originalPath.LastIndexOf("/"));
                //String result = originalPath.Substring(originalPath.LastIndexOf('?') + 1);
                //string DecryptQry = objCryptographicHashCode.DecryptCipherTextToPlainText(result);

                if (Request.QueryString["id"] != null)
                {
                    string DecryptQry = objCryptographicHashCode.DecryptCipherTextToPlainText(Request.QueryString["id"].ToString());
                    objUserDetails = new UserDetails();
                    objBL_UserLoginDetails = new BL_UserLoginDetails();
                    lstUserDetails = new List<UserDetails>();
                    lstUserDetails = objBL_UserLoginDetails.SelectUserDetailsList(Convert.ToInt32(DecryptQry));

                    if (lstUserDetails.Count > 0)
                    {
                        objUserDetails.PK_UserID = lstUserDetails[0].PK_UserID;
                        objUserDetails.FK_CompanyID = lstUserDetails[0].FK_CompanyID;
                        objUserDetails.LastName = lstUserDetails[0].LastName;
                        objUserDetails.FirstName = lstUserDetails[0].FirstName;
                        objUserDetails.UserName = lstUserDetails[0].UserName;
                        objUserDetails.UserType = lstUserDetails[0].UserType;
                        objUserDetails.Addressline1 = lstUserDetails[0].Addressline1;
                        objUserDetails.City1 = lstUserDetails[0].City1;
                        objUserDetails.State1 = lstUserDetails[0].State1;
                        objUserDetails.Country1 = lstUserDetails[0].Country1;
                        objUserDetails.Designation = lstUserDetails[0].Designation;
                        objUserDetails.DateOfBirth = lstUserDetails[0].DateOfBirth;
                        objUserDetails.Email_id = lstUserDetails[0].Email_id;
                        objUserDetails.ContactNo = lstUserDetails[0].ContactNo;
                        objUserDetails.AlternativeNo = lstUserDetails[0].AlternativeNo;
                        objUserDetails.MemberSince = lstUserDetails[0].MemberSince;
                        objUserDetails.MemberTill = lstUserDetails[0].MemberTill;
                        objUserDetails.IsActive = lstUserDetails[0].IsActive;
                        objUserDetails.CreatedBy = lstUserDetails[0].CreatedBy;
                        objUserDetails.CreatedOn = lstUserDetails[0].CreatedOn;
                        objUserDetails.UpdatedBy = lstUserDetails[0].PK_UserID;
                        objUserDetails.UpdatedOn = DateTime.Now;
                        objUserDetails.ReportID = lstUserDetails[0].ReportID;
                        objUserDetails.FK_RoleID = lstUserDetails[0].FK_RoleID;
                        objUserDetails.TotalMailCount = lstUserDetails[0].TotalMailCount;
                        objUserDetails.TotalContactsCount = lstUserDetails[0].TotalContactsCount;
                        objUserDetails.FK_UserPlanID = lstUserDetails[0].FK_UserPlanID;
                        objUserDetails.UserPassword = lstUserDetails[0].UserPassword;
                        objUserDetails.UserPhoto = lstUserDetails[0].UserPhoto;
                        objUserDetails.AccountActivated = true;
                        objUserDetails.SendNewsLetter = lstUserDetails[0].SendNewsLetter;

                        objBL_UserLoginDetails.AccessUpdateUserLogin(objUserDetails);
                        objUserDetails = null;
                        objBL_UserLoginDetails = null;
                        lstUserDetails = null;
                    }
                }
            }
        }
        /// <summary>
        /// Created By :: Sakthivel.R
        /// Created On :: 28-3-2015
        /// Comments :: Populating all campaign creation list in the grid.
        /// </summary>
        public void BindUserDetail()
        {
            try
            {
                if (Session["UserID"] != null)
                {
                    objUserDetails = new UserDetails();
                    objBL_UserLoginDetails = new BL_UserLoginDetails();
                    lstUserDetails = new List<UserDetails>();
                    lstUserDetails = objBL_UserLoginDetails.SelectUserDetailsList(Convert.ToInt32(Session["UserID"].ToString()));

                    if (lstUserDetails.Count > 0)
                    {
                        txtLastName.Value = lstUserDetails[0].LastName;
                        txtFirstName.Value = lstUserDetails[0].FirstName;
                        txtUserName.Value = lstUserDetails[0].UserName;
                        txtAddress.Value = lstUserDetails[0].Addressline1;
                        txtCity.Value = lstUserDetails[0].City1;
                        txtState.Value = lstUserDetails[0].State1;
                        txtCountry.Value = lstUserDetails[0].Country1;
                        txtDesignation.Value = lstUserDetails[0].Designation;

                        if (lstUserDetails[0].FK_RoleID != null)
                            ddlrole.SelectedValue = Convert.ToString(lstUserDetails[0].FK_RoleID);

                        if (lstUserDetails[0].DateOfBirth != null)
                            dtScheduledatetime.Value = (Convert.ToDateTime(lstUserDetails[0].DateOfBirth)).ToString("dd/MM/yyyy");

                        txtEmail.Value = lstUserDetails[0].Email_id;
                        txtContactNumber.Value = lstUserDetails[0].ContactNo;
                        txtAlternativeNumber.Value = lstUserDetails[0].AlternativeNo;

                        if (lstUserDetails[0].UserPhoto != null)
                        {
                            Image1.Attributes["src"] = ResolveUrl("~/UserImage/" + lstUserDetails[0].UserPhoto);
                        }

                        objUserDetails = null;
                        objBL_UserLoginDetails = null;
                        lstUserDetails = null;
                    }
                    objUserDetails = null;
                    objBL_UserLoginDetails = null;
                    lstUserDetails = null;
                }
            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("CreateProfile.aspx:BindUserDetail() - " + ex.Message);
            }
        }
        public void RetrieveInviteUser()
        {
            try
            {
                objUserDetails = new UserDetails();
                objBL_UserLoginDetails = new BL_UserLoginDetails();
                lstUserDetails = objBL_UserLoginDetails.SelectUserDetailsList(Convert.ToInt32(HttpUtility.UrlDecode(Request.QueryString["CampInvtusrId"]).ToString()));

                if (lstUserDetails.Count > 0)
                {
                    //txta1.Value = lstUserDetails[0].Message;
                    Text1.Value = lstUserDetails[0].Email_id;
                    ddlrole.SelectedValue = Convert.ToString(lstUserDetails[0].FK_RoleID);
                }
                lstUserDetails = null;
                objBL_UserLoginDetails = null;
                objUserDetails = null;
            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("InvitieUser.aspx:RetrieveInviteUser() - " + ex.Message);
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                objUserDetails = new UserDetails();
                objBL_UserLoginDetails = new BL_UserLoginDetails();
                lstUserDetails = new List<UserDetails>();
                lstUserDetails = objBL_UserLoginDetails.SelectUserDetailsList(Convert.ToInt32(Session["UserID"].ToString()));

                if (lstUserDetails.Count > 0)
                {
                    objUserDetails.PK_UserID = lstUserDetails[0].PK_UserID;
                    objUserDetails.FK_CompanyID = lstUserDetails[0].FK_CompanyID;
                    objUserDetails.LastName = txtLastName.Value;
                    objUserDetails.FirstName = txtFirstName.Value;
                    objUserDetails.UserName = txtUserName.Value;
                    objUserDetails.UserType = lstUserDetails[0].UserType;
                    objUserDetails.Addressline1 = txtAddress.Value;
                    objUserDetails.City1 = txtCity.Value;
                    objUserDetails.State1 = txtState.Value;
                    objUserDetails.Country1 = txtCountry.Value;
                    objUserDetails.Designation = txtDesignation.Value;

                    if (ddlrole.SelectedValue != "0")
                        objUserDetails.FK_RoleID = Convert.ToInt32(ddlrole.SelectedValue.ToString());

                    if (dtScheduledatetime.Value != string.Empty)
                        objUserDetails.DateOfBirth = DateTime.ParseExact(dtScheduledatetime.Value, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    //Convert.ToDateTime(dtScheduledatetime.Value);

                    objUserDetails.Email_id = txtEmail.Value;
                    objUserDetails.ContactNo = txtContactNumber.Value;
                    objUserDetails.AlternativeNo = txtAlternativeNumber.Value;
                    objUserDetails.MemberSince = lstUserDetails[0].MemberSince;
                    objUserDetails.MemberTill = lstUserDetails[0].MemberTill;
                    objUserDetails.IsActive = lstUserDetails[0].IsActive;
                    objUserDetails.CreatedBy = lstUserDetails[0].CreatedBy;
                    objUserDetails.CreatedOn = lstUserDetails[0].CreatedOn;
                    objUserDetails.UpdatedBy = Convert.ToInt16(Session["UserID"].ToString());
                    objUserDetails.UpdatedOn = DateTime.Now;
                    objUserDetails.ReportID = lstUserDetails[0].ReportID;
                    objUserDetails.TotalMailCount = lstUserDetails[0].TotalMailCount;
                    objUserDetails.TotalContactsCount = lstUserDetails[0].TotalContactsCount;
                    objUserDetails.FK_UserPlanID = lstUserDetails[0].FK_UserPlanID;
                    objUserDetails.UserPassword = lstUserDetails[0].UserPassword;

                    int status = objBL_UserLoginDetails.AccessVerifyUserFileNameExist(FileUpload1.PostedFile.FileName.ToString().Trim());
                    string ChangedFileName = string.Empty;

                    if (status == 0)
                    {
                        if (FileUpload1.Value == string.Empty)
                            objUserDetails.UserPhoto = lstUserDetails[0].UserPhoto;
                        else
                        {
                            ChangedFileName = FileUpload1.Value;
                            objUserDetails.UserPhoto = ChangedFileName;
                            ProfilePhotoUpload(ChangedFileName);
                        }
                    }
                    else
                    {
                        if (FileUpload1.Value == string.Empty)
                            objUserDetails.UserPhoto = lstUserDetails[0].UserPhoto;
                        else
                        {
                            ChangedFileName = Path.GetFileNameWithoutExtension(FileUpload1.Value) + "1" + Path.GetExtension(FileUpload1.Value);
                            objUserDetails.UserPhoto = ChangedFileName;
                            ProfilePhotoUpload(ChangedFileName);
                        }
                    }

                    objUserDetails.AccountActivated = true;
                    objUserDetails.SendNewsLetter = lstUserDetails[0].SendNewsLetter;

                    objBL_UserLoginDetails.AccessUpdateUserLogin(objUserDetails);
                    Session["UserName"] = txtFirstName.Value.Trim() + " " + txtLastName.Value.Trim();
                    objUserDetails = null;
                    objBL_UserLoginDetails = null;
                    lstUserDetails = null;

                    ClientScript.RegisterStartupScript(Page.GetType(), "mykey1", "alert('User profile information submitted successfully.');", true);
                }

                //string[] files = System.IO.Directory.GetFiles(MapPath(@"UserImage")).Equals(green);
            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("CreateProfile.aspx:btnSubmit_Click() - " + ex.Message);
            }
        }
        /// <summary>
        /// Created By :: Sakthivel.R
        /// Created On :: 25-6-2015
        /// Comments :: Inserting all values of InviteUser form.
        /// </summary>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                objInviteUser = new InviteUser();
                lstInviteUser = new List<InviteUser>();

                objInviteUser.FK_RoleID = Convert.ToInt32(ddlrole.SelectedValue);

                if (Request.QueryString["CampInvtusrId"] != null)
                {
                    objUserDetails = new UserDetails();
                    lstUserDetails = new List<UserDetails>();
                    objBL_UserLoginDetails = new BL_UserLoginDetails();
                    lstUserDetails = objBL_UserLoginDetails.SelectUserDetailsList(Convert.ToInt32(HttpUtility.UrlDecode(Request.QueryString["CampInvtusrId"]).ToString()));

                    if (lstUserDetails.Count > 0)
                    {
                        if (ddlrole.SelectedValue != "0")
                            objBL_Common.AccessUpdateAllCampaign("EC_UserLogin", "FK_RoleID= " + Convert.ToInt32(ddlrole.SelectedValue) + ", UpdatedBy = " + Convert.ToInt32(Session["UserID"].ToString()) + ", UpdatedOn = '" + DateTime.Now + "' ", "PK_UserID =" + Convert.ToInt32(HttpUtility.UrlDecode(Request.QueryString["CampInvtusrId"]).ToString()) + "");
                    }
                    lstUserDetails = null;
                    objUserDetails = null;
                    objBL_UserLoginDetails = null;
                    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "Clearuserinput2();", true);
                }
                else
                {
                    int status = objBL_UserLoginDetails.AccessVerifyUserEmailidExist(EmailID.Value.ToString().Trim());

                    if (status == 0)
                    {
                        objInviteUser.Emailid = EmailID.Value;
                        objInviteUser.Invitedate = DateTime.Now;
                        objInviteUser.Message = txtmessage.Value;
                        objInviteUser.FK_CompanyID = Convert.ToInt32(Session["CompanyID"].ToString());
                        objInviteUser.CreatedOn = DateTime.Now;
                        objInviteUser.CreatedBy = Convert.ToInt32(Session["UserID"].ToString());
                        string pkcqid = objBL_InviteUser.AccessInsertInviteUser(objInviteUser);

                        //------Sending confirmtion Email of account created to client.-----
                        string sEmailId = "*****@*****.**";
                        //subject
                        string sSubject = "Join my Email Campaign account";

                        ////sending emails to client
                        string strReceiverName = "ADMIN";
                        string EncryptQry = "signid=" + objCryptographicHashCode.EncryptPlainTextToCipherText(pkcqid) + "'";
                        lstCompany = objBL_CompanyDetails.SelectCompanyListbasedonid(Convert.ToInt32(Session["CompanyID"].ToString()));
                        string companyname = "";
                        string emailid = "";

                        if (lstCompany.Count > 0)
                        {
                            if (lstCompany[0].Company_Name != null)
                                companyname = lstCompany[0].Company_Name;
                        }

                        if (Session["AdminEmilid"] != null)
                            emailid = Session["AdminEmilid"].ToString();

                        string body = MailTemplate.MailInviteUser(companyname, emailid, EncryptQry);
                        objMailTemplate.fnSendMailToClientForCoUpld(body, sEmailId, sSubject, EmailID.Value.ToString().Trim());
                        ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "Clearuserinput1();", true);
                    }
                    else if (status == 1)
                    {
                        lblerrormsg.Text = "<span style='color:#c85305;font-size:12px;'>Emailid already exist use some other emailid.</span>";
                    }
                    //---------End---------------------
                }

            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("InvitieUser.aspx:btnSubmit_Click() - " + ex.Message);
            }
        }