Beispiel #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <LPWeb.Model.LoanTask_CompletionEmails> DataTableToList(DataTable dt)
        {
            List <LPWeb.Model.LoanTask_CompletionEmails> modelList = new List <LPWeb.Model.LoanTask_CompletionEmails>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                LPWeb.Model.LoanTask_CompletionEmails model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new LPWeb.Model.LoanTask_CompletionEmails();
                    if (dt.Rows[n]["TaskCompletionEmailId"] != null && dt.Rows[n]["TaskCompletionEmailId"].ToString() != "")
                    {
                        model.TaskCompletionEmailId = int.Parse(dt.Rows[n]["TaskCompletionEmailId"].ToString());
                    }
                    if (dt.Rows[n]["LoanTaskid"] != null && dt.Rows[n]["LoanTaskid"].ToString() != "")
                    {
                        model.LoanTaskid = int.Parse(dt.Rows[n]["LoanTaskid"].ToString());
                    }
                    if (dt.Rows[n]["TemplEmailId"] != null && dt.Rows[n]["TemplEmailId"].ToString() != "")
                    {
                        model.TemplEmailId = int.Parse(dt.Rows[n]["TemplEmailId"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Beispiel #2
0
    /// <summary>
    /// 保存任务完成邮件模板关系
    /// </summary>
    /// <param name="iLoanTaskId"></param>
    public void SaveCompletetionEmails(int iLoanTaskId)
    {
        var tmp = hdnCompletionEmail.Value;

        if (string.IsNullOrEmpty(tmp))
        {
            return;
        }
        var tmpList = tmp.Split('|').ToList();

        LPWeb.BLL.LoanTask_CompletionEmails blltaskMail = new LoanTask_CompletionEmails();
        var tmpidList = new List <int> {
        };

        foreach (var item in tmpList)
        {
            var list = item.Split(',').ToList();
            if (list.Count == 3 && !string.IsNullOrEmpty(list[1]) && !string.IsNullOrEmpty(list[2]) &&
                Convert.ToInt32(list[1]) != 0)
            {
                int templEmailId = Convert.ToInt32(list[1]);
                if (tmpidList.Contains(templEmailId))
                {
                    continue;
                }
                LPWeb.Model.LoanTask_CompletionEmails modMail = new LPWeb.Model.LoanTask_CompletionEmails();


                modMail.LoanTaskid   = iLoanTaskId;
                modMail.TemplEmailId = Convert.ToInt32(list[1]);
                modMail.Enabled      = list[2] == "1" ? true : false;

                blltaskMail.Add(modMail);
                tmpidList.Add(templEmailId);
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// 保存任务完成邮件模板关系
    /// </summary>
    /// <param name="iLoanTaskId"></param>
    public void SaveCompletetionEmails(int iLoanTaskId)
    {
        var tmp = hdnCompletionEmail.Value;


        LPWeb.BLL.LoanTask_CompletionEmails blltaskMail = new LoanTask_CompletionEmails();

        var        ds          = blltaskMail.GetList("LoanTaskid=" + iTaskID); //数据库中原有数据
        List <int> IdList      = ds.Tables[0].AsEnumerable().Select(c => c.Field <int>("TaskCompletionEmailId")).ToList();
        List <int> tmpIdList   = ds.Tables[0].AsEnumerable().Select(c => c.Field <int>("TemplEmailId")).ToList();
        var        oldDataList = ds.Tables[0].AsEnumerable().Select(c => new { Id = c.Field <int>("TaskCompletionEmailId"), tmpId = c.Field <int>("TemplEmailId") }).ToList();

        if (string.IsNullOrEmpty(tmp) && IdList.Count == 0)
        {
            return;
        }


        if (!string.IsNullOrEmpty(tmp))
        {
            var tmpList = tmp.Split('|').ToList();
            foreach (var item in tmpList)
            {
                var list = item.Split(',').ToList();

                if (list.Count == 3 && !string.IsNullOrEmpty(list[1]) && !string.IsNullOrEmpty(list[2]) &&
                    Convert.ToInt32(list[1]) != 0)
                {
                    int  Id           = Convert.ToInt32(list[0]);
                    int  templEmailId = Convert.ToInt32(list[1]);
                    bool enabled      = list[2] == "1" ? true : false;

                    var oldData = oldDataList.Where(c => c.tmpId == templEmailId).FirstOrDefault();
                    if (tmpIdList.Contains(templEmailId) && oldData != null & oldData.Id != Id)
                    {
                        continue;
                    }
                    else if (Id == 0)
                    {
                        LPWeb.Model.LoanTask_CompletionEmails modMail = new LPWeb.Model.LoanTask_CompletionEmails();

                        modMail.LoanTaskid   = iLoanTaskId;
                        modMail.TemplEmailId = templEmailId;
                        modMail.Enabled      = enabled;

                        blltaskMail.Add(modMail);
                        tmpIdList.Add(templEmailId);
                    }
                    else if (IdList.Where(c => c == Id).Count() > 0)
                    {
                        LPWeb.Model.LoanTask_CompletionEmails modMail = new LPWeb.Model.LoanTask_CompletionEmails();

                        modMail.TaskCompletionEmailId = Id;
                        modMail.LoanTaskid            = iLoanTaskId;
                        modMail.TemplEmailId          = templEmailId;
                        modMail.Enabled = enabled;

                        blltaskMail.Update(modMail);

                        IdList.Remove(Id);
                    }
                }
            }
        }

        //删除
        if (IdList.Count > 0)
        {
            var allDelId = string.Empty;
            foreach (var Id in IdList)
            {
                allDelId += "," + Id;
            }
            if (!string.IsNullOrEmpty(allDelId))
            {
                allDelId = allDelId.Remove(0, 1);
            }
            blltaskMail.DeleteList(allDelId);
        }
    }
Beispiel #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(LPWeb.Model.LoanTask_CompletionEmails model)
 {
     return(dal.Update(model));
 }
Beispiel #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(LPWeb.Model.LoanTask_CompletionEmails model)
 {
     return(dal.Add(model));
 }