/// <summary>
 /// 添加入库单
 /// </summary>
 /// <param name="ppd"></param>
 /// <returns></returns>
 public RespResult AddProductonDetail(ProProductonDetail ppd)
 {
     RespResult result = new RespResult();
     try
     {
         result.Error = ProProductonDetailAccessor.Instance.Insert(ppd) ? AppError.ERROR_SUCCESS : AppError.ERROR_FAILED;
     }
     catch (Exception e)
     {
         result.Error = AppError.ERROR_FAILED;
         result.ExMessage = e.ToString();
     }
     return result;
 }
        /// <summary>
        /// 修改指定的数据
        /// <param name="e">修改后的数据实体对象</param>
        /// <para>数据对应的主键必须在实例中设置</para>
        /// </summary>
        public void Update(ProProductonDetail e)
        {
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand _cmdUpdateProProductonDetail = cmdUpdateProProductonDetail.Clone() as MySqlCommand;
            _cmdUpdateProProductonDetail.Connection = oc;

            try
            {
                if (oc.State == ConnectionState.Closed)
                    oc.Open();
                _cmdUpdateProProductonDetail.Parameters["@PDId"].Value = e.PDId;
                _cmdUpdateProProductonDetail.Parameters["@Price"].Value = e.Price;
                _cmdUpdateProProductonDetail.Parameters["@PNum"].Value = e.PNum;
                _cmdUpdateProProductonDetail.Parameters["@PCode"].Value = e.PCode;
                _cmdUpdateProProductonDetail.Parameters["@CreateTime"].Value = e.CreateTime;
                _cmdUpdateProProductonDetail.Parameters["@UserId"].Value = e.UserId;
                _cmdUpdateProProductonDetail.Parameters["@PId"].Value = e.UserId;
                _cmdUpdateProProductonDetail.ExecuteNonQuery();

            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdUpdateProProductonDetail.Dispose();
                _cmdUpdateProProductonDetail = null;
                GC.Collect();
            }
        }
 /// <summary>
 /// 添加数据
 /// <param name="es">数据实体对象数组</param>
 /// <returns></returns>
 /// </summary>
 public bool Insert(ProProductonDetail e)
 {
     MySqlConnection oc = ConnectManager.Create();
     MySqlCommand _cmdInsertProProductonDetail = cmdInsertProProductonDetail.Clone() as MySqlCommand;
     bool returnValue = false;
     _cmdInsertProProductonDetail.Connection = oc;
     try
     {
         if (oc.State == ConnectionState.Closed)
             oc.Open();
         _cmdInsertProProductonDetail.Parameters["@Price"].Value = e.Price;
         _cmdInsertProProductonDetail.Parameters["@PNum"].Value = e.PNum;
         _cmdInsertProProductonDetail.Parameters["@PCode"].Value = e.PCode;
         _cmdInsertProProductonDetail.Parameters["@CreateTime"].Value = e.CreateTime;
         _cmdInsertProProductonDetail.Parameters["@UserId"].Value = e.UserId;
         _cmdInsertProProductonDetail.Parameters["@PId"].Value = e.Pid;
         returnValue= _cmdInsertProProductonDetail.ExecuteNonQuery()>0?true:returnValue;
         return returnValue;
     }
     finally
     {
         oc.Close();
         oc.Dispose();
         oc = null;
         _cmdInsertProProductonDetail.Dispose();
         _cmdInsertProProductonDetail = null;
     }
 }
        /// <summary>
        /// 获取指定记录
        /// <param name="id">Id值</param>
        /// </summary>
        public ProProductonDetail Get(int PDId)
        {
            ProProductonDetail returnValue = null;
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand _cmdGetProProductonDetail = cmdGetProProductonDetail.Clone() as MySqlCommand;

            _cmdGetProProductonDetail.Connection = oc;
            try
            {
                _cmdGetProProductonDetail.Parameters["@PDId"].Value = PDId;

                if (oc.State == ConnectionState.Closed)
                    oc.Open();

                MySqlDataReader reader = _cmdGetProProductonDetail.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    returnValue = new ProProductonDetail().BuildSampleEntity(reader);
                }
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdGetProProductonDetail.Dispose();
                _cmdGetProProductonDetail = null;
                GC.Collect();
            }
            return returnValue;
        }