工资条群发神器,HR必备!!!

工资条群发神器,HR必备!!!

最近在开发一个工资条助手,话不多说,先上图!

部分核心代码

 for (int i = startRow; i < sendNum + startRow; i++)
                {
                    string dstEmailAddress = dataTable.Rows[i][dataTable.Columns.Count - 2].ToString().Trim();
                    if (!CheckEmail(dstEmailAddress))
                    {
                        dataTable.Rows[i][dataTable.Rows[i].ItemArray.Length - 1] = "无效邮箱";
                    }
                    else
                    {
                        email.mailToArray = new string[] { dstEmailAddress };//接收者邮件集合
                        email.mailBody = CreateHtml(i);
                        if (email.Send())
                        {
                            dataTable.Rows[i][dataTable.Rows[i].ItemArray.Length - 1] = "OK";
                        }
                        else
                        {
                            dataTable.Rows[i][dataTable.Rows[i].ItemArray.Length - 1] = "发送失败";
                        }
                        //延时1秒,避免被封
                        Thread.Sleep(500);
                    }
                    //进度条更新
                    ProgressBarValue = (int)((i - startRow + 1) / (float)sendNum * 100);
                    SendEmailState = string.Format("已发送:{0}%", ProgressBarValue);
                }
                SendEmailState = "完成";
            }));
   #region 双表头
                        //倒数第一项:发送结果
                        //倒数第二项:邮箱
                        //倒数第三项:实发工资
                        //数据行索引:3【第4行开始】
                        //根据分组遍历
                        foreach (var item in GloableVar.HeaderGroups)
                        {
                            //如果是行合并
                            if (item.RowMerge == true)
                            {
                                //表头:值
                                str += string.Format("
{0}:{1}
"
, item.Title, dataTable.Rows[RowNum][item.dimension.FirstColumnIndex]); } //如果是列合并 else { //表头 str += string.Format("
{0}
"
, item.Title); //循环添加子项 for (int i = 0; i < item.ChildTitles.Count; i++) { str += string.Format("
--{0}:{1}
"
, item.ChildTitles[i], dataTable.Rows[RowNum][item.dimension.FirstColumnIndex + i]); } } } //添加实发工资总数 str += string.Format("
实发工资:{0}
", dataTable.Rows[RowNum][dataTable.Columns.Count - 3].ToString()); #endregion break;

后面再补充!

你可能感兴趣的:(办公,C#)