示例#1
0
        /// <summary>
        /// 邮件拼接的字符串
        /// </summary>
        /// <param name="applyId"></param>
        /// <param name="memberId"></param>
        /// <returns></returns>
        private static string EmailBodyStr(int applyId, int memberId)
        {
            //申请单明细
            VIPApplyDetail vad      = new VIPApplyDetail();
            List <int>     applyIds = new List <int>();

            applyIds.Add(applyId);
            DataSet       dsDetail = vad.GetApplyDetailByApplyId(applyIds);
            StringBuilder strTable = new StringBuilder();

            //申请单明细  添加英文
            strTable.Append(@"<table style='border-collapse:collapse;'>
<tr style='border:1px solid #aac1de;'>
<td style='border:1px solid #aac1de; padding:5px;'>序号(No.)</td>
<td style='border:1px solid #aac1de; padding:5px;'>商品编号(Id)</td>
<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>商品名称(Product )</td>
<td style='border:1px solid #aac1de; padding:5px;'>单位(Unit)</td>
<td style='border:1px solid #aac1de; padding:5px;'>数量(Num)</td>
<td style='border:1px solid #aac1de; padding:5px;'>单价(Price)</td>
<td style='border:1px solid #aac1de; padding:5px;'>金额(Amount)</td>
</tr>");
            int index = 1;

            foreach (DataRow row in dsDetail.Tables[0].Rows)
            {
                decimal amount = Convert.ToDecimal(row["VIPPrice"]) * Convert.ToInt32(row["Num"]);
                strTable.Append("<tr style='border:1px solid #aac1de;'>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + index.ToString() + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + row["GoodsId"] + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px;'>" + row["DisplayName"] + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + row["Unit"] + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + row["num"] + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + string.Format("{0:F2}", row["VIPPrice"]) + "</td>");
                strTable.Append("<td style='border:1px solid #aac1de; padding:5px; text-align:center;'>" + amount.ToString("0.00") + "</td>");
                strTable.Append("</tr>");
                index += 1;
            }
            strTable.Append("</table>");
            string applyId1s = CommenClass.Encrypt.EncryptDES(applyId.ToString(), "leading1");
            //获取token
            Emailapply ea = new Emailapply();

            ea.ApplyId   = applyId;
            ea.MemberId  = memberId;
            ea.Token     = Guid.NewGuid().ToString() + Guid.NewGuid().ToString();
            ea.StartTime = DateTime.Now;
            ea.EndTime   = DateTime.Now.AddDays(30); //DateTime.Now.AddHours(48);
            ea.Save();

            VIPApplyManager vam    = new VIPApplyManager();
            VIPApplyOption  option = new VIPApplyOption();

            option.Id           = applyId;
            option.ConfirmLevel = -1;
            DataRow  row1       = vam.ReadApply(option).Tables[0].Rows[0];
            string   DeptName   = DBTool.GetStringFromRow(row1, "DeptName", "");
            string   RealName   = DBTool.GetStringFromRow(row1, "RealName", "");
            double   SumMoney   = DBTool.GetDoubleFromRow(row1, "SumMoney", 0);
            DateTime UpdateTime = DBTool.GetDateTimeFromRow(row1, "UpdateTime");
            string   ApplyInfo  = string.Format("Id:{0}&nbsp;&nbsp;部门(Dept):{1}&nbsp;&nbsp;申请人(Applicant):{2}&nbsp;&nbsp;总金额(Amount):{3}&nbsp;&nbsp;日期(Date):{4}", applyId, DeptName, RealName, SumMoney, UpdateTime);
            string   url        = CommenClass.SiteUrl.HomeUrl();
            //string url ="http://*****:*****@"
系统邮件,请勿回复!(Don't reply this email.)<br/><br/>
您好,您有1张订单需要审批,明细如下(Hello, There is an application form need you to approve):<br/><br/>
{0}<br/><br/>
{1}<br/><br/> {2}&nbsp;&nbsp;&nbsp;&nbsp;{3}&nbsp;&nbsp;&nbsp;&nbsp;{4}<br/>",
                                       ApplyInfo, strTable, strConfirm, applydetail, strToConfirmOrder);

            return(str);
        }
示例#2
0
 /// <summary>
 /// 发送申请单邮件(可审核)
 /// </summary>
 /// <param name="applyId"></param>
 /// <param name="dt">该申请单是被谁审核的 管理员的表 </param>
 /// <returns></returns>
 public bool SendEmail(int applyId, int isPass)
 {
     if (applyId > 0)//申请单添加成功,审核消息发送给对应的管理员
     {
         //1、找到要发邮件的对应的人
         //通过ApplyId找到(新申请单生成)申请人,(审核过一级的)审核了一次的审核人
         VIPApply apply = new VIPApply(applyId);
         if (apply.Status == "待审核")
         {
             int            memberId = apply.OperatorId > 0 ? apply.OperatorId : apply.MemberId;
             VIPApplyOption option   = new VIPApplyOption();
             Member         member   = new Member();
             DataSet        ds       = member.GetDeptComIdByMemberId(memberId);
             option.ComId    = Convert.ToInt32(ds.Tables[0].Rows[0]["ComId"]);
             option.MemberId = memberId;
             option.RoleId   = 2;//成本中心管理员
             option.Code     = Convert.ToString(ds.Tables[0].Rows[0]["Code"]);
             VIPApplyManager vam       = new VIPApplyManager();
             DataSet         dsAdmin   = vam.GetAdmin(option);
             List <int>      memberIds = new List <int>();
             if (dsAdmin.Tables[0].Rows.Count > 0)
             {
                 int SendmemberId = Convert.ToInt32(dsAdmin.Tables[0].Rows[0]["MemberId"]);//上一级成本中心
                 memberIds.Add(SendmemberId);
             }
             //越级是 admin+sys_admin  逐级是admin
             if (isPass == 1)//越级
             {
                 MemberRole role        = new MemberRole();
                 DataSet    dsMemberIds = role.GetSysAdmin(option.ComId);//找到系统管理
                 if (dsMemberIds.Tables[0].Rows.Count > 0)
                 {
                     memberIds.Add(Convert.ToInt32(dsMemberIds.Tables[0].Rows[0]["MemberId"]));
                 }
             }
             if (memberIds.Count > 0)
             {
                 Memberinfocfg configure = new Memberinfocfg();
                 DataSet       dsEmail   = configure.GetIsPassAudit(memberIds);
                 if (dsEmail.Tables[0].Rows.Count > 0)
                 {
                     for (int i = 0; i < dsEmail.Tables[0].Rows.Count; i++)
                     {
                         if (dsEmail.Tables[0].Rows[i]["Type"].ToString() == "实时发送" && Convert.ToInt32(dsEmail.Tables[0].Rows[i]["Value"]) == 1)
                         {
                             string emailss = dsEmail.Tables[0].Rows[i]["Email"].ToString();
                             if (emailss != "")
                             {
                                 int mId = Convert.ToInt32(dsEmail.Tables[0].Rows[i]["MemberId"]);
                                 mailToArray = new string[] { emailss };
                                 mailSubject = "订单审核:您有新订单需要审核 来自 领先办公(Stationery Order: You have one new order need to approve _ from Leading Future)";
                                 mailBody    = EmailBodyStr(applyId, mId);
                                 isbodyHtml  = true;
                                 Send();
                             }
                         }
                     }
                 }
             }
         }
         return(true);
     }
     return(false);
 }