/// <summary>
 /// 执行返回值为标量的储存过程
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="functionName"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public T ExecuteFunction <T>(string functionName, params System.Data.EntityClient.EntityParameter[] parameters)
 {
     System.Data.EntityClient.EntityCommand cmd = ((System.Data.EntityClient.EntityConnection)context.Database.Connection).CreateCommand();
     cmd.CommandType = CommandType.StoredProcedure;
     foreach (var entityParameter in parameters)
     {
         if ((entityParameter.Direction == ParameterDirection.InputOutput || entityParameter.Direction == ParameterDirection.Input) && (entityParameter.Value == null))
         {
             //获取参数的值
             entityParameter.Value = DBNull.Value;
         }
         //添加参数
         cmd.Parameters.Add(new System.Data.EntityClient.EntityParameter(entityParameter.ParameterName, DbType.Decimal).Value);
     }
     cmd.Parameters.AddRange(parameters);
     cmd.CommandText = functionName;
     try
     {
         if (cmd.Connection.State != ConnectionState.Open)
         {
             cmd.Connection.Open();
         }
         var obj = cmd.ExecuteScalar();
         return((T)obj);
     }
     catch (Exception ex)
     {
         throw;
     }
     finally
     {
         cmd.Connection.Close();
     }
 }
 /// <summary>
 /// There are no comments for TutorialEntities.AgregarArticulo in the schema.
 /// </summary>
 public void AgregarArticulo(string PID, string PDESCRIPCION, global::System.Nullable <decimal> PCANT_PALLET_COMPLETO)
 {
     if (this.Connection.State != System.Data.ConnectionState.Open)
     {
         this.Connection.Open();
     }
     System.Data.EntityClient.EntityCommand command = new System.Data.EntityClient.EntityCommand();
     command.CommandType = System.Data.CommandType.StoredProcedure;
     command.CommandText = @"TutorialObjectContext.AgregarArticulo";
     command.Connection  = (System.Data.EntityClient.EntityConnection) this.Connection;
     global::System.Data.EntityClient.EntityParameter PIDParameter = new global::System.Data.EntityClient.EntityParameter("PID", System.Data.DbType.String);
     if (PID != null)
     {
         PIDParameter.Value = PID;
     }
     command.Parameters.Add(PIDParameter);
     global::System.Data.EntityClient.EntityParameter PDESCRIPCIONParameter = new global::System.Data.EntityClient.EntityParameter("PDESCRIPCION", System.Data.DbType.String);
     if (PDESCRIPCION != null)
     {
         PDESCRIPCIONParameter.Value = PDESCRIPCION;
     }
     command.Parameters.Add(PDESCRIPCIONParameter);
     global::System.Data.EntityClient.EntityParameter PCANT_PALLET_COMPLETOParameter = new global::System.Data.EntityClient.EntityParameter("PCANT_PALLET_COMPLETO", System.Data.DbType.Decimal);
     if (PCANT_PALLET_COMPLETO.HasValue)
     {
         PCANT_PALLET_COMPLETOParameter.Value = PCANT_PALLET_COMPLETO;
     }
     command.Parameters.Add(PCANT_PALLET_COMPLETOParameter);
     command.ExecuteNonQuery();
 }
 /// <summary>
 /// There are no comments for TutorialEntities.AgregarArticulo in the schema.
 /// </summary>
 public void AgregarArticulo(string PID, string PDESCRIPCION, global::System.Nullable<decimal> PCANT_PALLET_COMPLETO)
 {
     if (this.Connection.State != System.Data.ConnectionState.Open)
       this.Connection.Open();
     System.Data.EntityClient.EntityCommand command = new System.Data.EntityClient.EntityCommand();
     command.CommandType = System.Data.CommandType.StoredProcedure;
     command.CommandText = @"TutorialObjectContext.AgregarArticulo";
     command.Connection = (System.Data.EntityClient.EntityConnection)this.Connection;
     global::System.Data.EntityClient.EntityParameter PIDParameter = new global::System.Data.EntityClient.EntityParameter("PID", System.Data.DbType.String);
     if (PID != null)
         PIDParameter.Value = PID;
     command.Parameters.Add(PIDParameter);
     global::System.Data.EntityClient.EntityParameter PDESCRIPCIONParameter = new global::System.Data.EntityClient.EntityParameter("PDESCRIPCION", System.Data.DbType.String);
     if (PDESCRIPCION != null)
         PDESCRIPCIONParameter.Value = PDESCRIPCION;
     command.Parameters.Add(PDESCRIPCIONParameter);
     global::System.Data.EntityClient.EntityParameter PCANT_PALLET_COMPLETOParameter = new global::System.Data.EntityClient.EntityParameter("PCANT_PALLET_COMPLETO", System.Data.DbType.Decimal);
     if (PCANT_PALLET_COMPLETO.HasValue)
         PCANT_PALLET_COMPLETOParameter.Value = PCANT_PALLET_COMPLETO;
     command.Parameters.Add(PCANT_PALLET_COMPLETOParameter);
     command.ExecuteNonQuery();
 }