Exemplo n.º 1
0
        /// <summary>
        /// 添加数据
        /// <param name="es">数据实体对象数组</param>
        /// <returns></returns>
        /// </summary>
        public int Insert(ProProductionType e)
        {
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand    _cmdInsertProProductionType = cmdInsertProProductionType.Clone() as MySqlCommand;
            int             returnValue = 0;

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

                _cmdInsertProProductionType.Parameters["@PTypeName"].Value = e.PTypeName;
                _cmdInsertProProductionType.Parameters["@EntId"].Value     = e.EntId;
                _cmdInsertProProductionType.Parameters["@FatherId"].Value  = e.FatherId;
                _cmdInsertProProductionType.Parameters["@PicId"].Value     = e.PicId;

                _cmdInsertProProductionType.ExecuteNonQuery();
                returnValue = Convert.ToInt32(_cmdInsertProProductionType.LastInsertedId);
                return(returnValue);
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdInsertProProductionType.Dispose();
                _cmdInsertProProductionType = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取指定记录
        /// <param name="id">Id值</param>
        /// </summary>
        public ProProductionType Get(int PTypeId)
        {
            ProProductionType returnValue = null;
            MySqlConnection   oc          = ConnectManager.Create();
            MySqlCommand      _cmdGetProProductionType = cmdGetProProductionType.Clone() as MySqlCommand;

            _cmdGetProProductionType.Connection = oc;
            try
            {
                _cmdGetProProductionType.Parameters["@PTypeId"].Value = PTypeId;

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

                MySqlDataReader reader = _cmdGetProProductionType.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    returnValue = new ProProductionType().BuildSampleEntity(reader);
                }
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdGetProProductionType.Dispose();
                _cmdGetProProductionType = null;
                GC.Collect();
            }
            return(returnValue);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 修改指定的数据
        /// <param name="e">修改后的数据实体对象</param>
        /// <para>数据对应的主键必须在实例中设置</para>
        /// </summary>
        public void Update(ProProductionType e)
        {
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand    _cmdUpdateProProductionType = cmdUpdateProProductionType.Clone() as MySqlCommand;

            _cmdUpdateProProductionType.Connection = oc;

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

                _cmdUpdateProProductionType.Parameters["@PTypeId"].Value   = e.PTypeId;
                _cmdUpdateProProductionType.Parameters["@PTypeName"].Value = e.PTypeName;
                _cmdUpdateProProductionType.Parameters["@EntId"].Value     = e.EntId;
                _cmdUpdateProProductionType.Parameters["@FatherId"].Value  = e.FatherId;
                _cmdUpdateProProductionType.Parameters["@PicId"].Value     = e.PicId;

                _cmdUpdateProProductionType.ExecuteNonQuery();
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdUpdateProProductionType.Dispose();
                _cmdUpdateProProductionType = null;
                GC.Collect();
            }
        }
        /// <summary>
        ///添加产品分类
        /// </summary>
        /// <param name="ptype"></param>
        /// <returns></returns>
        public JsonResult AddProductionType(int fatherid, String pTypeName, int ptypepicid)
        {
            var               Res    = new JsonResult();
            RespResult        result = new RespResult();
            ProProductionType ptype  = new ProProductionType();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    ptype.EntId     = CurrentUser.EntId;
                    ptype.PicId     = ptypepicid;
                    ptype.PTypeName = pTypeName;
                    ptype.FatherId  = fatherid;

                    result.Id    = ProProductionTypeAccessor.Instance.Insert(ptype);
                    result.Error = result.Id > 0 ? AppError.ERROR_SUCCESS : AppError.ERROR_FAILED;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
        /// <summary>
        /// 根据产品ID获取产品信息
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        public JsonResult GetProductInfoByPID(int pid)
        {
            var Res = new JsonResult();
            AdvancedResult <ProProduction> result = new AdvancedResult <ProProduction>();

            try
            {
                if (!CheckUserFunction("2012"))
                {
                    result.Error            = AppError.ERROR_PERMISSION_FORBID;
                    Res.Data                = result;
                    Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                    return(Res);
                }
                result.Data = ProProductionAccessor.Instance.Get(pid);
                ProProductionType pt = ProProductionTypeAccessor.Instance.Get(result.Data.PTypeId);
                if (pt != null)
                {
                    result.Data.PTypeName = pt.PTypeName;
                }
                result.Error = AppError.ERROR_SUCCESS;
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 添加产品分类
        /// <param name="es">数据实体对象数组</param>
        /// <returns></returns>
        /// </summary>
        public bool Insert(ProProductionType e)
        {
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand    _cmdInsertProProductionType = cmdInsertProProductionType.Clone() as MySqlCommand;
            bool            returnValue = false;

            _cmdInsertProProductionType.Connection = oc;
            try
            {
                if (oc.State == ConnectionState.Closed)
                {
                    oc.Open();
                }
                _cmdInsertProProductionType.Parameters["@PTypeName"].Value = e.PTypeName;
                _cmdInsertProProductionType.Parameters["@UserId"].Value    = e.UserId;

                returnValue = _cmdInsertProProductionType.ExecuteNonQuery() > 0 ? true : returnValue;
                return(returnValue);
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdInsertProProductionType.Dispose();
                _cmdInsertProProductionType = null;
            }
        }
        /// <summary>
        ///添加产品分类
        /// </summary>
        /// <param name="ptype"></param>
        /// <returns></returns>
        public RespResult AddProductionType(ProProductionType ptype)
        {
            RespResult result = new RespResult();

            try
            {
                result.Error = ProProductionTypeAccessor.Instance.Insert(ptype) ? AppError.ERROR_SUCCESS : AppError.ERROR_FAILED;
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }