Esempio n. 1
0
    void BulkClearSalesPrice()
    {
        using (var connection = new SqlConnection(DB.GetDBConn()))
        {
            connection.Open();

            var whereClause = FilteredListing.GetFilterWhereClause();
            var setClause   = "null";
            var command     = new SqlCommand(BuildBatchUpdateCommandString(setClause, whereClause.Sql), connection);
            command.Parameters.AddRange(whereClause.Parameters.ToArray());

            DB.ExecuteSQL(command);
        }
    }
Esempio n. 2
0
    void BulkSaveSalesPrice(double discount)
    {
        using (var connection = new SqlConnection(DB.GetDBConn()))
        {
            connection.Open();

            var whereClause = FilteredListing.GetFilterWhereClause();
            var setClause   = ("Price * @discount");
            var command     = new SqlCommand(BuildBatchUpdateCommandString(setClause, whereClause.Sql), connection);
            command.Parameters.Add(new SqlParameter("discount", (100 - discount) / 100));
            command.Parameters.AddRange(whereClause.Parameters.ToArray());

            DB.ExecuteSQL(command);
        }
    }
Esempio n. 3
0
    void Save()
    {
        using (var connection = new SqlConnection(DB.GetDBConn()))
        {
            connection.Open();

            var items = repeatMap.Items.Cast <RepeaterItem>().Where(item => item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem);
            foreach (var item in items)
            {
                var variantId        = int.Parse((item.FindControl("lblVariantId") as Label).Text);
                var variantName      = (item.FindControl("txtVariantName") as TextBox).Text;
                var variantSKUSuffix = (item.FindControl("txtVariantSKUSuffix") as TextBox).Text;
                var price            = decimal.Parse((item.FindControl("txtPrice") as TextBox).Text);
                var inventory        = int.Parse((item.FindControl("txtInventory") as TextBox).Text);
                var published        = (item.FindControl("chkPublished") as CheckBox).Checked;
                var where = FilteredListing.GetFilterWhereClause();

                decimal?salePrice = null;
                decimal result;
                if (decimal.TryParse((item.FindControl("txtSalePrice") as TextBox).Text, out result))
                {
                    salePrice = result;
                }

                using (var command = new SqlCommand(@"
					update ProductVariant set
						Name = dbo.SetMlValue(Name, @Name, @_locale),
						SKUSuffix = @SKUSuffix,
						Price = @Price,
						SalePrice = @SalePrice,
						Inventory = @Inventory,
						Published = @published
					where VariantID = @VariantID"                    , connection))
                {
                    command.Parameters.Add(new SqlParameter("VariantID", variantId));
                    command.Parameters.Add(new SqlParameter("Name", variantName));
                    command.Parameters.Add(new SqlParameter("SKUSuffix", variantSKUSuffix));
                    command.Parameters.Add(new SqlParameter("Price", price));
                    command.Parameters.Add(new SqlParameter("SalePrice", (object)salePrice ?? DBNull.Value));
                    command.Parameters.Add(new SqlParameter("Inventory", inventory));
                    command.Parameters.Add(new SqlParameter("Published", published));
                    command.Parameters.Add(new SqlParameter("_locale", where.Parameters.Where(p => p.ParameterName == "_locale").FirstOrDefault().Value));

                    DB.ExecuteSQL(command);
                }
            }
        }
    }
Esempio n. 4
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            var exportContents = new StringBuilder();

            exportContents.AppendLine("Action, Description, Date, CustomerID, Email");

            // Can't use the grid as a datasource as it's paged, so query the DB with the same filters the grid is currently displaying
            using (var connection = new SqlConnection(DB.GetDBConn()))
                using (var command = connection.CreateCommand())
                {
                    var whereClause = FilteredListing.GetFilterWhereClause();

                    command.CommandText = string.Format(
                        @"select SecurityAction Action, Description, ActionDate Date, UpdatedBy CustomerID, c.EMail 
					from SecurityLog with (NOLOCK) 
					left outer join Customer c with (NOLOCK) on SecurityLog.UpdatedBy = c.CustomerID 
					where {0}"                    , whereClause.Sql);

                    command.Parameters.AddRange(whereClause.Parameters.ToArray());

                    connection.Open();
                    using (var reader = command.ExecuteReader())
                        while (reader.Read())
                        {
                            var shippedOn = DB.RSFieldDateTime(reader, "Date");

                            exportContents.AppendFormat(@"""{0}"",""{1}"",{2},{3},{4}{5}",
                                                        DecryptValue(reader.Field("Action")).Replace("\"", "\"\""),
                                                        DecryptValue(reader.Field("Description").Replace("\"", "\"\"")),
                                                        shippedOn == DateTime.MinValue
                                                                ? string.Empty
                                                                : shippedOn.ToString(),
                                                        reader.FieldInt("CustomerID"),
                                                        reader.Field("Email"),
                                                        Environment.NewLine);
                        }
                }

            // Send the CSV
            Response.Clear();
            Response.AddHeader("content-disposition", "attachment; filename=SecurityLogExport.csv");
            Response.BufferOutput = false;
            Response.ContentType  = "text/csv";
            Response.Output.Write(exportContents);
            Response.Flush();
            Response.End();
        }
    protected void Save(object sender, EventArgs e)
    {
        try
        {
            var items = repeatMap.Items.Cast <RepeaterItem>().Where(item => item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem);
            foreach (var item in items)
            {
                var variantId = int.Parse(((Label)item.FindControl("lblVariantId")).Text);
                var where = FilteredListing.GetFilterWhereClause();

                string dimensions = BuildDimensions(item);

                var isShipSeparately = ((CheckBox)item.FindControl("chkIsShipSeparately")).Checked;

                decimal?weight = null;
                decimal result;
                if (decimal.TryParse(((TextBox)item.FindControl("txtWeight")).Text, out result) && result > 0)
                {
                    weight = result;
                }

                using (var connection = new SqlConnection(DB.GetDBConn()))
                {
                    if (weight != null)
                    {
                        SaveWeight(weight.Value, variantId, connection);
                    }

                    if (dimensions != null)
                    {
                        SaveDimensions(dimensions, variantId, connection);
                    }

                    SaveShipSeparately(isShipSeparately, variantId, connection);
                }
            }

            AlertMessage.PushAlertMessage(AppLogic.GetString("admin.bulkeditweights.weightsupdated", ThisCustomer.LocaleSetting), AspDotNetStorefrontControls.AlertMessage.AlertType.Success);
        }
        catch (Exception ex)
        {
            AlertMessage.PushAlertMessage(ex.Message, AspDotNetStorefrontControls.AlertMessage.AlertType.Error);
        }
    }
Esempio n. 6
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            var exportContents = new StringBuilder();

            exportContents.AppendLine(MakeHeaderRow());

            //Can't use the grid as a datasource as it's paged, so query the DB with the same filters the grid is currently displaying
            using (var conn = new SqlConnection(DB.GetDBConn()))
            {
                conn.Open();

                var whereClause = FilteredListing.GetFilterWhereClause();
                var sql         = string.Format(
                    @"SELECT OrderNumber, ShippedOn, ShippedVIA, ShippingTrackingNumber,
						ShippingMethod, ShippingFirstName, ShippingLastName, ShippingAddress1,
						ShippingAddress2, ShippingSuite, ShippingCity, ShippingState, ShippingZip,
						ShippingCountry, ShippingPhone, Phone, Email
					FROM Orders WHERE {0}"                    , whereClause.Sql);

                using (var command = new SqlCommand(sql, conn))
                {
                    command.Parameters.AddRange(whereClause.Parameters.ToArray());

                    using (IDataReader rs = command.ExecuteReader())
                    {
                        while (rs.Read())
                        {
                            exportContents.Append(DB.RSFieldInt(rs, "OrderNumber").ToString());
                            exportContents.Append(",");

                            var shippedOn = DB.RSFieldDateTime(rs, "ShippedOn");
                            exportContents.Append(shippedOn == DateTime.MinValue ? string.Empty : shippedOn.ToString());
                            exportContents.Append(",");

                            exportContents.Append(DB.RSField(rs, "ShippedVIA"));
                            exportContents.Append(",");

                            exportContents.Append(DB.RSField(rs, "ShippingTrackingNumber"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingMethod"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingFirstName"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingLastName"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingAddress1"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingAddress2"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingSuite"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingCity"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingState"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingZip"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingCountry"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "ShippingPhone"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "Phone"));
                            exportContents.Append(",");
                            exportContents.Append(DB.RSField(rs, "Email"));
                            exportContents.Append("\r\n");
                        }
                    }
                }
            }

            //Save a copy in images
            var filepath     = CommonLogic.SafeMapPath("~/images") + "\\";
            var filename     = "ShippingExport_" + Localization.ToNativeDateTimeString(DateTime.Now).Replace(" ", "_").Replace(",", "_").Replace("/", "_").Replace(":", "_").Replace(".", "_") + ".csv";
            var fullFilePath = filepath + filename;

            File.WriteAllText(fullFilePath, exportContents.ToString());

            // Send the CSV
            Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment; filename=ShippingExport.csv");
            Response.BufferOutput = false;
            Response.ContentType  = "text/csv";
            Response.TransmitFile(fullFilePath);
            Response.Flush();
            Response.End();
        }
Esempio n. 7
0
        protected void btnExport_Click(Object sender, EventArgs e)
        {
            Response.Clear();
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=SystemLog.txt");

            Response.Write("----------------------------------------------------------------------\r\n");
            Response.Write("----------------------------------------------------------------------\r\n");
            Response.Write("SYSTEM INFORMATION \r\n");
            Response.Write("----------------------------------------------------------------------\r\n");
            Response.Write("----------------------------------------------------------------------\r\n");

            Response.Write("\r\n");
            Response.Write("Version:            " + CommonLogic.GetVersion() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("On Live Server:     " + AppLogic.OnLiveServer().ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("UseSSL:             " + AppLogic.UseSSL().ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Is Secure Page:     " + CommonLogic.IsSecureConnection().ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Changed Admin Dir:  " + CommonLogic.IIF(AppLogic.AppConfig("AdminDir").ToLowerInvariant() == "admin", "No", "Yes") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Caching:            " + (AppLogic.AppConfigBool("CacheMenus") ? AppLogic.GetString("admin.common.OnUC", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) : AppLogic.GetString("admin.common.OffUC", AppLogic.DefaultSkinID(), Localization.GetDefaultLocale())) + "\r\n");
            Response.Write("\r\n");
            Response.Write("----------------------LOCALIZATION----------------------\r\n");
            Response.Write("\r\n");
            Response.Write("Web Config Locale:  " + Localization.GetDefaultLocale() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("SQL Server Locale:  " + Localization.GetSqlServerLocale() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Store Currency:     " + AppLogic.AppConfig("Localization.StoreCurrency") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Store Currency Code:" + AppLogic.AppConfig("Localization.StoreCurrencyNumericCode") + "\r\n");
            Response.Write("\r\n");
            Response.Write("----------------------GATEWAY INFO----------------------\r\n");
            Response.Write("\r\n");
            Response.Write("Payment Gateway:    " + AppLogic.ActivePaymentGatewayRAW() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Use Live Transactions:" + (AppLogic.AppConfigBool("UseLiveTransactions") ? AppLogic.GetString("admin.splash.aspx.20", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) : AppLogic.GetString("admin.splash.aspx.21", AppLogic.DefaultSkinID(), Localization.GetDefaultLocale())) + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Transaction Mode:   " + AppLogic.AppConfig("TransactionMode").ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Payment Methods:    " + AppLogic.AppConfig("PaymentMethods").ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Primary Currency:   " + Localization.GetPrimaryCurrency() + "\r\n");
            Response.Write("\r\n");
            Response.Write("----------------------SHIPPING INFO----------------------\r\n");
            Response.Write("\r\n");
            Response.Write("Shipping Rates Table:" + DB.GetSqlS("select Name as S from dbo.ShippingCalculation where Selected=1") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Origin State:       " + AppLogic.AppConfig("RTShipping.OriginState") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Origin Zip:         " + AppLogic.AppConfig("RTShipping.OriginZip") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Origin Country:     " + AppLogic.AppConfig("RTShipping.OriginCountry") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Free Shipping Threshold: " + AppLogic.AppConfigNativeDecimal("FreeShippingThreshold").ToString() + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Free Shipping Method:" + AppLogic.AppConfig("ShippingMethodIDIfFreeShippingIsOn") + "\r\n");
            Response.Write("----------------------\r\n");
            Response.Write("Allow Rate Selection:" + CommonLogic.IIF(AppLogic.AppConfigBool("FreeShippingAllowsRateSelection"), "On", "Off") + "\r\n");
            Response.Write("\r\n\r\n");

            var whereClause = FilteredListing.GetFilterWhereClause();
            var sql         = String.Format("select * from aspdnsf_SysLog where {0}", whereClause.Sql);

            using (var connection = new SqlConnection(DB.GetDBConn()))
                using (var command = new SqlCommand(sql, connection))
                {
                    connection.Open();
                    command.Parameters.AddRange(whereClause.Parameters.ToArray());

                    using (var reader = command.ExecuteReader())
                        while (reader.Read())
                        {
                            Response.Write("----------------------------------------------------------------------\r\n");
                            Response.Write("----------------------------------------------------------------------\r\n");
                            Response.Write(AppLogic.GetString("admin.systemlog.aspx.1", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ": ");
                            Response.Write(DB.RSFieldInt(reader, "SysLogID").ToString() + "  " + DB.RSFieldDateTime(reader, "CreatedOn").ToString() + "  \r\n");
                            Response.Write("----------------------------------------------------------------------\r\n");
                            Response.Write("----------------------------------------------------------------------\r\n");
                            Response.Write("\r\n\r\n");
                            Response.Write(DB.RSField(reader, "Message"));
                            Response.Write("\r\n\r\n");
                            Response.Write(DB.RSField(reader, "Details"));
                            Response.Write("\r\n\r\n");
                        }
                }

            Response.Flush();
            Response.Close();
        }