示例#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
 private int modifyVIPApply(VIPApply apply, List <VIPApplyDetail> details, int OperaterId)
 {
     if (apply.Save() > 0)
     {
         //记录修改明细
         //循环新表处理 修改数量的商品 和 新增商品
         VIPApplyDetail vad = new VIPApplyDetail();
         vad.ApplyId = apply.Id;
         DataTable dtOld = vad.GetApplyDetailByApplyId().Tables[0];
         for (int i = 0; i < details.Count; i++)
         {
             DataRow[] rows = dtOld.Select(string.Format(" GoodsId={0} ", details[i].GoodsId));
             if (rows.Length == 1)//有这个商品
             {
                 int oldNum = DBTool.GetIntFromRow(rows[0], "Num", 0);
                 if (details[i].Num != oldNum)//数量改变需要修改
                 {
                     vad.Id = DBTool.GetIntFromRow(rows[0], "Id", 0);
                     vad.Load();
                     vad.Num = details[i].Num;
                     if (vad.Save() > 0)
                     {
                         //按专柜中没有组合商品处理
                         //修改明细记录
                         VIPApplyModify vam = new VIPApplyModify();
                         vam.ApplyId    = apply.Id;
                         vam.GoodsId    = vad.GoodsId;
                         vam.OldNum     = oldNum;
                         vam.NewNum     = vad.Num;
                         vam.OperaterId = OperaterId;//记录操作人
                         vam.UpdateTime = DateTime.Now;
                         vam.Save();
                     }
                 }
             }
             else //新增商品
             {
                 VIPApplyDetail svad = new VIPApplyDetail();
                 svad.ApplyId  = apply.Id;
                 svad.GoodsId  = details[i].GoodsId;
                 svad.Num      = details[i].Num;
                 svad.VIPPrice = details[i].VIPPrice;
                 if (svad.Save() > 0)
                 {
                     //修改明细记录
                     VIPApplyModify vam = new VIPApplyModify();
                     vam.ApplyId    = apply.Id;
                     vam.GoodsId    = svad.GoodsId;
                     vam.OldNum     = 0;
                     vam.NewNum     = svad.Num;
                     vam.OperaterId = OperaterId;//记录操作人
                     vam.UpdateTime = DateTime.Now;
                     vam.Save();
                 }
             }
         }
         //循环旧表找到删除的商品 记录明细
         foreach (DataRow row in dtOld.Rows)
         {
             int  goodsId  = DBTool.GetIntFromRow(row, "goodsId", 0);
             int  oldnum   = DBTool.GetIntFromRow(row, "num", 0);
             bool isExsist = false;
             for (int i = 0; i < details.Count; i++)
             {
                 if (details[i].GoodsId == goodsId)
                 {
                     isExsist = true;
                     break;
                 }
             }
             if (isExsist == false)
             {
                 VIPApplyDetail dvad = new VIPApplyDetail();
                 //新申请单中无 此项
                 dvad.Id = DBTool.GetIntFromRow(row, "Id", 0);
                 if (dvad.Delete())//删除申请单明细中的某一商品记录
                 {
                     //记录申请单删除某一商品
                     VIPApplyModify vam = new VIPApplyModify();
                     vam.ApplyId    = apply.Id;
                     vam.GoodsId    = goodsId;
                     vam.OldNum     = oldnum;
                     vam.NewNum     = 0;
                     vam.OperaterId = OperaterId;//记录操作人
                     vam.UpdateTime = DateTime.Now;
                     vam.Save();
                 }
             }
         }
     }
     return(apply.Id);
 }