/// <summary>
 /// Binds the address data to controls
 /// </summary>
 /// <param name="itemID">item id of the address data</param>
 private void BindAddressData(int itemID)
 {
     try
     {
         AddressInfo addressData = AddressInfoProvider.GetAddresses()
                                   .WhereEquals("AddressID", itemID)
                                   .FirstOrDefault();
         if (!DataHelper.DataSourceIsEmpty(addressData))
         {
             txtAddressLine1.Text     = addressData.AddressLine1;
             txtAddressLine2.Text     = addressData.AddressLine2;
             txtCity.Text             = addressData.AddressCity;
             txtZipcode.Text          = addressData.AddressZip;
             txtName.Text             = addressData.AddressPersonalName;
             txtTelephone.Text        = addressData.AddressPhone;
             uniSelectorCountry.Value = addressData.AddressCountryID;
             uniSelectorState.Value   = addressData.AddressStateID;
             txtEmail.Text            = addressData.GetStringValue("Email", string.Empty);
             txtComapnyName.Text      = addressData.GetStringValue("CompanyName", string.Empty);
             ddlAddressType.Value     = addressData.GetStringValue("AddressTypeID", string.Empty);
             if (addressData.AddressStateID <= 0)
             {
                 uniSelectorState.Enabled = false;
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CreateAddress.ascx.cs", "BindAddressData()", ex);
     }
 }
Example #2
0
 /// <summary>
 /// Load data of editing address.
 /// </summary>
 /// <param name="addressObj">Address object</param>
 protected void LoadData(AddressInfo addressObj)
 {
     txtAddressZip.Text           = addressObj.AddressZip;
     txtAddressDeliveryPhone.Text = addressObj.AddressPhone;
     txtPersonalName.Text         = addressObj.AddressPersonalName;
     //txtAddressName.Text = addressObj.AddressName;
     txtAddressLine1.Text      = addressObj.AddressLine1;
     chkAddressEnabled.Checked = addressObj.AddressEnabled;
     txtAddressLine2.Text      = addressObj.AddressLine2;
     txtAddressCity.Text       = addressObj.AddressCity;
     txtnum.Text = addressObj.GetStringValue("AddressNumber", string.Empty);
     ucCountrySelector.CountryID = addressObj.AddressCountryID;
     ucCountrySelector.StateID   = addressObj.AddressStateID;
 }
Example #3
0
    /// <summary>
    /// Load data of editing address.
    /// </summary>
    /// <param name="addressObj">Address object</param>
    protected void LoadData(AddressInfo addressObj)
    {
        txtAddressZip.Text           = addressObj.AddressZip;
        txtAddressDeliveryPhone.Text = addressObj.AddressPhone;
        txtPersonalName.Text         = addressObj.AddressPersonalName;
        //txtAddressName.Text = addressObj.AddressName;
        txtAddressLine1.Text      = addressObj.AddressLine1;
        chkAddressEnabled.Checked = addressObj.AddressEnabled;
        txtAddressLine2.Text      = addressObj.AddressLine2;
        txtAddressCity.Text       = addressObj.AddressCity;
        txtnum.Text = addressObj.GetStringValue("AddressNumber", string.Empty);

        //drpAddressType.SelectedValue = AddressInfoProvider.GetAddressString(addressObj.AddressType);
        chkAddressIsBilling.Checked  = addressObj.AddressIsBilling;
        chkAddressIsShipping.Checked = addressObj.AddressIsShipping;
        chkAddressIsCompany.Checked  = addressObj.AddressIsCompany;
        ucCountrySelector.CountryID  = addressObj.AddressCountryID;
        ucCountrySelector.StateID    = addressObj.AddressStateID;
    }
    private void sendconf2(UserInfo ui, string emailtype, string[,] macros)
    {
        SiteInfo         currentSite          = SiteContext.CurrentSite;
        ContextResolver  resolver             = MacroContext.CurrentResolver;
        EventLogProvider ev                   = new EventLogProvider();
        bool             requiresConfirmation = SettingsKeyInfoProvider.GetBoolValue(currentSite.SiteName + ".CMSRegistrationEmailConfirmation");
        bool             requiresAdminApprove = false;
        bool             SendWelcomeEmail     = true;

        #region "Welcome Emails (confirmation, waiting for approval)"

        bool error = false;
        //  EventLogProvider ev = new EventLogProvider();
        // EmailTemplateInfo template = null;

        string            emailSubject = null;
        string            templateName = null;
        EmailTemplateInfo template     = null;

        // Send welcome message with username and password, with confirmation link, user must confirm registration
        template     = EmailTemplateProvider.GetEmailTemplate("E-commerce-OrderNotificationToCustomerBO", currentSite.SiteName);
        emailSubject = EmailHelper.GetSubject(template, "Votre commande: " + ShoppingCart.Order.OrderID);

        //mail type

        if (template != null)
        {
            EventLogProvider p = new EventLogProvider();
            p.LogEvent("I", DateTime.Now, "test 11", "code BO");
            // Set resolver
            resolver.SourceParameters = macros;

            // Email message
            EmailMessage email = new EmailMessage();
            email.EmailFormat = EmailFormatEnum.Default;
            email.Recipients  = ShoppingCart.Customer.CustomerEmail;

            p.LogEvent("I", DateTime.Now, "MAIL: " + ShoppingCart.Customer.CustomerEmail, "code BO");
            email.From = SettingsKeyInfoProvider.GetStringValue(currentSite.SiteName + ".CMSStoreSendEmailsFrom");//EmailHelper.GetSender(template, SettingsKeyProvider.GetStringValue(currentSite.SiteName + ".CMSStoreSendEmailsTo"));
            p.LogEvent("I", DateTime.Now, "MAIL: " + SettingsKeyInfoProvider.GetStringValue(currentSite.SiteName + ".CMSStoreSendEmailsTo"), "code BO");
            //string templatetext = template.TemplateText.Replace("\r\n\t\tVotre compte 2MAD a �t� cr��. Veuillez valider votre inscription en cliquant sur le lien ci-dessous.  <br />\r\n<a href=\"{%confirmaddress%}\">{%confirmaddress%}</a>\r\n<br />\r\n<br />\r\nVos identifiants :", " ");


            int n = ShoppingCart.ShoppingCartBillingAddressID; //ECommerceContext.CurrentShoppingCart.ShoppingCartBillingAddressID

            //take address info
            SqlConnection con3 = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);
            con3.Open();
            var         stringQuery = "select * from COM_Address WHERE AddressID  = " + n;
            SqlCommand  cmd3        = new SqlCommand(stringQuery, con3);
            IDataReader reader      = cmd3.ExecuteReader();
            AddressInfo ai2         = new AddressInfo();
            var         temp        = "";
            while (reader.Read())
            {
                ai2.AddressLine1     = Convert.ToString(reader.GetValue(2));
                ai2.AddressLine2     = Convert.ToString(reader.GetValue(3));
                temp                 = ai2.GetStringValue(Convert.ToString(reader.GetValue(17)), Convert.ToString(reader.GetValue(17)));
                ai2.AddressZip       = Convert.ToString(reader.GetValue(5));
                ai2.AddressCity      = Convert.ToString(reader.GetValue(4));
                ai2.AddressCountryID = Convert.ToInt32(reader.GetValue(8));
            }
            con3.Dispose();
            // Take country name
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);
            con.Open();
            var        stringQuery2 = " select CountryName from CMS_Country where CountryID = " + ai2.AddressCountryID;
            SqlCommand cmd2         = new SqlCommand(stringQuery2, con);
            string     c            = (string)cmd2.ExecuteScalar();
            con.Dispose();

            // take sous total {%(TotalPrice-TotalShipping).Format(Currency.CurrencyFormatString)#%}
            var    s1 = ShoppingCart.TotalPrice - ShoppingCart.TotalShipping;
            string s  = CurrencyInfoProvider.GetFormattedPrice(s1, ShoppingCart.Currency).ToString();

            // take frais d'envoi {%TotalShipping.Format(Currency.CurrencyFormatString)#%}
            var    fr    = ShoppingCart.TotalShipping;
            string frais = CurrencyInfoProvider.GetFormattedPrice(fr, ShoppingCart.Currency).ToString();

            // take {%TotalPrice.Format(Currency.CurrencyFormatString)#%}
            var    pr   = ShoppingCart.TotalPrice;
            string prix = CurrencyInfoProvider.GetFormattedPrice(pr, ShoppingCart.Currency).ToString();

            // take items
            string panier = "<table cellpadding='0' cellspacing='0'> <tbody>";

            foreach (ShoppingCartItemInfo item in ShoppingCart.CartItems)
            {
                var    t1    = item.TotalPrice;
                string total = CurrencyInfoProvider.GetFormattedPrice(t1, ShoppingCart.Currency).ToString();
                panier = panier + "<tr valign='top'>";
                panier = panier + "<td style='background-color:#e4e4e4;padding:8px 10px;margin-bottom:10px;display:block'> <table cellpadding='0' cellspacing='0'> <tbody> <tr valign='middle'> <td style='color:#3c3341;font-size:11px;font-family:Arial,Helvetica,sans-serif;text-transform:uppercase;border-right:#b3b3b3 1px solid' width='265' height='30'>" + item.SKU.SKUName + "</td> <td style='background-color:#fff;color:#241d29;font-size:16px;font-family:Arial,Helvetica,sans-serif;font-weight:bold;text-align:center;margin:0 10px;display:block;vertical-align:middle;line-height:30px' width='37' height='30'>" + item.CartItemUnits + "</td><td style='color:#241d29;font-size:16px;font-family:Arial,Helvetica,sans-serif;text-transform:uppercase;font-weight:bold;border-left:#b3b3b3 1px solid;text-align:center' width='70' height='30'> " + total + "</td></tr></tbody></table></td>";
                panier = panier + "</tr>";
            }
            panier = panier + "</tbody> </table >";

            string templatetext = template.TemplateText.Replace("#number", ShoppingCart.Order.OrderInvoiceNumber).Replace("#facturation", "<b>" + ShoppingCart.Customer.CustomerFirstName + " " + ShoppingCart.Customer.CustomerLastName + "</b><br/>" + temp + " " + ai2.AddressLine1 + "<br/>" + ai2.AddressLine2 + "<br/>" + ai2.AddressZip + " " + ai2.AddressCity + "<br/>" + c).Replace("#shipping", ShoppingCart.ShippingOption.ShippingOptionDisplayName).Replace("#payment", ShoppingCart.PaymentOption.PaymentOptionDisplayName).Replace("#soustotal", s).Replace("#prixtotal", prix).Replace("#fraisdenvoi", frais).Replace("#items", panier);

            email.Body = resolver.ResolveMacros(templatetext);

            resolver.EncodeResolvedValues = false;
            email.PlainTextBody           = resolver.ResolveMacros(template.TemplatePlainText);
            email.Subject = resolver.ResolveMacros(emailSubject);
            //email.CcRecipients = "*****@*****.**";
            //p.LogEvent("I",DateTime.Now,"mail admin"+ShoppingCart,"code BO");
            email.CcRecipients  = template.TemplateCc;
            email.BccRecipients = template.TemplateBcc;

            try
            {
                MetaFileInfoProvider.ResolveMetaFileImages(email, template.TemplateID, EmailObjectType.EMAILTEMPLATE, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE);
                // Send the e-mail immediately
                EmailSender.SendEmail(currentSite.SiteName, email, true);
                p.LogEvent("I", DateTime.Now, "after try ttt", "code BO");
            }
            catch (Exception ex)
            {
                ev.LogEvent("E", "EMAIL NON ENVOYE", ex);
            }
        }

        #endregion
    }
    protected void rptAdressItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        System.Globalization.CultureInfo         currentUI = System.Globalization.CultureInfo.CurrentUICulture;
        AjaxControlToolkit.ConfirmButtonExtender cbe       = new AjaxControlToolkit.ConfirmButtonExtender();
        cbe = (AjaxControlToolkit.ConfirmButtonExtender)e.Item.FindControl("ConfirmButtonDelete");

        if (cbe != null)
        {
            cbe.ConfirmText = GetString("msgconfirm");
        }

        var drv = (System.Data.DataRowView)e.Item.DataItem;

        if (drv != null)
        {
            int currentAdressID = ValidationHelper.GetInteger(drv["AddressID"], 0);
            if (currentAdressID > 0)
            {
                AddressInfo ai = AddressInfoProvider.GetAddressInfo(currentAdressID);
                if (ai != null)
                {
                    var ltlAdress = e.Item.FindControl("ltlAdress") as Literal;
                    if (ltlAdress != null)
                    {
                        int countryID = ai.AddressCountryID;
                        ltlAdress.Text = string.Format("{0}, {1}", ai.AddressName, MacroContext.CurrentResolver.ResolveMacros(CountryInfoProvider.GetCountryInfo(countryID).CountryDisplayName));
                    }

                    var txtnumero = e.Item.FindControl("txtnumero") as TextBox;
                    if (txtnumero != null)
                    {
                        txtnumero.Text    = ai.GetStringValue("AddressNumber", string.Empty).Trim();
                        txtnumero.ToolTip = GetString("numerorue");
                    }

                    var wmnumero = e.Item.FindControl("wmnumero") as AjaxControlToolkit.TextBoxWatermarkExtender;
                    if (wmnumero != null)
                    {
                        wmnumero.WatermarkText = GetString("numerorue");
                    }

                    var txtadresse1 = e.Item.FindControl("txtadresse1") as TextBox;
                    if (txtadresse1 != null)
                    {
                        txtadresse1.Text    = ai.AddressLine1.Trim();
                        txtadresse1.ToolTip = GetString("adresse1");
                    }

                    var wmadresse1 = e.Item.FindControl("wmadresse1") as AjaxControlToolkit.TextBoxWatermarkExtender;
                    if (wmadresse1 != null)
                    {
                        wmadresse1.WatermarkText = GetString("adresse1");
                    }

                    var txtadresse2 = e.Item.FindControl("txtadresse2") as TextBox;
                    if (txtadresse2 != null)
                    {
                        txtadresse2.Text    = ai.AddressLine2.Trim() == string.Empty ? string.Empty : ai.AddressLine2.Trim();
                        txtadresse2.ToolTip = GetString("adresse2");
                    }

                    var wmadresse2 = e.Item.FindControl("wmadresse2") as AjaxControlToolkit.TextBoxWatermarkExtender;
                    if (wmadresse2 != null)
                    {
                        wmadresse2.WatermarkText = GetString("adresse2");
                    }


                    var txtcp = e.Item.FindControl("txtcp") as TextBox;
                    if (txtcp != null)
                    {
                        txtcp.Text    = ai.AddressZip.Trim();
                        txtcp.ToolTip = GetString("cp");
                    }

                    var wmcp = e.Item.FindControl("wmcp") as AjaxControlToolkit.TextBoxWatermarkExtender;
                    if (wmcp != null)
                    {
                        wmcp.WatermarkText = GetString("cp");
                    }

                    var txtville = e.Item.FindControl("txtville") as TextBox;
                    if (txtville != null)
                    {
                        txtville.Text    = ai.AddressCity.Trim();
                        txtville.ToolTip = GetString("ville");
                    }

                    var wmville = e.Item.FindControl("wmville") as AjaxControlToolkit.TextBoxWatermarkExtender;
                    if (wmville != null)
                    {
                        wmville.WatermarkText = GetString("ville");
                    }

                    var txtCountry = e.Item.FindControl("txtCountry") as TextBox;
                    if (txtCountry != null)
                    {
                        txtCountry.Text = MacroContext.CurrentResolver.ResolveMacros(
                            GetString(CountryInfoProvider.GetCountryInfo(ai.AddressCountryID).CountryDisplayName));
                    }

                    var chkShippingAddr = e.Item.FindControl("chkShippingAddr") as CheckBox;
                    if (chkShippingAddr != null)
                    {
                        chkShippingAddr.Checked = ai.AddressIsShipping;
                    }

                    var chkBillingAddr = e.Item.FindControl("chkBillingAddr") as CheckBox;
                    if (chkBillingAddr != null)
                    {
                        chkBillingAddr.Checked = ai.AddressIsBilling;
                    }
                }
            }
        }
    }
    protected void rptAdressItemCommand(object source, RepeaterCommandEventArgs e)
    {
        // Get AddressId from the row
        int AddressId = ValidationHelper.GetInteger(e.CommandArgument, 0);

        // Delete selected address
        if (e.CommandName.Equals("Remove"))
        {
            int idShoppingCart = 0;
            //   EventLogProvider ev = new EventLogProvider();
            // test du nombre d'adresse
            int idCustomer = ECommerceContext.CurrentCustomer.CustomerID;
            string where, orderby;
            where   = "AddressEnabled = 1 AND AddressCustomerID  = " + idCustomer;
            orderby = "AddressID";
            InfoDataSet <AddressInfo> listadresse = AddressInfoProvider.GetAddresses(where, orderby);
            if (listadresse.Tables[0].Rows.Count <= 1)
            {
                return;
            }

            else
            {
                // Delete AddressInfo object from database if address not used for order
                if ((OrderBillingAddress(AddressId) == 0) && (OrderShippingAddress(AddressId) == 0))
                {
                    SqlConnection con4  = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);
                    var           query = "Select ShoppingCartID from COM_ShoppingCart where ShoppingCartShippingAddressID = " + AddressId;
                    SqlCommand    cmd2  = new SqlCommand(query, con4);
                    //  ev.LogEvent("I", DateTime.Now, "ds billig&shipping=0", "code");
                    con4.Open();
                    try
                    {
                        idShoppingCart = (int)cmd2.ExecuteScalar();
                        //  ev.LogEvent("I", DateTime.Now, "dans try  " + idShoppingCart, "code");
                    }
                    catch (Exception ex)
                    {
                    }
                    con4.Close();
                    if (idShoppingCart != 0)
                    {
                        var        query2 = "Delete  from COM_ShoppingCartSKU WHERE ShoppingCartID = " + idShoppingCart;
                        SqlCommand cmd1   = new SqlCommand(query2, con4);
                        cmd1.ExecuteScalar();

                        var        stringQuery = "Delete  from COM_ShoppingCart WHERE ShoppingCartShippingAddressID = " + AddressId;
                        SqlCommand cmd3        = new SqlCommand(stringQuery, con4);
                        cmd3.ExecuteScalar();

                        con4.Dispose();
                    }
                    if (Session["newAddress"] != null)
                    {
                        int temp2 = Int32.Parse(Session["newAddress"].ToString());

                        if (temp2 != 0)
                        {
                            if (temp2 == AddressId)
                            {
                                Session["newAddress"] = null;
                            }
                        }
                    }
                    AddressInfoProvider.DeleteAddressInfo(AddressId);

                    //ev.LogEvent("I", DateTime.Now, "button delete enabled true", "code");
                    //
                    int id1 = ECommerceContext.CurrentCustomer.CustomerID;
                }
                // Disable AddressInfo object from database if address used for order
                else
                {
                    SqlConnection con3 = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);
                    // con3.Open();
                    //   ev.LogEvent("I", DateTime.Now, "iD = " + AddressId, "code");
                    var        query = "Select ShoppingCartID from COM_ShoppingCart where ShoppingCartShippingAddressID = " + AddressId;
                    SqlCommand cmd2  = new SqlCommand(query, con3);
                    //  ev.LogEvent("I", DateTime.Now, "test", "code");
                    con3.Open();
                    try
                    {
                        idShoppingCart = (int)cmd2.ExecuteScalar();
                        con3.Dispose();
                    }
                    catch (Exception ex)
                    {
                    }
                    con3.Close();

                    SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);

                    //  ev.LogEvent("I", DateTime.Now, "idShoppingCart = " + idShoppingCart, "code");

                    if (idShoppingCart != 0)
                    {
                        connect.Open();
                        var        query2 = "Delete  from COM_ShoppingCartSKU WHERE ShoppingCartID = " + idShoppingCart;
                        SqlCommand cmd1   = new SqlCommand(query2, connect);
                        cmd1.ExecuteScalar();


                        var        stringQuery = "Delete  from COM_ShoppingCart WHERE ShoppingCartShippingAddressID = " + AddressId;
                        SqlCommand cmd3        = new SqlCommand(stringQuery, connect);
                        cmd3.ExecuteScalar();
                        connect.Close();
                        Response.Redirect("~/Special-Page/Mon-compte.aspx");
                    }
                    //    ev.LogEvent("I", DateTime.Now, "btn delet enabled false", "code");
                    AddressInfo  UpdateAdress = AddressInfoProvider.GetAddressInfo(AddressId);
                    CustomerInfo uc           = ECommerceContext.CurrentCustomer;
                    UpdateAdress.AddressEnabled    = false;
                    UpdateAdress.AddressCustomerID = mCustomerId;
                    AddressInfoProvider.SetAddressInfo(UpdateAdress);
                    AddressId = UpdateAdress.AddressID;
                }
            }
            ReloadDataAdress();
            // PnlInsertAdress.Visible = false;
        }

        // Update selected adress
        if (e.CommandName.Equals("Update"))
        {
            // lblErrorAdress
            var lblErrorAdress = e.Item.FindControl("lblErrorAdress") as Label;

            // chkShippingAddr
            var chkShippingAddr = e.Item.FindControl("chkShippingAddr") as CheckBox;

            // chkBillingAddr
            var chkBillingAddr = e.Item.FindControl("chkBillingAddr") as CheckBox;

            if (!chkBillingAddr.Checked && !chkShippingAddr.Checked)
            {
                lblErrorAdress.Text    = "V�rifier le type d'adresse";
                lblErrorAdress.Visible = true;
                return;
            }

            int         AddressID = Convert.ToInt32(e.CommandArgument);
            AddressInfo ai        = AddressInfoProvider.GetAddressInfo(AddressID);
            string      s         = ai.AddressZip;

            // txtnumero
            var txtnumero = e.Item.FindControl("txtnumero") as TextBox;
            if (txtnumero != null)
            {
                ai.SetValue("AddressNumber", txtnumero.Text);
            }

            // txtadresse1
            var txtadresse1 = e.Item.FindControl("txtadresse1") as TextBox;
            if (txtadresse1 != null)
            {
                ai.AddressLine1 = txtadresse1.Text;
            }

            // txtadresse2
            var txtadresse2 = e.Item.FindControl("txtadresse2") as TextBox;
            if (txtadresse2 != null)
            {
                ai.AddressLine2 = txtadresse2.Text;
            }

            // txtcp
            TextBox txtcp = e.Item.FindControl("txtcp") as TextBox;
            if (txtcp != null)
            {
                ai.AddressZip = txtcp.Text;
                // Response.Write("<script>alert('This is Alert " + txtcp.Text + " " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt") + "');</script>");
            }

            // txtville
            var txtville = e.Item.FindControl("txtville") as TextBox;
            if (txtville != null)
            {
                ai.AddressCity = txtville.Text;
            }

            // chkShippingAddr
            if (chkShippingAddr != null)
            {
                ai.AddressIsShipping = chkShippingAddr.Checked;
            }

            // chkBillingAddr
            if (chkBillingAddr != null)
            {
                ai.AddressIsBilling = chkBillingAddr.Checked;
            }

            CustomerInfo uc            = ECommerceContext.CurrentCustomer;
            string       mCustomerName = string.Format("{0} {1}", uc.CustomerFirstName, uc.CustomerLastName);
            // Set the properties
            ai.AddressName = string.Format("{0}, {4} {1} - {2} {3}", mCustomerName, ai.AddressLine1, ai.AddressZip, ai.AddressCity, ai.GetStringValue("AddressNumber", string.Empty));
            AddressInfoProvider.SetAddressInfo(ai);

            // Update page here
            ReloadDataAdress();
        }
    }