Beispiel #1
0
        /// <summary>
        /// 找到最近的管理员
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        public DataSet GetAdmin(VIPApplyOption option)
        {
            string sql = "select top 1 mr.MemberId,mr.RoleId,m.ComId,d.Code,d.Level from Member m inner join Dept d on m.DeptId=d.Id inner join MemberRole mr on m.Id=mr.MemberId where 1=1";

            if (option.ComId > 0)
            {
                sql += string.Format(" and m.ComId={0}", option.ComId);
            }
            if (option.Code != "")
            {
                DeptCode      dc   = new DeptCode();
                List <string> code = dc.GetAllCode(option.Code);
                sql += " and ( ";
                for (int i = 0; i < code.Count; i++)
                {
                    sql += "  d.Code = '" + code[i] + "' ";
                    if (i < code.Count - 1)
                    {
                        sql += " or ";
                    }
                }
                sql += " ) ";
            }
            if (option.RoleId > 0)
            {
                sql += string.Format(" and RoleId={0}", option.RoleId);
            }
            if (option.MemberId > 0)//传memberId是为了找到当前提交申请单的是成本中心管理员 把他排除 找到上一级管理员
            {
                sql += string.Format(" and m.Id <> {0}", option.MemberId);
            }
            sql += "  and IsVisible=1 order by Code desc";
            return(m_dbo.GetDataSet(sql));
        }
Beispiel #2
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);
        }
Beispiel #3
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);
 }
Beispiel #4
0
        /// <summary>
        /// 读取待审核的申请单 add by luochunhui
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        public DataSet ReadApply(VIPApplyOption option)
        {
            string sql = "select * from View_VIPApply where 1=1";

            if (option.Id > 0)
            {
                sql += string.Format(" and Id={0} ", option.Id);
            }
            if (option.ComId > 0)
            {
                sql += string.Format(" and ComId={0}", option.ComId);
            }
            if (option.Status != "")
            {
                string[] status = option.Status.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                if (status.Length == 1)
                {
                    sql += string.Format(" and Status='{0}' ", status[0]);
                }
                else
                {
                    sql += " and Status in ( ";
                    for (int i = 0; i < status.Length; i++)
                    {
                        if (i == 0)
                        {
                            sql += string.Format(" '{0}' ", status[0]);
                        }
                        else
                        {
                            sql += string.Format(" ,'{0}' ", status[i]);
                        }
                    }
                    sql += " ) ";
                }
            }
            if (option.ConfirmLevel >= 0)
            {
                if (option.IsPass == 1)
                {
                    sql += string.Format(" and ApplyConfirmLevel>={0}", option.ConfirmLevel);
                }
                else
                {
                    sql += string.Format(" and ApplyConfirmLevel={0}", option.ConfirmLevel);
                }
            }
            if (option.Code != "")
            {
                sql += string.Format(" and Code like '{0}%'", option.Code);
            }
            if (option.IsBudget > 0 && option.MemberId > 0)
            {
                sql += string.Format(" and ( MemberId={0} ) ", option.MemberId);
            }
            else if (option.MemberId > 0)
            {
                sql += string.Format(" and ( MemberId={0} or OperatorId={0} ) ", option.MemberId);
            }
            if (option.DeptId > 0)
            {
                sql += string.Format("and DeptId={0} ", option.DeptId, option.Code);
            }
            if (option.StartDate != new DateTime(1900, 1, 1))
            {
                sql += string.Format(" and UpdateTime >='{0}' ", option.StartDate.ToShortDateString());
            }
            if (option.EndDate != new DateTime(1900, 1, 1))
            {
                sql += string.Format(" and UpdateTime <'{0}' ", option.EndDate.AddDays(1).ToShortDateString());
            }
            sql += "  order by UpdateTime desc ; select @@ROWCOUNT as rownum ";
            return(m_dbo.GetDataSet(sql));
        }