Ejemplo n.º 1
0
 public bool SaveCarrierDetails(ShippingCarrierModel carrier)
 {
     using (var connection = new SqlConnection(Constants.ConnectorDatabase))
     {
         const string commandText = @"IF @CarrierId<=0
                                             Insert into [ShippingCarrier] (CarrierName,CarrierDescription) values (@CarrierName,@CarrierDescription);
                                             ELSE
                                             update ShippingCarrier set CarrierName=@CarrierName,CarrierDescription=@CarrierDescription where CarrierId=@CarrierId";
         var          cmd         = new SqlCommand(commandText, connection);
         cmd.Parameters.AddWithValue("@CarrierId", carrier.CarrierId);
         cmd.Parameters.AddWithValue("@CarrierName", carrier.CarrierCode);
         cmd.Parameters.AddWithValue("@CarrierDescription", carrier.CarrierDescription);
         connection.Open();
         int i = cmd.ExecuteNonQuery();
         return(i > 0);
     }
 }
Ejemplo n.º 2
0
        public bool IsCarrierExists(ShippingCarrierModel carrier)
        {
            using (var connection = new SqlConnection(Constants.ConnectorDatabase))
            {
                const string commandText = @"Select CarrierId from ShippingCarrier where CarrierName=@CarrierName and CarrierId<>@CarrierId";
                using (var command = new SqlCommand(commandText, connection))
                {
                    connection.Open();
                    command.Parameters.AddWithValue("@CarrierName", carrier.CarrierCode);
                    command.Parameters.AddWithValue("@CarrierId", carrier.CarrierId);

                    using (SqlDataReader dataReader = command.ExecuteReader())
                    {
                        return(dataReader.Read());
                    }
                }
            }
        }
 private void ClearValues()
 {
     Carrier           = new ShippingCarrierModel();
     ValidationMessage = "";
 }