コード例 #1
0
 /// <summary>
 ///添加产品
 /// </summary>
 /// <param name="pro"></param>
 /// <returns></returns>
 public RespResult AddProduction(ProProduction pro)
 {
     RespResult result = new RespResult();
     try
     {
         result.Error = ProProductionAccessor.Instance.Insert(pro) ? AppError.ERROR_SUCCESS : AppError.ERROR_FAILED;
     }
     catch (Exception e)
     {
         result.Error = AppError.ERROR_FAILED;
         result.ExMessage = e.ToString();
     }
     return result;
 }
コード例 #2
0
 /// <summary>
 /// 添加数据
 /// <param name="es">数据实体对象数组</param>
 /// <returns></returns>
 /// </summary>
 public bool Insert(ProProduction e)
 {
     MySqlConnection oc = ConnectManager.Create();
     MySqlCommand _cmdInsertProProduction = cmdInsertProProduction.Clone() as MySqlCommand;
     bool returnValue = false;
     _cmdInsertProProduction.Connection = oc;
     try
     {
         if (oc.State == ConnectionState.Closed)
             oc.Open();
         _cmdInsertProProduction.Parameters["@PName"].Value = e.PName;
         _cmdInsertProProduction.Parameters["@PInfo"].Value = e.PInfo;
         _cmdInsertProProduction.Parameters["@Unit"].Value = e.Unit;
         _cmdInsertProProduction.Parameters["@PTypeId"].Value = e.PTypeId;
         _cmdInsertProProduction.Parameters["@LowestPrice"].Value = e.LowestPrice;
         _cmdInsertProProduction.Parameters["@MarketPrice"].Value = e.MarketPrice;
         _cmdInsertProProduction.Parameters["@UserId"].Value = e.UserId;
         returnValue = _cmdInsertProProduction.ExecuteNonQuery() > 0 ? true : returnValue;
         return returnValue;
     }
     finally
     {
         oc.Close();
         oc.Dispose();
         oc = null;
         _cmdInsertProProduction.Dispose();
         _cmdInsertProProduction = null;
     }
 }
コード例 #3
0
        /// <summary>
        /// 修改指定的数据
        /// <param name="e">修改后的数据实体对象</param>
        /// <para>数据对应的主键必须在实例中设置</para>
        /// </summary>
        public void Update(ProProduction e)
        {
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand _cmdUpdateProProduction = cmdUpdateProProduction.Clone() as MySqlCommand;
            _cmdUpdateProProduction.Connection = oc;

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

                _cmdUpdateProProduction.Parameters["@PId"].Value = e.PId;
                _cmdUpdateProProduction.Parameters["@PName"].Value = e.PName;
                _cmdUpdateProProduction.Parameters["@PInfo"].Value = e.PInfo;
                _cmdUpdateProProduction.Parameters["@Unit"].Value = e.Unit;
                _cmdUpdateProProduction.Parameters["@PTypeId"].Value = e.PTypeId;
                _cmdUpdateProProduction.Parameters["@LowestPrice"].Value = e.LowestPrice;
                _cmdUpdateProProduction.Parameters["@MarketPrice"].Value = e.MarketPrice;
                _cmdUpdateProProduction.Parameters["@UserId"].Value = e.UserId;

                _cmdUpdateProProduction.ExecuteNonQuery();

            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdUpdateProProduction.Dispose();
                _cmdUpdateProProduction = null;
                GC.Collect();
            }
        }
コード例 #4
0
        /// <summary>
        /// 获取指定记录
        /// <param name="id">Id值</param>
        /// </summary>
        public ProProduction Get(int PId)
        {
            ProProduction returnValue = null;
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand _cmdGetProProduction = cmdGetProProduction.Clone() as MySqlCommand;

            _cmdGetProProduction.Connection = oc;
            try
            {
                _cmdGetProProduction.Parameters["@PId"].Value = PId;

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

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