예제 #1
0
        /// <summary>
        /// delete a customerlog
        /// <summary>
        /// <param name=id>id</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Delete(int id, out string emsg)
        {
            try
            {
                modCustomerLog mod = GetItem(id, out emsg);
                if (mod == null)
                {
                    emsg = null;
                    return(true);
                }
                dalUserList dalu    = new dalUserList();
                DateTime    svrtime = dalu.GetServerTime(out emsg);
                TimeSpan    ts1     = new TimeSpan(svrtime.Ticks);
                TimeSpan    ts2     = new TimeSpan(DateTime.Parse(mod.ToTime).Ticks);
                TimeSpan    ts      = ts1.Subtract(ts2).Duration();
                if (ts.Days < 0)
                {
                    emsg = "您不能删除未来的工作日志!";
                    return(false);
                }
                dalSysParameters dalp = new dalSysParameters();
                int delaydays         = Convert.ToInt32(dalp.GetParaValue("CUSTOMER_LOG_DELAY_DAYS"));
                if (ts.Days >= delaydays)
                {
                    emsg = "您提交的日期不能超过" + delaydays.ToString() + "天";
                    return(false);
                }

                string sql = string.Format("delete customer_log where id={0} ", id);
                int    i   = SqlHelper.ExecuteNonQuery(sql);
                if (i > 0)
                {
                    emsg = null;
                    return(true);
                }
                else
                {
                    emsg = "Unknown error when ExecuteNonQuery!";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// update a customerlog
        /// <summary>
        /// <param name=id>id</param>
        /// <param name=mod>model object of customerlog</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Update(int id, modCustomerLog mod, out string emsg)
        {
            try
            {
                dalUserList dalu    = new dalUserList();
                DateTime    svrtime = dalu.GetServerTime(out emsg);
                TimeSpan    ts1     = new TimeSpan(svrtime.Ticks);
                TimeSpan    ts2     = new TimeSpan(DateTime.Parse(mod.ToTime).Ticks);
                TimeSpan    ts      = ts1.Subtract(ts2).Duration();
                if (ts.Days < 0)
                {
                    emsg = "您不能更新未来的工作日志!";
                    return(false);
                }

                dalSysParameters dalp = new dalSysParameters();
                int delaydays         = Convert.ToInt32(dalp.GetParaValue("CUSTOMER_LOG_DELAY_DAYS"));
                if (ts.Days >= delaydays)
                {
                    emsg = "你提交的日期不能超过" + delaydays.ToString() + "天";
                    return(false);
                }

                string sql = string.Format("update customer_log set cust_id='{0}',cust_name='{1}',action_code='{2}',action_type='{3}',action_man='{4}',form_id='{5}',action_subject='{6}',action_content='{7}',object_name='{8}',venue='{9}',from_time='{10}',to_time='{11}',scores={12},ad_flag={13},update_user='******',update_time=getdate() where id={15}", mod.CustId, mod.CustName, mod.ActionCode, mod.ActionType, mod.ActionMan, mod.FormId, mod.ActionSubject, mod.ActionContent, mod.ObjectName, mod.Venue, mod.FromTime, mod.ToTime, mod.Scores, mod.AdFlag, mod.UpdateUser, id);
                int    i   = SqlHelper.ExecuteNonQuery(sql);
                if (i > 0)
                {
                    emsg = null;
                    return(true);
                }
                else
                {
                    emsg = "Unknown error when ExecuteNonQuery!";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
        }
예제 #3
0
        /// <summary>
        /// insert a crmactionschedule
        /// <summary>
        /// <param name=mod>model object of crmactionschedule</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Insert(modCrmActionSchedule mod, out string emsg)
        {
            try
            {
                dalUserList dalu    = new dalUserList();
                DateTime    svrtime = dalu.GetServerTime(out emsg);
                TimeSpan    ts1     = new TimeSpan(svrtime.Ticks);
                TimeSpan    ts2     = new TimeSpan(mod.ActionDate.Ticks);
                TimeSpan    ts      = ts2.Subtract(ts1).Duration();
                if (ts.Days < 0)
                {
                    emsg = "您不能新增过去的工作计划!";
                    return(false);
                }
                dalSysParameters dalp = new dalSysParameters();
                int aheaddays         = Convert.ToInt32(dalp.GetParaValue("ACTION_SCHEDULE_AHEAD_DAYS"));
                if (ts.Days > aheaddays)
                {
                    emsg = "您不能提交" + aheaddays.ToString() + "天后的工作计划";
                    return(false);
                }

                string sql = string.Format("insert into crm_action_schedule(action_man,action_date,action_content,status,status_desc,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}',getdate())", mod.ActionMan, mod.ActionDate, mod.ActionContent, mod.Status, mod.StatusDesc, mod.UpdateUser);
                int    i   = SqlHelper.ExecuteNonQuery(sql);
                if (i > 0)
                {
                    emsg = null;
                    return(true);
                }
                else
                {
                    emsg = "Unknown error when ExecuteNonQuery!";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
        }