Beispiel #1
0
        /// <summary>
        /// 获取指定记录
        /// <param name="id">Id值</param>
        /// </summary>
        public MarketingVisit Get(int IdmarketingVisit)
        {
            MarketingVisit  returnValue           = null;
            MySqlConnection oc                    = ConnectManager.Create();
            MySqlCommand    _cmdGetMarketingVisit = cmdGetMarketingVisit.Clone() as MySqlCommand;

            _cmdGetMarketingVisit.Connection = oc;
            try
            {
                _cmdGetMarketingVisit.Parameters["@IdmarketingVisit"].Value = IdmarketingVisit;

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

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

            _cmdUpdateMarketingVisit.Connection = oc;

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

                _cmdUpdateMarketingVisit.Parameters["@IdmarketingVisit"].Value = e.IdmarketingVisit;
                _cmdUpdateMarketingVisit.Parameters["@VisitType"].Value        = e.VisitType;
                _cmdUpdateMarketingVisit.Parameters["@Amount"].Value           = e.Amount;
                _cmdUpdateMarketingVisit.Parameters["@Address"].Value          = e.Address;
                _cmdUpdateMarketingVisit.Parameters["@Remark"].Value           = e.Remark;
                _cmdUpdateMarketingVisit.Parameters["@VisitTime"].Value        = e.VisitTime;
                _cmdUpdateMarketingVisit.Parameters["@ChanceId"].Value         = e.ChanceId;
                _cmdUpdateMarketingVisit.Parameters["@EntId"].Value            = e.EntId;

                _cmdUpdateMarketingVisit.ExecuteNonQuery();
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdUpdateMarketingVisit.Dispose();
                _cmdUpdateMarketingVisit = null;
                GC.Collect();
            }
        }
Beispiel #3
0
        /// <summary>
        /// 添加数据
        /// <param name="es">数据实体对象数组</param>
        /// <returns></returns>
        /// </summary>
        public int Insert(MarketingVisit e)
        {
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand    _cmdInsertMarketingVisit = cmdInsertMarketingVisit.Clone() as MySqlCommand;
            int             returnValue = 0;

            _cmdInsertMarketingVisit.Connection = oc;
            try
            {
                if (oc.State == ConnectionState.Closed)
                {
                    oc.Open();
                }
                _cmdInsertMarketingVisit.Parameters["@VisitType"].Value = e.VisitType;
                _cmdInsertMarketingVisit.Parameters["@Amount"].Value    = e.Amount;
                _cmdInsertMarketingVisit.Parameters["@Address"].Value   = e.Address;
                _cmdInsertMarketingVisit.Parameters["@Remark"].Value    = e.Remark;
                _cmdInsertMarketingVisit.Parameters["@VisitTime"].Value = e.VisitTime;
                _cmdInsertMarketingVisit.Parameters["@ChanceId"].Value  = e.ChanceId;
                _cmdInsertMarketingVisit.Parameters["@EntId"].Value     = e.EntId;

                _cmdInsertMarketingVisit.ExecuteNonQuery();
                returnValue = Convert.ToInt32(_cmdInsertMarketingVisit.LastInsertedId);
                return(returnValue);
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdInsertMarketingVisit.Dispose();
                _cmdInsertMarketingVisit = null;
            }
        }
Beispiel #4
0
        //针对单个销售机会拜访客户(销售机会ID,拜访方式,拜访描述,报价,地点,token)
        //返回(True/false)注:如果是第一次则需修改机会表字段为已拜访
        public JsonResult ToVisit(int cid, int visitType, string remark, Double amount, String address)
        {
            var        Res    = new JsonResult();
            RespResult result = new RespResult();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction(21))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }
                    MarketingVisit mv = new MarketingVisit();
                    mv.Address   = address;
                    mv.Amount    = amount;
                    mv.ChanceId  = cid;
                    mv.Remark    = remark;
                    mv.VisitTime = DateTime.Now;
                    mv.VisitType = visitType;
                    mv.EntId     = CurrentUser.EntId;
                    int i = MarketingVisitAccessor.Instance.Insert(mv);

                    if (i > 0)
                    {
                        MarketingChanceAccessor.Instance.UpdateisVisit(cid, 2);
                        result.Error = AppError.ERROR_SUCCESS;
                    }
                    else
                    {
                        result.Error = 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);
        }
        //编辑拜访记录(拜访记录ID,拜访方式,拜访描述,报价,地点)返回(true/false)
        public JsonResult EditVisitInfo(int vid, int visitType, string remark, Double amount, String address)
        {
            var        Res    = new JsonResult();
            RespResult result = new RespResult();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction("1204"))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }
                    MarketingVisit mv = MarketingVisitAccessor.Instance.Get(vid);
                    mv.Address          = address;
                    mv.Amount           = amount;
                    mv.IdmarketingVisit = vid;
                    mv.Remark           = remark;
                    mv.VisitType        = visitType;
                    MarketingVisitAccessor.Instance.Update(mv);
                    result.Error = AppError.ERROR_SUCCESS;
                }
                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);
        }