From 9de8676f6c9098a9789afa1ae36e0eb162591904 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Mon, 7 Dec 2020 11:30:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=8F=91=E8=B4=A7=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8F=91=E9=82=AE=E4=BB=B6=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E5=BE=85=E5=BC=80=E7=A5=A8=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SCP/Admin/default.aspx.cs | 2 +- SCP/Common/MailHelper.cs | 35 ++++++++++++++++ SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs | 42 ++++++++++++++++++- SCP/Views/SupplierData/SCP_RECEIVE_LIST.aspx | 4 +- .../SupplierData/SCP_RECEIVE_LIST.aspx.cs | 8 +++- .../SCP_RECEIVE_LIST.aspx.designer.cs | 18 ++++---- UniApiGroup/Controller/MailController.cs | 6 +-- 7 files changed, 96 insertions(+), 19 deletions(-) diff --git a/SCP/Admin/default.aspx.cs b/SCP/Admin/default.aspx.cs index 9abdb72..4a2b7f7 100644 --- a/SCP/Admin/default.aspx.cs +++ b/SCP/Admin/default.aspx.cs @@ -30,7 +30,7 @@ namespace SCP.admin public void BindData() { SearchData(ret => { - if (CurrentUser.RoleList !=null && CurrentUser.RoleList.Contains("供应商")) + if (CurrentUser.RoleList !=null && CurrentUser.RoleList.Contains("供应商")&& !CurrentUser.RoleList.Contains("管理员")) { ret = SetV_INFO(ret); } diff --git a/SCP/Common/MailHelper.cs b/SCP/Common/MailHelper.cs index 6009803..6872f9d 100644 --- a/SCP/Common/MailHelper.cs +++ b/SCP/Common/MailHelper.cs @@ -101,6 +101,41 @@ namespace SCP.Common } } } + + public static void SendMails(string p_VendId, string p_Content, string p_title) + { + using (AppBoxContext db = EntitiesFactory.CreateAppBoxInstance()) + { + StringBuilder _buffer = new StringBuilder(); + _buffer.Append("SELECT b.Email "); + _buffer.Append(" FROM VenderUsers AS a INNER JOIN "); + _buffer.Append(" Users AS b ON a.UserId = b.ID INNER JOIN "); + _buffer.Append(" RoleUsers AS g ON a.UserId = g.UserID INNER JOIN "); + _buffer.Append(" Roles AS h ON g.RoleID = h.ID "); + _buffer.AppendFormat(" WHERE(h.Name = '供应商' and a.VenderId in ({0}) and b.enabled=1 ) ", p_VendId); + var _userList = db.Database.SqlQuery(_buffer.ToString()).ToList(); + //var _vender = ScpCache.VenderList.Where(itm => itm.VendId == p_VendId).FirstOrDefault(); + if (_userList != null && _userList.Count > 0) + { + foreach (var itm in _userList) + { + string mails = ""; + mails += itm + ","; + if (mails != "") + { + mails = mails.Substring(0, mails.Length - 1); + } + string mailbody = ""; + mailbody += "尊敬的供应商
"; + mailbody += "你好!

"; + mailbody += "" + p_Content + " ,请到供应商SCP网站" + ConfigurationManager.AppSettings["ResetPassWord"] + "打开查看下载!
"; + mailbody += "



日期:" + DateTime.Now; + MyWebSmtpMail webmail = new MyWebSmtpMail(); + webmail.Send(mails, mailbody, p_title); + } + } + } + } /// /// 发邮件给采购 /// diff --git a/SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs b/SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs index c0e6b35..b97369e 100644 --- a/SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs +++ b/SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs @@ -100,7 +100,7 @@ namespace SCP.BasicData protected void Button3_OnClick(object sender, EventArgs e) { Int32 id = GetQueryIntValue("id"); - + string mailVendIds = ""; if (id != -1) { User modelUsers = DB.Users.FirstOrDefault(p => p.Name == txtSupplierCode.SelectedValue); @@ -179,6 +179,7 @@ namespace SCP.BasicData { model.SupplierCode = GetSupplierCodes("All"); model.SupplierName = GetSupplierNames("All"); + mailVendIds = GetSupplierCodes_Mail("All"); } else { @@ -189,8 +190,9 @@ namespace SCP.BasicData return; } - model.SupplierCode = GetSupplierCodes("Some"); + model.SupplierCode = GetSupplierCodes("Some"); model.SupplierName = GetSupplierNames("Some"); + mailVendIds = GetSupplierCodes_Mail("Some"); } // model.FactoryCode=txt 用户登陆名字 model.Content = txtContent.Text; @@ -209,6 +211,7 @@ namespace SCP.BasicData var ret = SCP_INFO_CONTROLLER.SaveInfo(model); if (ret.State == ReturnStatus.Succeed) { + SCP.Common.MailManager.SendMails(mailVendIds, "信息发布:" + model.Content, CurrentUser.FactoryList.FirstOrDefault()); Alert.ShowInParent("保存成功!"); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); @@ -259,6 +262,41 @@ namespace SCP.BasicData } } + private string GetSupplierCodes_Mail(string type) + { + string strResult = ""; + + if ("All".Equals(type)) + { + foreach (FineUI.ListItem vender in txtSupplierCode.Items) + { + if (string.IsNullOrEmpty(strResult)) + { + strResult ="'"+ vender.Value+"'"; + } + else + { + strResult = strResult + "," + "'" + vender.Value + "'"; + } + } + } + else if ("Some".Equals(type)) + { + foreach (FineUI.ListItem item in txtSupplierCode.SelectedItemArray) + { + if (string.IsNullOrEmpty(strResult)) + { + strResult = "'" + item.Value + "'"; + } + else + { + strResult = strResult + "," + "'" + item.Value + "'"; + } + } + } + + return strResult; + } private string GetSupplierCodes(string type) { diff --git a/SCP/Views/SupplierData/SCP_RECEIVE_LIST.aspx b/SCP/Views/SupplierData/SCP_RECEIVE_LIST.aspx index 96913e9..5fde5d1 100644 --- a/SCP/Views/SupplierData/SCP_RECEIVE_LIST.aspx +++ b/SCP/Views/SupplierData/SCP_RECEIVE_LIST.aspx @@ -43,7 +43,6 @@