Ejemplo n.º 1
0
        public static ShipGateway Load(Int32 shipGatewayId, bool useCache)
        {
            if (shipGatewayId == 0)
            {
                return(null);
            }
            ShipGateway shipGateway = null;
            string      key         = "ShipGateway_" + shipGatewayId.ToString();

            if (useCache)
            {
                shipGateway = ContextCache.GetObject(key) as ShipGateway;
                if (shipGateway != null)
                {
                    return(shipGateway);
                }
            }
            shipGateway = new ShipGateway();
            if (shipGateway.Load(shipGatewayId))
            {
                if (useCache)
                {
                    ContextCache.SetObject(key, shipGateway);
                }
                return(shipGateway);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public static bool Delete(Int32 shipGatewayId)
        {
            ShipGateway shipGateway = new ShipGateway();

            if (shipGateway.Load(shipGatewayId))
            {
                return(shipGateway.Delete());
            }
            return(false);
        }
 /// <summary>
 /// Loads the given ShipGateway object from the given database data reader.
 /// </summary>
 /// <param name="shipGateway">The ShipGateway object to load.</param>
 /// <param name="dr">The database data reader to read data from.</param>
 public static void LoadDataReader(ShipGateway shipGateway, IDataReader dr)
 {
     //SET FIELDS FROM ROW DATA
     shipGateway.ShipGatewayId = dr.GetInt32(0);
     shipGateway.StoreId       = dr.GetInt32(1);
     shipGateway.Name          = dr.GetString(2);
     shipGateway.ClassId       = dr.GetString(3);
     shipGateway.ConfigData    = NullableData.GetString(dr, 4);
     shipGateway.ReCrypt       = dr.GetBoolean(5);
     shipGateway.Enabled       = dr.GetBoolean(6);
     shipGateway.IsDirty       = false;
 }
Ejemplo n.º 4
0
        public static ShipGatewayCollection LoadForStore(int maximumRows, int startRowIndex, string sortExpression)
        {
            int storeId = Token.Instance.StoreId;
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT");
            if (maximumRows > 0)
            {
                selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString());
            }
            selectQuery.Append(" " + ShipGateway.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_ShipGateways");
            selectQuery.Append(" WHERE StoreId = @storeId");
            if (!string.IsNullOrEmpty(sortExpression))
            {
                selectQuery.Append(" ORDER BY " + sortExpression);
            }
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, storeId);
            //EXECUTE THE COMMAND
            ShipGatewayCollection results = new ShipGatewayCollection();
            int thisIndex = 0;
            int rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        ShipGateway shipGateway = new ShipGateway();
                        ShipGateway.LoadDataReader(shipGateway, dr);
                        results.Add(shipGateway);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
Ejemplo n.º 5
0
        public static ShipGatewayCollection LoadForClassId(string classId)
        {
            ShipGatewayCollection ShipGateways = new ShipGatewayCollection();
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand("SELECT " + ShipGateway.GetColumnNames(string.Empty) + "  FROM ac_ShipGateways WHERE StoreId=@storeId AND ClassId=@classId");

            database.AddInParameter(selectCommand, "@storeId", DbType.Int32, Token.Instance.StoreId);
            database.AddInParameter(selectCommand, "@classId", DbType.String, classId);
            //EXECUTE THE COMMAND
            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read())
                {
                    ShipGateway shipGateway = new ShipGateway();
                    ShipGateway.LoadDataReader(shipGateway, dr);
                    ShipGateways.Add(shipGateway);
                }
                dr.Close();
            }
            return(ShipGateways);
        }
Ejemplo n.º 6
0
        protected void Page_Init(object sender, EventArgs e)
        {
            int shipmentId = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]);

            _OrderShipment = OrderShipmentDataSource.Load(shipmentId);
            if (_OrderShipment == null)
            {
                Response.Redirect("../Default.aspx");
            }
            _Order                   = _OrderShipment.Order;
            Caption.Text             = string.Format(Caption.Text, _Order.OrderNumber);
            ShipmentNumber.Text      = string.Format(ShipmentNumber.Text, _Order.Shipments.IndexOf(_OrderShipment.Id) + 1, _Order.Shipments.Count);
            ShippingMethod.Text      = _OrderShipment.ShipMethodName;
            trShipMessage.Visible    = !string.IsNullOrEmpty(_OrderShipment.ShipMessage);
            ShipMessage.Text         = _OrderShipment.ShipMessage;
            ShipFrom.Text            = _OrderShipment.FormatFromAddress();
            ShipTo.Text              = _OrderShipment.FormatToAddress();
            ShipmentItems.DataSource = GetShipmentItems();
            ShipmentItems.DataBind();

            // check if ship gateway supports shipping feature
            CommerceBuilder.Shipping.ShipGateway shipGateway = _OrderShipment.ShipMethod != null ?_OrderShipment.ShipMethod.ShipGateway : null;
            IShippingProvider shipProvider = null;

            if (shipGateway != null)
            {
                shipProvider = shipGateway.GetProviderInstance();
                _IsProviderSupportShipping = shipProvider != null && shipProvider.IsShippingSupported;
            }

            ShipGateway.DataSource = ShipGatewayDataSource.LoadAll();
            ShipGateway.DataBind();
            if (ShipGateway.Items.Count > 1)
            {
                //TRY TO PRESET THE CORRECT GATEWAY
                if (_OrderShipment.ShipMethod != null)
                {
                    ListItem item = ShipGateway.Items.FindByValue(_OrderShipment.ShipMethod.ShipGatewayId.ToString());
                    if (item != null)
                    {
                        item.Selected = true;
                    }
                }
            }
            else
            {
                ShipGateway.Visible = false;
            }

            if (_IsProviderSupportShipping)
            {
                autoTrackingInputPanel.Visible = true;

                // update the provider name
                ProviderInstructionText.Text    = string.Format(ProviderInstructionText.Text, shipProvider.Name);
                ProviderInstructionText.Visible = true;
            }
            else
            {
                autoTrackingInputPanel.Visible = false;
            }

            CancelButton.NavigateUrl += "?OrderNumber=" + _OrderShipment.Order.OrderNumber.ToString();
        }
Ejemplo n.º 7
0
 public static SaveResult Insert(ShipGateway shipGateway)
 {
     return(shipGateway.Save());
 }
Ejemplo n.º 8
0
 public static SaveResult Update(ShipGateway shipGateway)
 {
     return(shipGateway.Save());
 }
Ejemplo n.º 9
0
 public static bool Delete(ShipGateway shipGateway)
 {
     return(shipGateway.Delete());
 }