using Dapper; using dccdc.Models; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace dccdc.DAL { public class ERPLanEmailDal { public object save(ERPLanEmailModel model) { string sql = @"INSERT INTO [dbo].[ERPLanEmail] ([EmailTitle] ,[TimeStr] ,[EmailContent] ,[FuJian] ,[FromUser] ,[ToUser] ,[EmailState] ,[type]) VALUES (@EmailTitle ,@TimeStr ,@EmailContent ,@FuJian ,@FromUser ,@ToUser ,@EmailState ,@type)"; using (IDbConnection conn = CommHelper.GetSqlConnection("OADB")) { try { int result = conn.Execute(sql, model); if (result > 0) return new { State = 1, Message = "保存成功!" }; else return new { State = 0, Message = "保存失败!" }; } catch (Exception ex) { return new { State = 0, Message = ex.Message }; } } } public object update(string type, string touser) { string sql = "update ERPLanEmail set emailstate='已读' where type='" + type + "' and touser='" + touser + "'"; using (IDbConnection conn = CommHelper.GetSqlConnection("OADB")) { try { int result = conn.Execute(sql); if (result > 0) return new { State = 1, Message = "保存成功!" }; else return new { State = 0, Message = "保存失败!" }; } catch (Exception ex) { return new { State = 0, Message = ex.Message }; } } } } }