protected void btnSubscribe_Click(object sender, EventArgs e)
    {
        PreferencesBL objPreferencesBL = new PreferencesBL();

        DataSet dssub = new DataSet();

        PreferenceInfo ObjPreferncesInfo = new PreferenceInfo();

        PreferncesItemsInfo ObjPreferncesItemsInfo = new PreferncesItemsInfo();

        ObjPreferncesInfo.PreferenceID = hdnUserPrefernceID.Value;

        if (txtZip.Text != "Zip")
        {
            ObjPreferncesInfo.Zip = txtZip.Text;
        }
        if (txtName.Text != "Your Name")
        {
            ObjPreferncesInfo.Name = txtName.Text;
        }

        if (txtEmailAlert.Text != "Your Email")
        {
            ObjPreferncesInfo.Email = txtEmailAlert.Text;
        }

        if (txtPhoneNo.Text != "Your Phone")
        {
            ObjPreferncesInfo.Phone = txtPhoneNo.Text;
        }

        String strHostName = HttpContext.Current.Request.UserHostAddress.ToString();

        ObjPreferncesInfo.IPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

        DataSet dsPreferences = new DataSet();

        dsPreferences = objPreferencesBL.SaveSubscribe(ObjPreferncesInfo, 1);

        for (int i = 1; i < 6; i++)
        {
            string SelectedMake = string.Empty;
            string SelectedModel = string.Empty;
            string SelectedRange = string.Empty;

            if (i == 1)
            {
                SelectedMake = ddlMakes1.SelectedValue;
                SelectedModel = ddlModels1.SelectedValue;
                SelectedRange = ddlRanges1.SelectedValue;
            }
            else if (i == 2)
            {
                SelectedMake = ddlMakes2.SelectedValue;
                SelectedModel = ddlModels2.SelectedValue;
                SelectedRange = ddlRanges2.SelectedValue;
            }
            else if (i == 3)
            {
                SelectedMake = ddlMakes3.SelectedValue;
                SelectedModel = ddlModels3.SelectedValue;
                SelectedRange = ddlRanges3.SelectedValue;
            }
            else if (i == 4)
            {
                SelectedMake = ddlMakes4.SelectedValue;
                SelectedModel = ddlModels4.SelectedValue;
                SelectedRange = ddlRanges4.SelectedValue;
            }
            else if (i == 5)
            {
                SelectedMake = ddlMakes5.SelectedValue;
                SelectedModel = ddlModels5.SelectedValue;
                SelectedRange = ddlRanges5.SelectedValue;
            }
            if (SelectedMake != "0" && SelectedModel != "0")
            {

                ObjPreferncesItemsInfo.Makeid = SelectedMake;

                ObjPreferncesItemsInfo.ModelID = SelectedModel;

                ObjPreferncesItemsInfo.PriceRange = SelectedRange;

                ObjPreferncesItemsInfo.UserPreferID = dsPreferences.Tables[0].Rows[0]["UserPreferID"].ToString();

                HiddenField hdnPreferenceID = (HiddenField)Page.FindControl("hdnPreferenceID" + i);

                ObjPreferncesItemsInfo.PreferenceID = hdnPreferenceID.Value;

                dssub = objPreferencesBL.SaveSubScribeItems(ObjPreferncesItemsInfo, true);
            }
            else
            {

                HiddenField hdnPreferenceID = (HiddenField)Page.FindControl("hdnPreferenceID" + i);

                if (hdnPreferenceID.Value != "")
                {
                    if (SelectedMake != "0" && SelectedModel != "0")
                    {
                        ObjPreferncesItemsInfo.Makeid = SelectedMake;

                        ObjPreferncesItemsInfo.ModelID = SelectedModel;

                        ObjPreferncesItemsInfo.PriceRange = SelectedRange;

                        ObjPreferncesItemsInfo.UserPreferID = dsPreferences.Tables[0].Rows[0]["UserPreferID"].ToString();

                        ObjPreferncesItemsInfo.PreferenceID = hdnPreferenceID.Value;

                        dssub = objPreferencesBL.SaveSubScribeItems(ObjPreferncesItemsInfo, false);
                    }
                }
            }
        }

        clsMailFormats format = new clsMailFormats();
        MailMessage msg = new MailMessage();

        msg.From = new MailAddress(CommonVariable.FromInfoMail);

        msg.To.Add(txtEmailAlert.Text);

        //msg.Bcc.Add("*****@*****.**");

        msg.Subject = "Successfully modified your personalized weekly email alerts - United Car Exchange.";

        msg.IsBodyHtml = true;

        string text = string.Empty;

        string VerifyPreferences = string.Empty;

        string ModifyPreferences = string.Empty;

        string PreferencesID = string.Empty;

        //VerifyPreferences = "www.unitedcarexchange.com/VerifyPreferences.aspx?Preferce=" + dssub.Tables[0].Rows[0]["ID"].ToString();

        //ModifyPreferences = "www.unitedcarexchange.com/EmailPreferences.aspx?Preferce=" + dssub.Tables[0].Rows[0]["ID"].ToString();

        PreferencesID = dsPreferences.Tables[0].Rows[0]["UserPreferID"].ToString();

        text = format.SendEMailPreferencesEdit(dsPreferences.Tables[0].Rows[0]["Name"].ToString(), dsPreferences.Tables[0].Rows[0]["UserPreferID"].ToString(), ref text);

        msg.Body = text.ToString();

        SmtpClient smtp = new SmtpClient();

        //smtp.Host = "smtp.gmail.com";
        //smtp.Port = 587;
        //smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "hugomirad");
        //smtp.EnableSsl = true;
        //smtp.Send(msg);

        smtp.Host = "127.0.0.1";
        smtp.Port = 25;
        smtp.Send(msg);

        lblalert.Text = "Your Preferences Has been Updated according to your selection";

        mpealteruser.Show();

        Page.ClientScript.RegisterStartupScript(typeof(Page), "KyRST", "<script type='text/javascript' language='javascript'>pageLoad();</script>");
    }
Esempio n. 2
0
    public string SubScribe(string PreferenceID, string sZip, string sName, string sEmail, string sPhoneNo)
    {
        Session[Constants.Subscribe] = 1;

        PreferencesBL objPreferencesBL = new PreferencesBL();

        DataSet dssub = new DataSet();

        PreferenceInfo ObjPreferncesInfo = new PreferenceInfo();

        PreferncesItemsInfo ObjPreferncesItemsInfo = new PreferncesItemsInfo();

        dssub = objPreferencesBL.GetEmailPreferencesbyEmail(sEmail);

        string sPreferenceID = string.Empty;

        if (dssub.Tables[0].Rows.Count == 0)
        {
            ObjPreferncesInfo.PreferenceID = PreferenceID;

            if (sZip != "Zip")
            {
                ObjPreferncesInfo.Zip = sZip;
            }
            if (sName != "Your Name")
            {
                ObjPreferncesInfo.Name = sName;
            }

            if (sEmail != "Your Email")
            {
                ObjPreferncesInfo.Email = sEmail;
            }

            if (sPhoneNo != "Your Phone")
            {
                ObjPreferncesInfo.Phone = sPhoneNo;
            }

            String strHostName = HttpContext.Current.Request.UserHostAddress.ToString();

            ObjPreferncesInfo.IPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

            if (HttpContext.Current.Request.Cookies["UserSettings"] == null)
            {
                HttpCookie myCookie = new HttpCookie("UserSettings");

                myCookie.Expires = DateTime.Now.AddDays(500);

                myCookie.Values.Add("Email", ObjPreferncesInfo.Email);
                myCookie.Values.Add("Name", ObjPreferncesInfo.Name);
                myCookie.Values.Add("Phone", ObjPreferncesInfo.Phone);

                HttpContext.Current.Response.Cookies.Add(myCookie);
            }

            DataSet dsPreferences = new DataSet();

            dsPreferences = objPreferencesBL.SaveSubscribe(ObjPreferncesInfo, 1);

            clsMailFormats format = new clsMailFormats();
            MailMessage msg = new MailMessage();

            msg.From = new MailAddress(CommonVariable.FromInfoMail);

            msg.To.Add(sEmail);

            //msg.Bcc.Add("*****@*****.**");

            msg.Subject = "Successfully modified your personalized weekly email alerts - United Car Exchange.";

            msg.IsBodyHtml = true;

            string text = string.Empty;

            string VerifyPreferences = string.Empty;

            string ModifyPreferences = string.Empty;

            string PreferencesID = string.Empty;

            //VerifyPreferences = "www.unitedcarexchange.com/VerifyPreferences.aspx?Preferce=" + dssub.Tables[0].Rows[0]["ID"].ToString();

            //ModifyPreferences = "www.unitedcarexchange.com/EmailPreferences.aspx?Preferce=" + dssub.Tables[0].Rows[0]["ID"].ToString();

            PreferencesID = dsPreferences.Tables[0].Rows[0]["UserPreferID"].ToString();

            text = format.SendEMailPreferencesEdit(dsPreferences.Tables[0].Rows[0]["Name"].ToString(), dsPreferences.Tables[0].Rows[0]["UserPreferID"].ToString(), ref text);

            msg.Body = text.ToString();

            SmtpClient smtp = new SmtpClient();

            //smtp.Host = "smtp.gmail.com";
            //smtp.Port = 587;
            //smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "hugomirad");
            //smtp.EnableSsl = true;
            //smtp.Send(msg);

            smtp.Host = "127.0.0.1";
            smtp.Port = 25;
            smtp.Send(msg);

            return PreferencesID;
        }
        else
        {
            return "true";

        }
    }
Esempio n. 3
0
        public DataSet SaveSubscribe(PreferenceInfo  ObjPreferncesInfo,int  Isactive)
        {
            DataSet dsResult = new DataSet();

            string spNameString = string.Empty;

            bool bsucess = false;

            //Setting Connection
            //Global.INSTANCE_NAME = strCurrentConn;

            IDataReader ModelsInfoDataReader = null;

            //Connect to the database
            Database dbDatabase = DatabaseFactory.CreateDatabase(Global.INSTANCE_NAME);

            //Assign stored procedure name

            spNameString = "[Save_SubScribe]";
            DbCommand dbCommand = null;

            try
            {

                //Set stored procedure to the command object

                dbCommand = dbDatabase.GetStoredProcCommand(spNameString);

                dbDatabase.AddInParameter(dbCommand, "@UserPreferID", DbType.Int64, ObjPreferncesInfo.PreferenceID);
                dbDatabase.AddInParameter(dbCommand, "@Name", DbType.String, ObjPreferncesInfo.Name );
                dbDatabase.AddInParameter(dbCommand, "@Email", DbType.String, ObjPreferncesInfo.Email  );

                dbDatabase.AddInParameter(dbCommand, "@Phone", DbType.String, ObjPreferncesInfo.Phone );
                dbDatabase.AddInParameter(dbCommand, "@IPAddress", DbType.String, ObjPreferncesInfo.IPAddress);
                dbDatabase.AddInParameter(dbCommand, "@Zip", DbType.String, ObjPreferncesInfo.Zip);

                dbDatabase.AddInParameter(dbCommand, "@Isactive", DbType.Int32, Isactive);

                //Executing stored procedure

                dsResult = dbDatabase.ExecuteDataSet(dbCommand);

                bsucess = true;

            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, Global.EXCEPTION_POLICY);

                if (rethrow)
                    throw;
            }

            return dsResult;
        }
Esempio n. 4
0
    protected void btnSubscribe_Click(object sender, EventArgs e)
    {
        mpesubscribe.Hide();

        PreferencesBL objPreferencesBL = new PreferencesBL();

        DataSet dssub = new DataSet();

        PreferenceInfo ObjPreferncesInfo = new PreferenceInfo();

        PreferncesItemsInfo ObjPreferncesItemsInfo = new PreferncesItemsInfo();

        ObjPreferncesInfo.PreferenceID = "0";

        ObjPreferncesInfo.Zip = txtZip.Text;

        ObjPreferncesInfo.Name = txtName.Text;

        if (txtEmailAlert.Text != "Your Email")
        {
            ObjPreferncesInfo.Email = txtEmailAlert.Text;
        }

        if (txtPhoneNo.Text != "Your Phone")
        {
            ObjPreferncesInfo.Phone = txtPhoneNo.Text;
        }

        String strHostName = HttpContext.Current.Request.UserHostAddress.ToString();

        ObjPreferncesInfo.IPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

        if (Request.Cookies["UserSettings"] == null)
        {
            HttpCookie myCookie = new HttpCookie("UserSettings");

            myCookie.Expires = DateTime.Now.AddDays(500);

            myCookie.Values.Add("Email", ObjPreferncesInfo.Email);
            myCookie.Values.Add("Name", ObjPreferncesInfo.Name);
            myCookie.Values.Add("Phone", ObjPreferncesInfo.Phone);

            Response.Cookies.Add(myCookie);
        }

        ObjPreferncesItemsInfo.Makeid = ddlMake1.SelectedValue;
        ObjPreferncesItemsInfo.ModelID = ddlModel1.SelectedValue;
        ObjPreferncesItemsInfo.PriceRange = ddlRange1.SelectedValue;

        DataSet dsEmailExist = new DataSet();

        DataSet dsPreferences = new DataSet();

        dsEmailExist = objPreferencesBL.GetEmailPreferencesbyEmail(txtEmailAlert.Text);

        if (dsEmailExist.Tables[0].Rows.Count == 0)
        {
            dsPreferences = objPreferencesBL.SaveSubscribe(ObjPreferncesInfo, 1);

            for (int i = 1; i < 6; i++)
            {
                string SelectedMake = string.Empty;
                string SelectedModel = string.Empty;
                string SelectedRange = string.Empty;

                if (i == 1)
                {
                    SelectedMake = ddlMake1.SelectedValue;
                    SelectedModel = ddlModel1.SelectedValue;
                    SelectedRange = ddlRange1.SelectedValue;
                }
                else if (i == 2)
                {
                    SelectedMake = ddlMake2.SelectedValue;
                    SelectedModel = ddlModel2.SelectedValue;
                    SelectedRange = ddlRange2.SelectedValue;
                }
                else if (i == 3)
                {
                    SelectedMake = ddlMake3.SelectedValue;
                    SelectedModel = ddlModel3.SelectedValue;
                    SelectedRange = ddlRange3.SelectedValue;
                }
                else if (i == 4)
                {
                    SelectedMake = ddlMake4.SelectedValue;
                    SelectedModel = ddlModel4.SelectedValue;
                    SelectedRange = ddlRange4.SelectedValue;
                }
                else if (i == 5)
                {
                    SelectedMake = ddlMake5.SelectedValue;
                    SelectedModel = ddlModel5.SelectedValue;
                    SelectedRange = ddlRange5.SelectedValue;
                }
                if (SelectedMake != "0" && SelectedModel != "0")
                {

                    ObjPreferncesItemsInfo.Makeid = SelectedMake;

                    ObjPreferncesItemsInfo.ModelID = SelectedModel;

                    ObjPreferncesItemsInfo.PreferenceID = "0";

                    ObjPreferncesItemsInfo.PriceRange = SelectedRange;

                    ObjPreferncesItemsInfo.UserPreferID = dsPreferences.Tables[0].Rows[0]["UserPreferID"].ToString();

                    dssub = objPreferencesBL.SaveSubScribeItems(ObjPreferncesItemsInfo, true);
                }
            }
            clsMailFormats format = new clsMailFormats();

            MailMessage msg = new MailMessage();

            msg.From = new MailAddress(txtEmailAlert.Text);

            msg.To.Add("*****@*****.**");

            //msg.Bcc.Add();

            msg.Subject = "Welcome to your personalized weekly email alerts preferences.";

            msg.IsBodyHtml = true;

            string text = string.Empty;

            string VerifyPreferences = string.Empty;

            string ModifyPreferences = string.Empty;

            string PreferencesID = string.Empty;

            //VerifyPreferences = "www.unitedcarexchange.com/VerifyPreferences.aspx?Preferce=" + dssub.Tables[0].Rows[0]["ID"].ToString();

            //ModifyPreferences = "www.unitedcarexchange.com/EmailPreferences.aspx?Preferce=" + dssub.Tables[0].Rows[0]["ID"].ToString();

            PreferencesID = dsPreferences.Tables[0].Rows[0]["UserPreferID"].ToString();

            GeneralFunc obj = new GeneralFunc();

            text = format.SendEMailPreferences(GeneralFunc.ToProper(dsPreferences.Tables[0].Rows[0]["Name"].ToString()), dsPreferences.Tables[0].Rows[0]["UserPreferID"].ToString(), ref text);

            msg.Body = text.ToString();

            SmtpClient smtp = new SmtpClient();

            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "hugomirad");
            smtp.EnableSsl = true;
            smtp.Send(msg);

            //smtp.Host = "127.0.0.1";
            //smtp.Port = 25;
            //smtp.Send(msg);

            // Progress111.Visible = false;

            Type cstype = GetType();

            ClientScriptManager cs = Page.ClientScript;

            cs.RegisterStartupScript(cstype, "KyRST", "<script type='text/javascript' language='javascript'>pageLoad();</script>");

            lblAlertMsg.Text = "Thank you for signing up for automatic email alerts..";
            //mpealert.Show();
        }
        else
        {

            Type cstype = GetType();

            ClientScriptManager cs = Page.ClientScript;

            cs.RegisterStartupScript(cstype, "KyRST", "<script type='text/javascript' language='javascript'>pageLoad();</script>");

            lblAlertMsg.Text = "Email ID Already Subscribed..";
            //mpealert.Show();

        }
    }