public int ChangeStatus(string status, string id) { int rowId = int.Parse(id); StringBuilder strSql = new StringBuilder(); switch (status) { case "1": strSql.Append("update i200.dbo.T_OutLink set state=0 where id=@id;"); break; case "0": strSql.Append("update i200.dbo.T_OutLink set state=1 where id=@id;"); break; } try { int st = DapperHelper.Execute(strSql.ToString(), new { id = rowId }); if (st != 0) { return(1); } else { return(0); } } catch (Exception ex) { return(0); } }
/// <summary> /// 添加新的用户模板 /// </summary> /// <param name="model"></param> /// <returns></returns> public string AddTemplate(TriggerTemplateModel model) { StringBuilder strSql = new StringBuilder(); //如果已经存在则禁用掉 if (CheckTemplateExist(model.EventId)) { UnactiveOldTemplate(model.EventId); } strSql.Append("insert into Sys_MessageNotify (MissionTarget,MissionName,UserDesc," + "SmsMark,MobileMark,WebMark,EmailMark,SmsContent,MobileTitle,MobileContent," + "MobileContentType,MobileContentUrl,EmailTitle,EmailContent,WebTitle,WebContent,CreateTime,Operator,EnableStatus,EventId) " + "Values (@MissionTarget,@MissionName,@UserDesc," + "@SmsMark,@MobileMark,@WebMark,@EmailMark,@SmsContent,@MobileTitle,@MobileContent," + "@MobileContentType,@MobileContentUrl,@EmailTitle,@EmailContent,@WebTitle,@WebContent,@CreateTime,@Operator,@EnableStatus,@EventId);"); try { return(DapperHelper.Execute(strSql.ToString(), model).ToString()); } catch (Exception ex) { Logger.Error("插入触发类消息模板出错", ex); return("0"); } }
/// <summary> /// 插入当日数据 /// </summary> /// <param name="?"></param> /// <returns></returns> public int InsertShopActive(ActiveStatus model) { if (CheckShopActive(model.ShowDate) == 1) { UpdateTodayActive(model); } StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Sys_TempActiveStatus " + "(ShowDate,AllUsr,NewReg,UnknownUsr,RegAttention,Attention,LoginUsr," + "RegUsr,ActiveUsr,FaithUsr,SleepUsr,OutUsr,Time) " + "Values(@ShowDate,@AllUsr,@NewReg,@UnknownUsr," + "@RegAttention,@Attention,@LoginUsr,@RegUsr,@ActiveUsr,@FaithUsr,@SleepUsr,@OutUsr,@Time);"); return(DapperHelper.Execute(strSql.ToString(), new { ShowDate = model.ShowDate, AllUsr = model.AllUsr, NewReg = model.NewReg, UnknownUsr = model.UnknownUsr, RegAttention = model.RegAttention, Attention = model.Attention, LoginUsr = model.LoginUsr, RegUsr = model.RegUsr, ActiveUsr = model.ActiveUsr, FaithUsr = model.FaithUsr, SleepUsr = model.SleepUsr, OutUsr = model.OutUsr, Time = model.Time })); }
public string ModifyAgentInfo(AgentModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("select AgentPassword from Sys_I200.dbo.Sys_agent_mess where id=@id;"); string pwd = DapperHelper.ExecuteScalar <string>(strSql.ToString(), new { id = model.ID }); strSql.Clear(); if (model.AgentPassword != pwd) { model.AgentPassword = CommonLib.Helper.Md5Hash(model.AgentPassword); } strSql.Append("update Sys_I200.dbo.Sys_agent_mess set " + " AgentPassword=@pwd," + " AgentName=@name," + " AgentGrade=@grade," + " AgentPhone=@phone," + " AgentAddress=@address," + " AgentIdCard=@idCard," + " AgentNumber=@number," + " AgentEmail=@email," + " AgentQQ=@qq," + " Remark=@remark ," + " ServiceType=@serviceType " + " where id=@id"); try { int reVal = DapperHelper.Execute(strSql.ToString(), new { pwd = model.AgentPassword, name = model.AgentName, grade = model.AgentGrade, phone = model.AgentPhone, address = model.AgentAddress, idCard = model.AgentIdCard, number = model.AgentNumber, email = model.AgentEmail, qq = model.AgentQQ, remark = model.Remark, serviceType = model.ServiceType, id = model.ID }); if (reVal > 0) { return("1"); } else { return("0"); } } catch (Exception ex) { return("0"); } }
/// <summary> /// 初始化用户问题信息 /// </summary> /// <param name="accId"></param> /// <returns></returns> public void InitialUserQuestion(int accId) { StringBuilder strSql = new StringBuilder(); strSql.Append("if exists (select * from Sys_Visit_Question_List where AccId=@accid) "); strSql.Append(" begin "); strSql.Append(" select 1; "); strSql.Append(" end "); strSql.Append(" else "); strSql.Append(" begin "); strSql.Append(" select 0 "); //strSql.Append(" select @@IDENTITY; "); strSql.Append(" end"); int mark = DapperHelper.ExecuteScalar <int>(strSql.ToString(), new { accid = accId }); if (mark == 0) { strSql.Clear(); strSql.Append("select * from Sys_Visit_Question where Status=1;"); List <Sys_Visit_Question> list = DapperHelper.Query <Sys_Visit_Question>(strSql.ToString()).ToList(); strSql.Clear(); foreach (var item in list) { strSql.Append("insert into Sys_Visit_Question_List (AccId,Qid,Reply) Values (@accid," + item.Id + ",'');"); } DapperHelper.Execute(strSql.ToString(), new { accid = accId }); } }
/// <summary> /// 初始化条件设置记录 /// </summary> /// <param name="uid"></param> /// <param name="accIdList"></param> /// <param name="verif"></param> /// <returns></returns> public int InitialConditionRecord(int uid, string accIdList, int accIdCount, string verif) { StringBuilder strSql = new StringBuilder(); strSql.Append( "insert into I200_Task.dbo.ConditionSetting (Verification,AccIdSet,AccIdCount,ActiveStatus,Operator) " + "Values (@verif,@accIdList,@accIdCount,0,@uid);" + "select @@IDENTITY;"); try { return(DapperHelper.Execute(strSql.ToString(), new { verif = verif, accIdList = accIdList, accIdCount = accIdCount, uid = uid })); } catch (Exception ex) { Logger.Error("发送消息初始化条件组失败!", ex); return(0); } }
/// <summary> /// 新增/修改用户问题 /// </summary> /// <param name="accId"></param> /// <param name="qid"></param> /// <param name="reply"></param> /// <returns></returns> public int AddQuestionReply(int accId, int qid, string reply) { StringBuilder strSql = new StringBuilder(); strSql.Append("if exists (select * from Sys_Visit_Question_List where AccId=@accid and Qid=@qid) "); strSql.Append(" begin "); strSql.Append(" update Sys_Visit_Question_List set Reply=@reply where AccId=@accid and Qid=@qid; "); strSql.Append(" end "); strSql.Append(" else "); strSql.Append(" begin "); strSql.Append(" insert into Sys_Visit_Question_List (AccId,Qid,Reply) values (@accid,@qid,@reply) "); //strSql.Append(" select @@IDENTITY; "); strSql.Append(" end"); try { return(DapperHelper.Execute(strSql.ToString(), new { accid = accId, qid = qid, reply = reply })); } catch (Exception ex) { Logger.Error("更新用户回访问题出错!", ex); return(0); } }
/// <summary> /// 更新密码 /// </summary> public int UpdatePassWordEmployId(int id, string oldPass, string newPass) { StringBuilder strSql = new StringBuilder(); strSql.Append(" if(EXISTS(select * from Sys_Manage_User where Id=@id and PassWord=@oldPass)) "); strSql.Append(" begin "); strSql.Append(" update Sys_Manage_User set PassWord=@newPass where Id=@id; "); strSql.Append(" select 2; "); strSql.Append(" end "); strSql.Append(" else "); strSql.Append(" select 1;"); int result = 0; try { result = DapperHelper.Execute(strSql.ToString(), new { id = id, oldPass = oldPass, newPass = newPass }); } catch (Exception) { return(0); } return(result); }
/// <summary> /// 用户注册数据访问层方法 /// </summary> /// <param name="user"></param> /// <returns></returns> public int UserRegist(UserInfo user) { int res = 0; string sql = $@"INSERT INTO [dbo].[UserInfo] ( [UserPhone] ,[UserName] ,[UserPass] ,[UserSalt] ,[Status] ,[CreateTime] ,[UpdateTime] ,[CreaterId] ,[UpdaterId]) VALUES ( @UserPhone ,@UserName ,@UserPass ,@UserSalt ,1 ,GETDATE() ,GETDATE() ,1 ,1);"; res = DapperHelper <UserInfo> .Execute(sql, user); return(res); }
/// <summary> /// 添加一条充值记录 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddNewRecord(RechargeRecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append( "insert into Sys_RechargeRecord (AccId,OrderNo,State,CardNum,RealNum,PaidNum,GapNum,CardName,AddTime,Oid) Values " + "(@accId,@orderNo,@state,@cardNum,@realNum,@paidNum,@gapNum,@cardName,@addTime,@oid);"); try { return(DapperHelper.Execute(strSql.ToString(), new { accId = model.AccId, orderNo = model.OrderNo, state = model.State, cardNum = model.CardNum, realNum = model.RealNum, paidNum = model.PaidNum, gapNum = model.GapNum, cardName = model.CardName, addTime = model.AddTime, oid = model.Oid })); } catch (Exception ex) { Logger.Error("添加充值记录出错", ex); return(0); } }
/// <summary> /// 公司发布招聘添加 /// </summary> /// <param name="company"></param> /// <returns></returns> public int AddCompany(CompanyManage company) { int result = 0; try { //字符串添加 string str = "insert into CompanyManage values(@C_CheckIndustry,@C_AvailablePositions,@C_TypeLabor,@C_NearEstoffice,@C_JobRequirements,@C_Name,@C_CompanyPhone,@C_EmailAddress,@C_CompanyName)"; //调用 result = DapperHelper <CompanyManage> .Execute(str, new { C_CheckIndustry = company.C_CheckIndustry, C_AvailablePositions = company.C_AvailablePositions, C_TypeLabor = company.C_TypeLabor, C_NearEstoffice = company.C_NearEstoffice, C_JobRequirements = company.C_JobRequirements, C_Name = company.C_Name, C_CompanyPhone = company.C_CompanyPhone, C_EmailAddress = company.C_EmailAddress, C_CompanyName = company.C_CompanyName }); } catch (Exception e) { Logger.Error(e.TargetSite.ToString()); } return(result); }
//public Contractmanagement GetContractmanagement(PageProperty page) //{ // Contractmanagement info = new Contractmanagement(); // var p = new DynamicParameters(); // p.Add("@Pageindex", page.PageIndex); // p.Add("@PageSize", page.PageSize); // p.Add("@ProjectNumber", page.ProjectNumber); // p.Add("@Projectstage", page.Projectstage); // p.Add("@TotalCount", page.Projectstage, DbType.Int32, ParameterDirection.Output); // info.Project = DapperHelper<ProjectInfo>.ExecutePro("dbo.P_ProjectShow", p); // info.TotalCount = p.Get<int>("@TotalCount"); // return info; //} /// <summary> /// 删除合同 /// </summary> /// <param name="cInfo"></param> /// <returns></returns> public int AddContractmanagement(int Id) { string sql = @"DELETE FROM [dbo].[Contractmanagement] WHERE Id=@Id"; return(DapperHelper <Contractmanagement> .Execute(sql, new { Id = Id })); }
/// <summary> /// 添加合同 /// </summary> /// <param name="cInfo"></param> /// <returns></returns> public int AddContractmanagement(Contractmanagement cInfo) { string sql = @"INSERT INTO [dbo].[Contractmanagement] ([Contractnumber] ,[Contractname] ,[Contracttype] ,[Personincharge] ,[Effectivedate] ,[Expirationdate] ,[Status] ,[CreateTime] ,[UpdateTime] ,[CreaterId] ,[UpdaterId]) VALUES @Contractnumber ,@Contractname ,@Contracttype ,@Personincharge ,@Effectivedate ,@Expirationdate ,1 ,GETDATE() ,GETDATE() ,1 ,1"; return(DapperHelper <Contractmanagement> .Execute(sql, cInfo)); }
/// <summary> /// 退款日志 /// </summary> /// <param name="oid">订单号</param> /// <param name="name">名称</param> /// <param name="oper">操作者</param> /// <param name="accid">店铺ID</param> /// <param name="type"> /// 类型 /// 1-完整订单 /// 2-订单详情 /// </param> /// <param name="realMoney"> /// 退款金额 /// </param> /// <param name="quantity">数量</param> /// <param name="desc"></param> /// <returns></returns> public int AddDrawbackRec(int oid, int accid, string name, int oper, int type, decimal realMoney, int quantity, string desc) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Sys_DrawbackRec (Oid,AccId,Name,Oper,Type,ReturnMoney,Quantity,OperTime,Descrip) " + "Values(@oid,@accid,@name,@oper,@type,@realMoney,@quantity,getdate(),@desc);"); try { return(DapperHelper.Execute(strSql.ToString(), new { oid = oid, accid = accid, name = name, oper = oper, type = type, realMoney = realMoney, quantity = quantity, desc = desc })); } catch (Exception ex) { Logger.Error("增加退款日志记录出错!", ex); return(0); } }
/// <summary> /// 根据接口返回状态更新详情列表状态 /// </summary> /// <param name="batchId"></param> /// <param name="channelId"></param> /// <param name="statusModel"></param> /// <returns></returns> public int UpdateDetailSendingStatus(string batchId, int channelId, SendStatus statusModel) { StringBuilder strSql = new StringBuilder(); if (statusModel != null) { if (statusModel.DataList != null) { if (statusModel.DataList.Count > 0) { foreach (var item in statusModel.DataList) { if (channelId == 1 || channelId == 4) { strSql.Append("update MessageDetail set ArriveMark=@arriveMark,OpenMark=@openMark " + " where AccIdNumber='" + item.TargetId + "' and BatchId='" + batchId + "' and channelId=" + channelId); } else { strSql.Append("update MessageDetail set ArriveMark=@arriveMark,OpenMark=@openMark " + " where AccId=" + item.TargetId + " and BatchId='" + batchId + "' and channelId=" + channelId); } try { DapperHelper.Execute(strSql.ToString(), new { arriveMark = (item.SendStatus == 1 ? 1 : -99), openMark = (item.IsRead) }); strSql.Clear(); } catch (Exception ex) { Logger.Error("更新发送详情列表出错", ex); strSql.Clear(); continue; } } } //空列表返回正常状态 return(0); } else { //返回发送状态的详情列表为空 return(-1); } } else { //返回发送状态为空 return(-2); } }
/// <summary> /// 公司界面添加 /// </summary> /// <param name="company"></param> /// <returns></returns> public int InsertCompany(Company com) { int result = 0; try { //字符串添加 string str = "insert into Company values(@CName,@CNameNature,@Cnumber,@CompanyIndustry,@CompanyProfile,@Companyposition,@CompanyPhone)"; //调用 result = DapperHelper <Company> .Execute(str, new { CName = com.CName, CNameNature = com.CNameNature, Cnumber = com.Cnumber, CompanyIndustry = com.CompanyIndustry, CompanyProfile = com.CompanyProfile, Companyposition = com.Companyposition, CompanyPhone = com.CompanyPhone }); } catch (Exception e) { Logger.Error(e.TargetSite.ToString()); } return(result); }
//删除操作 public bool Delete(string id, IDbTransaction trans = null) { string sql = @"delete from BookInfo where bookguid=@bookguid"; int result = DapperHelper.Execute(sql, new { bookguid = id }, trans); return(result > 0); }
/// <summary> /// 添加批次概览信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddMsgSendingInfo(MessageSending model) { StringBuilder strSql = new StringBuilder(); strSql.Append( "insert into MessageSending (BatchId,AccIdSet,AccIdCount,ChannelSet,ActionType,ActionMark,Remark,CreateTime) " + "Values(@BatchId,@AccIdSet,@AccIdCount,@ChannelSet,@ActionType,@ActionMark,@Remark,@CreateTime)"); try { int reVal = DapperHelper.Execute(strSql.ToString(), new { BatchId = model.BatchId, AccIdSet = model.AccIdSet, AccIdCount = model.AccIdCount, ChannelSet = model.ChannelSet, ActionType = 0, ActionMark = 0, Remark = model.Remark, CreateTime = DateTime.Now }); return(reVal); } catch (Exception ex) { Logger.Error("插入批次" + model.BatchId + "概览详情出错", ex); return(0); } }
/// <summary> /// 添加一条信息详情 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddMessageDetail(MessageDetail model) { StringBuilder strSql = new StringBuilder(); strSql.Append( "insert into MessageDetail (BatchId,AccId,Title,Content,ArriveMark,OpenMark,ChannelId,Remark,CreateTime,AccIdNumber,ContentType,ContentUrl) " + "Values(@BatchId,@AccId,@Title,@Content,@ArriveMark,@OpenMark,@ChannelId,@Remark,@CreateTime,@AccIdNumber,@ContentType,@ContentUrl)"); try { int reVal = DapperHelper.Execute(strSql.ToString(), new { BatchId = model.BatchId, AccId = model.AccId, Title = model.Title, Content = model.Content, ArriveMark = 0, OpenMark = 0, ChannelId = model.ChannelId, Remark = model.Remark, CreateTime = DateTime.Now, AccIdNumber = model.AccIdNumber, ContentType = model.ContentType, ContentUrl = model.ContentUrl }); return(reVal); } catch (Exception ex) { Logger.Error("插入批次" + model.BatchId + "消息详情出错", ex); return(0); } }
public int UpdateDetailUnableMark(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("update MessageDetail set ArriveMark=-1 where Id=" + id); return(DapperHelper.Execute(strSql.ToString())); }
/// <summary> /// 禁用老模板 /// </summary> /// <param name="eventId"></param> /// <returns></returns> public int UnactiveOldTemplate(int eventId) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Sys_MessageNotify set EnableStatus=0 where eventId=@eventId;"); return(DapperHelper.Execute(strSql.ToString(), new { eventId = eventId })); }
/// <summary> /// 更新清洗状态 /// </summary> /// <param name="accid"></param> /// <returns></returns> public int UpdateFilterStatus(int accid) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SysStat_IndustryFilter set Remark='1' where AccId=@accid;"); return(DapperHelper.Execute(strSql.ToString(), new { accid = accid })); }
/// <summary> /// 变更任务状态 /// </summary> /// <param name="id"></param> /// <param name="type"></param> /// <returns></returns> public string ChangeTaskStatus(int id, int type, string desc) { StringBuilder strSql = new StringBuilder(); strSql.Append("update RequirementManage set Status=" + type + ",Description='" + desc + "' where Id=" + id); return(DapperHelper.Execute(strSql.ToString()).ToString()); }
public int UpdateOperator(int operId, string batchId, int channelId) { StringBuilder strSql = new StringBuilder(); strSql.Append("update MessageBatch set Operator=" + operId + " where BatchId='" + batchId + "' and ChannelId=" + channelId); return(DapperHelper.Execute(strSql.ToString())); }
/// <summary> /// 更新批次表的发送数以及关联发送ID /// </summary> /// <param name="batchId"></param> /// <param name="channelId"></param> /// <param name="count"></param> /// <param name="sendId"></param> /// <returns></returns> public int UpdateAllowCount(string batchId, int channelId, int count, string sendId) { StringBuilder strSql = new StringBuilder(); strSql.Append("update MessageBatch set SendId='" + sendId + "',AllowNumber=" + count + " where BatchId='" + batchId + "' and channelId=" + channelId); return(DapperHelper.Execute(strSql.ToString())); }
/// <summary> /// 删除一条KPI数据 /// </summary> /// <param name="id"></param> /// <returns></returns> public int DeleteKPI(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("Update Sys_PresetKPI set DelStatus=1 where id=@id"); int status = DapperHelper.Execute(strSql.ToString(), new { id = id }); return(status); }
/// <summary> /// 记录登录日志 /// </summary> /// <param name="UserID">ID</param> /// <param name="sIP"></param> /// <param name="sBrowser"></param> public void LoginLog(int UserID, string sIP, string sBrowser) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Sys_Manage_User set LastLoginTime=getdate(),loginCounter=isnull(loginCounter,0)+1 where id=@UserID;"); strSql.Append("insert into Sys_ManageLog (logtype,operdate,managerid,loginfo,logmode,typeid,Loginbrslast,ip) values "); strSql.Append("(1,getdate(),@UserID,'后台用户登录',0,@UserID,@sBrowser,@sIP);"); int iResult = DapperHelper.Execute(strSql.ToString(), new { UserID = UserID, sIP = sIP, sBrowser = sBrowser }); }
//记录更新日志 public int UpdateIndustryFilterLog(IndustryFilterLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append( "insert into SysStat_IndustryFilter_Log (AccId,FormerIndustry,NowIndustry,UpdateTime,Keyword) " + "Values (@AccId,@FormerIndustry,@NowIndustry,@UpdateTime,@Keyword);"); return(DapperHelper.Execute(strSql.ToString(), model)); }
/// <summary> /// 新增阶段 /// </summary> /// <returns></returns> public int AddStage(StagePlanInfo info) { string sql = @"insert into StagePlanInfo (StageName,StageStartTime,StageFinishTime, StageStaffName,ProjectStageId,StageStaus) values(@StageName,@StageStartTime, @StageFinishTime,@StageStaffName, @ProjectStageId,@StageStaus)"; return(DapperHelper <StagePlanInfo> .Execute(sql, info)); }
/// <summary> /// 修改积分商城统计数据 /// 更新方式为全部更新 /// </summary> /// <param name="dayDate"></param> /// <param name="model"></param> /// <returns> /// 0-没有找到对应日期的对象 /// 1-更新出错 /// 2-更新成功 /// </returns> public int ModifyRecord(DateTime dayDate, IntegralExchangeModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from Sys_DailyIntegralExchange where DayDate=@dayDate;"); Model.Sys_DailyIntegralExchange modelForUpdate = new Model.Sys_DailyIntegralExchange(); int reVal = 0; List <Model.Sys_DailyIntegralExchange> models = DapperHelper.Query <Model.Sys_DailyIntegralExchange>(strSql.ToString(), new { dayDate = dayDate }).ToList(); strSql.Clear(); if (models != null && models.Count > 0) { foreach (Model.Sys_DailyIntegralExchange item in models) { strSql.Clear(); modelForUpdate = model.DataList.Find(x => x.ProductName == item.ProductName); strSql.Append( "update Sys_DailyIntegralExchange set VisitNum=@visitNum,ExchangeNum=@exchangeNum,Ratio=@ratio " + "where DayDate=@dayDate and ProductName=@productName;"); try { reVal = DapperHelper.Execute(strSql.ToString(), new { visitNum = modelForUpdate.VisitNum, exchangeNum = modelForUpdate.ExchangeNum, ratio = modelForUpdate.Ratio, dayDate = dayDate, productName = item.ProductName }); if (reVal <= 0) { return(1); } } catch (Exception ex) { return(1); } } return(2); } else { return(0); } }