/// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        int addressId = ValidationHelper.GetInteger(actionArgument, 0);

        if (actionName == "edit")
        {
            URLHelper.Redirect("Customer_Edit_Address_Edit.aspx?customerId=" + customerObj.CustomerID + "&addressId=" + addressId);
        }
        else if (actionName == "delete")
        {
            if (!ECommerceContext.IsUserAuthorizedToModifyCustomer())
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers");
            }

            var address = AddressInfoProvider.GetAddressInfo(addressId);

            // Check for the address dependencies
            if ((address != null) && address.Generalized.CheckDependencies())
            {
                ShowError(ECommerceHelper.GetDependencyMessage(address));
                return;
            }

            // Delete AddressInfo object from database
            AddressInfoProvider.DeleteAddressInfo(address);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            URLHelper.Redirect("Customer_Edit_Address_Edit.aspx?customerId=" + customerId + "&addressId=" + Convert.ToString(actionArgument));
        }
        else if (actionName == "delete")
        {
            if (customerObj == null)
            {
                return;
            }

            if (!ECommerceContext.IsUserAuthorizedToModifyCustomer())
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers");
            }

            int addressId = ValidationHelper.GetInteger(actionArgument, 0);
            // Check for the address dependences
            if (AddressInfoProvider.CheckDependencies(addressId))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Ecommerce.DeleteDisabled");
                return;
            }

            // Delete AddressInfo object from database
            AddressInfoProvider.DeleteAddressInfo(addressId);
        }
    }
        public void DeleteAddress(int addressID)
        {
            var address = AddressInfoProvider.GetAddressInfo(addressID);

            if (address != null)
            {
                AddressInfoProvider.DeleteAddressInfo(addressID);
            }
        }
Exemplo n.º 4
0
    protected void btnHiddenDelete_Click(object sender, EventArgs e)
    {
        // Get AddressId from the row
        AddressId = ValidationHelper.GetInteger(hdnID.Value, 0);

        // Check for the address dependences
        if (AddressInfoProvider.CheckDependencies(AddressId))
        {
            lblError.Visible = true;
            lblError.Text    = GetString("Ecommerce.DeleteDisabled");
            return;
        }

        // Delete AddressInfo object from database
        AddressInfoProvider.DeleteAddressInfo(AddressId);

        gridAddresses.ReBind();
    }
Exemplo n.º 5
0
    protected void btnHiddenDelete_Click(object sender, EventArgs e)
    {
        // Get AddressId from the row
        AddressId = ValidationHelper.GetInteger(hdnID.Value, 0);

        // Check for the address dependences
        DataSet ds = OrderInfoProvider.GetOrders("OrderBillingAddressID=" + AddressId + " OR OrderShippingAddressID=" + AddressId + " OR OrderCompanyAddressID=" + AddressId, null);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            lblError.Visible = true;
            lblError.Text    = GetString("Ecommerce.DeleteDisabled");
            return;
        }

        // Delete AddressInfo object from database
        AddressInfoProvider.DeleteAddressInfo(AddressId);

        gridAddresses.ReBind();
    }
        public bool DeleteAddress(int addressID)
        {
            bool returnValue = false;
            var  address     = AddressInfoProvider.GetAddressInfo(addressID);

            if (address != null)
            {
                AddressInfoProvider.DeleteAddressInfo(addressID);
                //Delete data from Shipping Table..
                ShippingAddressItem shippingAddress = new ShippingAddressItem();
                string        customTableClassName  = shippingAddress.ClassName;
                DataClassInfo customTable           = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
                if (customTable != null)
                {
                    CustomTableItemProvider.DeleteItems(customTableClassName, "COM_AddressID =" + addressID);
                    returnValue = true;
                }
            }

            return(returnValue);
        }
    private void DeleteAddress()
    {
        // Prepare the parameters
        //string where = "AddressName LIKE 'My New%'";

        // Get the address
        DataSet addresses = AddressInfoProvider.GetAddresses(null, null);

        if (!DataHelper.DataSourceIsEmpty(addresses))
        {
            // Create object from DataRow
            AddressInfo updateAddress = new AddressInfo(addresses.Tables[0].Rows[0]);

            // Delete the address
            AddressInfoProvider.DeleteAddressInfo(updateAddress);

            // return true;
        }

        // return false;
    }
    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();
        }
    }