From 20f906ca4bd44cdac6b0eeb4ba08195565dd82c1 Mon Sep 17 00:00:00 2001 From: qian Date: Thu, 11 Jan 2024 10:30:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=82=AE=E4=BB=B6=E5=8F=8A=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=8A=A5=E9=94=99=E5=90=8E=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 北京北汽/Common/CK.SCP.Common.csproj | 14 ++ 北京北汽/Common/MailManager.cs | 42 ++++ 北京北汽/Common/MyWebSmtpMail.cs | 210 +++++++++++++++++- 北京北汽/Common/packages.config | 4 + .../Controller/SCP_DC_UNI_CONTROLLER.cs | 16 +- 北京北汽/Controller/SCP_PO_CONTROLLER.cs | 78 +++---- .../Controller/SCP_TB_PRICE_CONTROLLER.cs | 21 +- 北京北汽/SCP/SCP.csproj | 13 ++ .../SCP/Views/BasicData/Price.aspx.cs | 11 +- .../SCP/Views/BasicData/PriceUpdate.aspx.cs | 4 +- .../Views/BasicData/SCP_PRICE_EDIT.aspx.cs | 2 +- .../SCP/Views/PlanData/SCP_PO.aspx.cs | 7 +- .../SCP/Views/PlanData/SCP_PO_CQ.aspx.cs | 2 +- 北京北汽/SCP/Web.config | 130 +++++------ 北京北汽/SCP/default_hb.aspx.cs | 29 ++- 北京北汽/SCP/packages.config | 4 + 16 files changed, 449 insertions(+), 138 deletions(-) create mode 100644 北京北汽/Common/MailManager.cs diff --git a/北京北汽/Common/CK.SCP.Common.csproj b/北京北汽/Common/CK.SCP.Common.csproj index e8af561..689f119 100644 --- a/北京北汽/Common/CK.SCP.Common.csproj +++ b/北京北汽/Common/CK.SCP.Common.csproj @@ -30,6 +30,9 @@ 4 + + ..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll + ..\DLL\DevComponents.DotNetBar.Layout.dll @@ -39,6 +42,12 @@ ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + + ..\packages\MailKit.3.1.1\lib\net452\MailKit.dll + + + ..\packages\MimeKit.3.1.1\lib\net452\MimeKit.dll + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll @@ -55,10 +64,14 @@ ..\packages\NPOI.2.3.0\lib\net40\NPOI.OpenXmlFormats.dll + + ..\packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll + + @@ -80,6 +93,7 @@ CktTextBox.cs + diff --git a/北京北汽/Common/MailManager.cs b/北京北汽/Common/MailManager.cs new file mode 100644 index 0000000..c91d08d --- /dev/null +++ b/北京北汽/Common/MailManager.cs @@ -0,0 +1,42 @@ +using System.Configuration; +using System; +using System.IO; +using CK.SCP.Utils; +using System.Text; +using NPOI.HSSF.UserModel; +using System.Collections.Generic; +using MailKit.Security; + +namespace CK.SCP.Common +{ + public class MailManager + { + /// + /// 发送邮件 + /// + /// + /// + /// + public static void SendMail(string mails = "", string mailbody = "", string p_MailTitle ="" ) + { + try + { + List toList = new List(); + EmailAddress add = new EmailAddress(mails, mails); + toList.Add(add); + var smtpMailSender = new MailKitMailSender(SecureSocketOptions.StartTls); + smtpMailSender.BuildMessage( + toList, + p_MailTitle, + mailbody, + "BBC" + ); + smtpMailSender.Send(); + } + catch (Exception e) + { + LogHelper.Writlog(LogHelper.LogType.Error, typeof(MailManager), "MailManager", e.Message + e.InnerException?.Message); + } + } + } +} diff --git a/北京北汽/Common/MyWebSmtpMail.cs b/北京北汽/Common/MyWebSmtpMail.cs index 232f024..08ad6e3 100644 --- a/北京北汽/Common/MyWebSmtpMail.cs +++ b/北京北汽/Common/MyWebSmtpMail.cs @@ -5,6 +5,9 @@ using System.Linq; using System.Net.Mail; using System.Text; using System.Threading.Tasks; +using MailKit.Security; +using MimeKit; +using MimeKit.Text; namespace CK.SCP.Common { @@ -38,12 +41,13 @@ namespace CK.SCP.Common this.credentials = false; } + public void Send(string To, string Body, string Title) { mailMessage = new MailMessage(); mailMessage.To.Add(To); mailMessage.From = new System.Net.Mail.MailAddress(this.from); - mailMessage.Subject = Title; + mailMessage.Subject = "新的邮件通知"; mailMessage.Body = Body; mailMessage.IsBodyHtml = true; mailMessage.BodyEncoding = System.Text.Encoding.UTF8; @@ -52,6 +56,7 @@ namespace CK.SCP.Common if (mailMessage != null) { smtpClient = new SmtpClient(); + if (!credentials) { smtpClient.Credentials = new System.Net.NetworkCredential(username, password); @@ -60,16 +65,11 @@ namespace CK.SCP.Common smtpClient.Host = server; smtpClient.Port = port; smtpClient.EnableSsl = enablessl; - //smtpClient.Send(mailMessage); - //smtpClient.SendAsync(mailMessage, null); - //如果服务器支持安全连接,则将安全连接设为true - //smtpClient.EnableSsl = true; try { //是否使用默认凭据,若为false,则使用自定义的证书,就是下面的networkCredential实例对象 - smtpClient.UseDefaultCredentials = false; - + smtpClient.UseDefaultCredentials = true; //指定邮箱账号和密码,需要注意的是,这个密码是你在QQ邮箱设置里开启服务的时候给你的那个授权码 System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(username, password); smtpClient.Credentials = networkCredential; @@ -79,10 +79,202 @@ namespace CK.SCP.Common } catch (System.Net.Mail.SmtpException ex) - { - //Console.WriteLine(ex.Message, "发送邮件出错"); + { + throw new Exception(ex.Message + ex.InnerException?.Message); + // Console.WriteLine(ex.Message, "发送邮件出错"); } } } + + + } + + public class SmtpMailSender + { + private readonly SmtpClient _client = new SmtpClient(); + private MailMessage _message = new MailMessage(); + private readonly string _targetName; + public SmtpMailSender(string targetName) + { + _targetName = targetName; + } + + public void BuildClient(string host, int port, bool enableSsl, string username, string password) + { + _client.Host = host; + //587 or 25 + _client.Port = port; + // This require to be before setting Credentials property + _client.UseDefaultCredentials = false; + _client.DeliveryMethod = SmtpDeliveryMethod.Network; + // you must give a full email address for authentication + _client.Credentials = new System.Net.NetworkCredential(username, password); + // Set to avoid MustIssueStartTlsFirst exception + _client.TargetName = _targetName; + // Set to avoid secure connection exception + _client.EnableSsl = enableSsl; + + } + + public void BuildMessage(EmailAddress fromAddress, List toAddressList, string subject, string body) + { + _message = new MailMessage() + { + // sender must be a full email address + From = new MailAddress(fromAddress.Address, fromAddress.Name), + Subject = subject, + IsBodyHtml = true, + Body = body, + BodyEncoding = Encoding.UTF8, + SubjectEncoding = Encoding.UTF8, + }; + foreach (var emailAddress in toAddressList) + { + _message.To.Add(new MailAddress(emailAddress.Address, emailAddress.Name)); + } + + } + + public void Send() + { + try + { + _client.Send(_message); + Console.WriteLine("Smtp Send Success:" + _message.To[0].Address); + + + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + Console.WriteLine(); + } + + } + + public async Task SendAsync() + { + try + { + await _client.SendMailAsync(_message); + Console.WriteLine("Smtp Send Success:" + _message.To[0].Address); + + + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + Console.WriteLine(); + } + + } + + + } + + public class MailKitMailSender + { + private readonly MailKit.Net.Smtp.SmtpClient _client = new MailKit.Net.Smtp.SmtpClient(); + private MimeMessage _message = new MimeMessage(); + + private string host;//邮箱服务器 + private int port;//端口 + private string from;//发送的邮箱 + private string password;//密码 + private bool enablessl;//是否ssl + private string username;//发送名称 + + private readonly SecureSocketOptions _secureSocketOptions; + + private MailKitMailSender() + { + _client.ServerCertificateValidationCallback = (s, c, h, e) => true; + } + + public MailKitMailSender(SecureSocketOptions secureSocketOptions) : this() + { + _secureSocketOptions = secureSocketOptions; + host = ConfigurationManager.AppSettings["MailServer"]; + port = Convert.ToInt32(ConfigurationManager.AppSettings["MailPort"]); + from = ConfigurationManager.AppSettings["MailSender"]; + username = ConfigurationManager.AppSettings["MailUserName"]; + password = ConfigurationManager.AppSettings["MailPassword"]; + enablessl = false; + } + + public void BuildMessage(List toAddressList, string subject, string body, string model) + { + _message = new MimeMessage(); + + _message.Sender = new MailboxAddress(username, from); + _message.From.Add(new MailboxAddress(username, from)); + _message.Subject = subject; + _message.Body = new TextPart(TextFormat.Html) { Text = body }; + + foreach (var emailAddress in toAddressList) + { + if (model == "BCC")//抄送模式(抄送模式只发送一个邮件,避免大量发重复邮件) + { + _message.Bcc.Add(new MailboxAddress(emailAddress.Name, emailAddress.Address)); + } + else + { + _message.To.Add(new MailboxAddress(emailAddress.Name, emailAddress.Address)); + } + + } + } + public void Send() + { + try + { + _client.Connect(host, port, _secureSocketOptions); + _client.Authenticate(from, password); + _client.Send(_message); + _client.Disconnect(true); + Console.WriteLine("MailKit Send Success:" + _message.To.Mailboxes.First()); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + Console.WriteLine(); + + } + } + + + + public async Task SendAsync() + { + try + { + await _client.ConnectAsync(host, port, _secureSocketOptions); + await _client.AuthenticateAsync(from, password); + await _client.SendAsync(_message); + await _client.DisconnectAsync(true); + Console.WriteLine("MailKit Send Success:" + _message.To.Mailboxes.First()); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + Console.WriteLine(); + + } + + } + + } + + + public class EmailAddress + { + public EmailAddress(string address, string name) + { + Address = address; + Name = name; + } + public string Name { get; set; } + public string Address { get; set; } } } + diff --git a/北京北汽/Common/packages.config b/北京北汽/Common/packages.config index 8e2e973..cea886c 100644 --- a/北京北汽/Common/packages.config +++ b/北京北汽/Common/packages.config @@ -1,6 +1,10 @@  + + + + \ No newline at end of file diff --git a/北京北汽/Controller/SCP_DC_UNI_CONTROLLER.cs b/北京北汽/Controller/SCP_DC_UNI_CONTROLLER.cs index 4ef0196..f59e66e 100644 --- a/北京北汽/Controller/SCP_DC_UNI_CONTROLLER.cs +++ b/北京北汽/Controller/SCP_DC_UNI_CONTROLLER.cs @@ -2614,7 +2614,7 @@ namespace CK.SCP.Controller _PO_Detail.Currency = "CNY"; _PO_Detail.PoBillNum = _po.PoBillNum; _PO_Detail.PartCode = itm.零件号.Trim(); - var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm.零件号 && t.Site == _po.Site); + var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm.零件号.Trim() && t.Site == _po.Site); _PO_Detail.PoLine =int.Parse(itm.行号); _PO_Detail.PoUnit = part.Unit; _PO_Detail.CreateTime = DateTime.Now; @@ -2636,7 +2636,7 @@ namespace CK.SCP.Controller _PO_Detail.Scheduledays = string.IsNullOrEmpty(itm.日程天数) ? 7 : int.Parse(itm.日程天数); _PO_Detail.Scheduleweeks = string.IsNullOrEmpty(itm.日程周数) ? 2 : int.Parse(itm.日程周数); _PO_Detail.Schedulemonth = string.IsNullOrEmpty(itm.日程月数) ? 1 : int.Parse(itm.日程月数); - _PO_Detail.Supplieritem = itm.供应商零件; + _PO_Detail.Supplieritem = itm.供应商零件.Trim(); _PO_Detail.Dliverypatterncode = itm.发货样式; _PO_Detail.Deliverytimecode = itm.发货时间样式; _PO_Detail.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); @@ -2734,7 +2734,7 @@ namespace CK.SCP.Controller TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL(); _PO_Detail.GUID = Guid.NewGuid(); _PO_Detail.PartCode = itm.零件号.Trim().ToUpper(); - var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm.零件号 && t.Site == _po.Site); + var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm.零件号.Trim() && t.Site == _po.Site); _PO_Detail.PoLine = _number; _PO_Detail.PoBillNum = _po.PoBillNum; _PO_Detail.State = (int)PoState.Open; @@ -2760,7 +2760,7 @@ namespace CK.SCP.Controller _PO_Detail.Scheduledays = string.IsNullOrEmpty(itm.日程天数) ? 7 : int.Parse(itm.日程天数); _PO_Detail.Scheduleweeks = string.IsNullOrEmpty(itm.日程周数) ? 2 : int.Parse(itm.日程周数); _PO_Detail.Schedulemonth = string.IsNullOrEmpty(itm.日程月数) ? 1 : int.Parse(itm.日程月数); - _PO_Detail.Supplieritem = itm.供应商零件; + _PO_Detail.Supplieritem = itm.供应商零件.Trim(); _PO_Detail.Dliverypatterncode = itm.发货样式; _PO_Detail.Deliverytimecode = itm.发货时间样式; _PO_Detail.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); @@ -2924,8 +2924,8 @@ namespace CK.SCP.Controller TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL(); _PO_Detail.Currency = "CNY"; _PO_Detail.PoBillNum = _po.PoBillNum; - _PO_Detail.PartCode = itm.零件号; - var part = scpdb.TA_PART.FirstOrDefault(t=>t.PartCode== itm.零件号&&t.Site==_po.Site); + _PO_Detail.PartCode = itm.零件号.Trim(); + var part = scpdb.TA_PART.FirstOrDefault(t=>t.PartCode== itm.零件号.Trim()&&t.Site==_po.Site); _PO_Detail.PoLine = int.Parse(itm.行号); _PO_Detail.PoUnit = part.Unit; _PO_Detail.CreateTime = DateTime.Now; @@ -3021,7 +3021,7 @@ namespace CK.SCP.Controller TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL(); _PO_Detail.GUID = Guid.NewGuid(); _PO_Detail.PartCode = itm.零件号.Trim().ToUpper(); - var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm.零件号 && t.Site == _po.Site); + var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm.零件号.Trim() && t.Site == _po.Site); _PO_Detail.PoLine = _number; _PO_Detail.PoBillNum = _po.PoBillNum.Trim(); _PO_Detail.State = (int)PoState.Open; @@ -3179,7 +3179,7 @@ namespace CK.SCP.Controller TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL(); _PO_Detail.Currency = "CNY"; _PO_Detail.PoBillNum = _po.PoBillNum; - _PO_Detail.PartCode = itm.零件号; + _PO_Detail.PartCode = itm.零件号.Trim(); _PO_Detail.PoLine = int.Parse(itm.行号); _PO_Detail.PoUnit = itm.单位; _PO_Detail.CreateTime = DateTime.Now; diff --git a/北京北汽/Controller/SCP_PO_CONTROLLER.cs b/北京北汽/Controller/SCP_PO_CONTROLLER.cs index 2a38c27..a35bc2b 100644 --- a/北京北汽/Controller/SCP_PO_CONTROLLER.cs +++ b/北京北汽/Controller/SCP_PO_CONTROLLER.cs @@ -1178,7 +1178,7 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("供应商编号为【{0}】的零件编号【{1}】币种填写错误,只能是CNY或者EUR或者USD!", p_excel.供应商编号, p_excel.零件编码)); } var Site = db.TB_FACTORY.Where(p=>p.ErpSite== p_excel.域).FirstOrDefault(); - var _first = db.TA_PART.Where(p => p.PartCode == p_excel.零件编码 &&p.Site== p_excel.域).FirstOrDefault(); + var _first = db.TA_PART.Where(p => p.PartCode == p_excel.零件编码.Trim() &&p.Site== p_excel.域).FirstOrDefault(); if (_first == null) { ErrorList.Add(string.Format("供应商编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.供应商编号, p_excel.零件编码)); @@ -1208,7 +1208,7 @@ namespace CK.SCP.Controller var _Site = new SqlParameter("@Site", p_excel.域); var _SubSite = new SqlParameter("@SubSite", p_excel.地点); var _VendId = new SqlParameter("@VendId", p_excel.供应商编号); - var _PartCode = new SqlParameter("@PartCode", p_excel.零件编码); + var _PartCode = new SqlParameter("@PartCode", p_excel.零件编码.Trim()); if (st > et) { ErrorList.Add(string.Format("供应商{0}零件编号{1}的结束时间需要大于开始时间!", p_excel.供应商编号, p_excel.零件编码)); @@ -1307,7 +1307,7 @@ namespace CK.SCP.Controller // ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.订单编号,p_excel.零件号 )); //} - var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.零件号&&p.Site== site); + var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.零件号.Trim()&&p.Site== site); if (_checkpart != null) { if (_checkpart.State.ToUpper() != "SP") @@ -1319,7 +1319,7 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表零件停用,无法导入!", p_excel.订单编号, p_excel.零件号)); } } - var _checkpart1= db.TA_PART.Count(p => p.PartCode == p_excel.零件号 && p.Site == site); + var _checkpart1= db.TA_PART.Count(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site); if (_checkpart1 == 0) { ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.订单编号, p_excel.零件号)); @@ -1369,17 +1369,17 @@ namespace CK.SCP.Controller } int _polinr = Int32.Parse(p_excel.行号); - var _partlist = db.TB_PO_DETAIL.Where(p => p.PoBillNum == p_excel.订单编号 && p.PartCode == p_excel.零件号 && p.PoLine != _polinr).ToList(); + var _partlist = db.TB_PO_DETAIL.Where(p => p.PoBillNum == p_excel.订单编号 && p.PartCode == p_excel.零件号.Trim() && p.PoLine != _polinr).ToList(); if (_partlist.Count > 0) { ErrorList.Add(string.Format("订单编号【{0}】零件号【{1}】已经存在(系统:行号-【{2}】),请更换零件号!", p_excel.订单编号, p_excel.零件号, _partlist[0].PoLine)); } - int linecount = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel.订单编号 && p.PoLine == _polinr && p.PartCode != p_excel.零件号); + int linecount = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel.订单编号 && p.PoLine == _polinr && p.PartCode != p_excel.零件号.Trim()); if (linecount > 0) { ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】已经存在,请更换行号!", p_excel.订单编号, p_excel.行号)); } - var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号 && p.Site == site && p.SubSite == subsite && p.State != (int)PriceState.Reject && p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); + var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site && p.SubSite == subsite && p.State != (int)PriceState.Reject && p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); if (checkcount.Count == 0) { ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel.零件号, p_excel.供应商编号)); @@ -1535,7 +1535,7 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); } } - var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号 && p.Site == site && p.SubSite == subsite && p.State == (int)PriceState.FConfirm && p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); + var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site && p.SubSite == subsite && p.State == (int)PriceState.FConfirm && p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); if (checkcount.Count == 0) { ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel.零件号, p_excel.供应商编号)); @@ -1622,7 +1622,7 @@ namespace CK.SCP.Controller // ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.订单编号,p_excel.零件号 )); //} - var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.零件号&&p.Site== site); + var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.零件号.Trim()&&p.Site== site); if (_checkpart != null) { if (_checkpart.State.ToUpper() != "SP") @@ -1634,7 +1634,7 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表零件停用,无法导入!", p_excel.订单编号, p_excel.零件号)); } } - var _checkpart1 = db.TA_PART.Count(p => p.PartCode == p_excel.零件号 && p.Site == site); + var _checkpart1 = db.TA_PART.Count(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site); if (_checkpart1 == 0) { @@ -1678,7 +1678,7 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); } } - var pode = db.TB_PO_DETAIL.Count(p=>p.PoBillNum== p_excel.订单编号&&p.PartCode==p_excel.零件号); + var pode = db.TB_PO_DETAIL.Count(p=>p.PoBillNum== p_excel.订单编号&&p.PartCode==p_excel.零件号.Trim()); if (pode > 0) { ErrorList.Add(string.Format("订单号【{1}】零件号【{0}】已存在!", p_excel.零件号, p_excel.订单编号)); @@ -1690,20 +1690,20 @@ namespace CK.SCP.Controller //} int _polinr = Int32.Parse(p_excel.行号); - var _partlist = db.TB_PO_DETAIL.Where(p => p.PoBillNum == p_excel.订单编号 && p.PartCode == p_excel.零件号 && p.PoLine != _polinr).ToList(); + var _partlist = db.TB_PO_DETAIL.Where(p => p.PoBillNum == p_excel.订单编号 && p.PartCode == p_excel.零件号.Trim() && p.PoLine != _polinr).ToList(); if (_partlist.Count > 0) { ErrorList.Add(string.Format("订单编号【{0}】零件号【{1}】已经存在(系统:行号-【{2}】),请更换零件号!", p_excel.订单编号, p_excel.零件号, _partlist[0].PoLine)); } - int linecount = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel.订单编号 && p.PoLine == _polinr && p.PartCode != p_excel.零件号); + int linecount = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel.订单编号 && p.PoLine == _polinr && p.PartCode != p_excel.零件号.Trim()); if (linecount > 0) { ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】已经存在,请更换行号!", p_excel.订单编号, p_excel.行号)); } - var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号 && p.Site == site && p.SubSite == subsite && p.State != (int)PriceState.Reject && p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); + var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site && p.SubSite == subsite && p.State != (int)PriceState.Reject && p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); if (checkcount.Count == 0) { - ErrorList.Add(string.Format("零件编号【{0}】供应编码【{1}】价格表没有维护信息!", p_excel.零件号, p_excel.供应商编号)); + ErrorList.Add(string.Format("零件编号【{0}】供应编码【{1}】价格表没有维护信息!", p_excel.零件号.Trim(), p_excel.供应商编号)); } else { @@ -1853,7 +1853,7 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); } } - var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号 && p.Site == site && p.SubSite == subsite && p.State == (int)PriceState.FConfirm && p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); + var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site && p.SubSite == subsite && p.State == (int)PriceState.FConfirm && p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); if (checkcount.Count == 0) { ErrorList.Add(string.Format("零件编号【{0}】供应编码【{1}】价格表没有维护信息!", p_excel.零件号, p_excel.供应商编号)); @@ -2399,7 +2399,7 @@ namespace CK.SCP.Controller var _lst = p_order_list; _lst.ForEach(p => { - var _count = _lst.Count(itm => itm.供应商代码 == p.供应商代码 && itm.零件号 == p.零件号 && itm.域 == p.域); + var _count = _lst.Count(itm => itm.供应商代码 == p.供应商代码 && itm.零件号.Trim() == p.零件号 && itm.域 == p.域); if (_count > 1) { lineError.Add(string.Format("导入的域{2}供应商{0}零件编号{1}有重复", p.供应商代码, p.零件号, p.域)); @@ -2677,7 +2677,7 @@ namespace CK.SCP.Controller { List ErrorList = new List(); - int count = db.TA_MoldSharing.Count(p => p.VendId == p_excel.供应商编号.ToUpper() && p.Site == p_excel.域 && p.PartCode == p_excel.零件编码.ToUpper() && p.Count != 0); + int count = db.TA_MoldSharing.Count(p => p.VendId == p_excel.供应商编号.ToUpper() && p.Site == p_excel.域 && p.PartCode == p_excel.零件编码.Trim().ToUpper() && p.Count != 0); if (count > 0) { ErrorList.Add(string.Format("供应商{0}零件编码{1}已存在分摊数据,不可修改分摊价格和数量!", p_excel.供应商编号, p_excel.零件编码)); @@ -2706,10 +2706,10 @@ namespace CK.SCP.Controller _lst.ForEach (p => { - var _count = _lst.Count(itm => itm.域 == p.域 && itm.地点 == p.地点 && itm.供应商编号 == p.供应商编号 && itm.零件编码 == p.零件编码); + var _count = _lst.Count(itm => itm.域 == p.域 && itm.地点 == p.地点 && itm.供应商编号 == p.供应商编号 && itm.零件编码.Trim() == p.零件编码.Trim()); if (_count > 1) { - lineError.Add(string.Format("导入的模板供应商编号{0}零件编号{3}有重复,请修改时间!", p.供应商编号, p.开始时间, p.结束时间, p.零件编码)); + lineError.Add(string.Format("导入的模板供应商编号{0}零件编号{3}有重复,请修改时间!", p.供应商编号, p.开始时间, p.结束时间, p.零件编码.Trim())); ErrorList = lineError; } @@ -2721,7 +2721,7 @@ namespace CK.SCP.Controller } number++; }); - var _sharinglist = _lst.Where(t => !string.IsNullOrEmpty(t.供应商编号) && !string.IsNullOrEmpty(t.零件编码) && t.累计分摊价格 != "0" && t.累计分摊数量 != "0" && !string.IsNullOrEmpty(t.累计分摊价格) && !string.IsNullOrEmpty(t.累计分摊数量)).ToList().DistinctBy(x => new { x.供应商编号, x.零件编码, x.累计分摊价格, x.累计分摊数量, x.域 }).ToList(); + var _sharinglist = _lst.Where(t => !string.IsNullOrEmpty(t.供应商编号) && !string.IsNullOrEmpty(t.零件编码.Trim()) && t.累计分摊价格 != "0" && t.累计分摊数量 != "0" && !string.IsNullOrEmpty(t.累计分摊价格) && !string.IsNullOrEmpty(t.累计分摊数量)).ToList().DistinctBy(x => new { x.供应商编号, x.零件编码, x.累计分摊价格, x.累计分摊数量, x.域 }).ToList(); if (_sharinglist.Count > 0) { _sharinglist.ForEach(p => @@ -2755,7 +2755,7 @@ namespace CK.SCP.Controller var _Site = new SqlParameter("@Site", p.域); var _SubSite = new SqlParameter("@SubSite", p.地点); var _VendId = new SqlParameter("@VendId", p.供应商编号); - var _PartCode = new SqlParameter("@PartCode", p.零件编码); + var _PartCode = new SqlParameter("@PartCode", p.零件编码.Trim()); string sqlString = "select * from tb_price where uid in\n" + "(\n" + " select max(uid) uid\n" + @@ -2794,7 +2794,7 @@ namespace CK.SCP.Controller }); _sharinglist.ForEach(p => { - var _moldsharing = db.TA_MoldSharing.SingleOrDefault(t => t.VendId == p.供应商编号.ToUpper() && t.PartCode == p.零件编码.ToUpper() && t.Site == p.域) ?? + var _moldsharing = db.TA_MoldSharing.SingleOrDefault(t => t.VendId == p.供应商编号.ToUpper() && t.PartCode == p.零件编码.Trim().ToUpper() && t.Site == p.域) ?? new TA_MOLDSHARING { VendId = p.供应商编号.ToUpper().Trim(), @@ -3038,7 +3038,7 @@ namespace CK.SCP.Controller _lst.ForEach (p => { - var _count = _lst.Count(itm => itm.供应商编号 == p.供应商编号 && itm.零件编码 == p.零件编码); + var _count = _lst.Count(itm => itm.供应商编号 == p.供应商编号 && itm.零件编码.Trim() == p.零件编码.Trim()); if (_count > 1) { lineError.Add(string.Format("导入的模板供应商编号{0}零件编号{3}有重复,请修改时间!", p.供应商编号, p.开始时间, p.结束时间, p.零件编码)); @@ -3072,10 +3072,10 @@ namespace CK.SCP.Controller { string starttime = Convert.ToDateTime(p.最新开始时间).ToShortDateString(); string endtime = Convert.ToDateTime(p.最新结束时间).ToShortDateString(); - var _vender = db.TB_PRICE.SingleOrDefault(t => t.VendId == p.供应商编号.ToUpper() && t.PartCode == p.零件编码 && t.UID.ToString() == p.标识 && t.SubSite == p.地点 && t.Site == p.域); + var _vender = db.TB_PRICE.SingleOrDefault(t => t.VendId == p.供应商编号.ToUpper() && t.PartCode == p.零件编码.Trim() && t.UID.ToString() == p.标识 && t.SubSite == p.地点 && t.Site == p.域); if (_vender == null) { - lineError.Add(string.Format("供应商编号{0}零件编号{3}数据不存在", p.供应商编号, p.开始时间, p.结束时间, p.零件编码)); + lineError.Add(string.Format("供应商编号{0}零件编号{3}数据不存在", p.供应商编号, p.开始时间, p.结束时间, p.零件编码.Trim())); ErrorList = lineError; } if (DateTime.Parse(p.最新开始时间)< DateTime.Parse(p.结束时间) && DateTime.Parse(p.最新开始时间) >DateTime.Parse(p.开始时间)) @@ -3083,7 +3083,7 @@ namespace CK.SCP.Controller _vender.EndTime = Convert.ToDateTime(DateTime.Parse(starttime).AddDays(-1)); _vender.Extend3 = "价格表修改"; - var _PR = db.V_TB_PRICE.FirstOrDefault(t => t.VendId == p.供应商编号.ToUpper() && t.PartCode == p.零件编码 && t.UID.ToString() == p.标识 && t.SubSite == p.地点 && t.Site == p.域); + var _PR = db.V_TB_PRICE.FirstOrDefault(t => t.VendId == p.供应商编号.ToUpper() && t.PartCode == p.零件编码.Trim() && t.UID.ToString() == p.标识 && t.SubSite == p.地点 && t.Site == p.域); if (_PR != null) { TS_UNI_API TS = new TS_UNI_API(); @@ -3110,7 +3110,7 @@ namespace CK.SCP.Controller TS.PutTime = Convert.ToDateTime(DateTime.Parse(starttime).AddDays(-1));//结束时间 TS.CreateOper = _PR.Creator; TS.Currency = _PR.Curr;//货币 - var _first = db.TA_PART.Where(itm => itm.PartCode == p.零件编码).FirstOrDefault(); + var _first = db.TA_PART.Where(itm => itm.PartCode == p.零件编码.Trim()).FirstOrDefault(); if (_first != null) { TS.PoUnit = _first.Unit; @@ -3128,7 +3128,7 @@ namespace CK.SCP.Controller tb.State = 0; tb.Extend3 = "价格表修改增加"; tb.VendId = p.供应商编号; - tb.PartCode = p.零件编码; + tb.PartCode = p.零件编码.Trim(); tb.Curr = p.币种; tb.Unit = p.单位; tb.Remarks = p.备注; @@ -3254,7 +3254,7 @@ namespace CK.SCP.Controller }); _lst.ForEach(p => { - var _count = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.零件号 == p.零件号 && itm.行号 == p.行号); + var _count = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.零件号.Trim() == p.零件号.Trim() && itm.行号 == p.行号); if (_count > 1) { lineError.Add(string.Format("导入订单编号{0}行号{1}零件编码{2}有重复", p.订单编号, p.行号, p.零件号)); @@ -3316,7 +3316,7 @@ namespace CK.SCP.Controller _PO_Detail.PoUnit = itm.单位; _PO_Detail.CreateTime = DateTime.Parse(itm.订单创建时间); _PO_Detail.CreateUser = p_creator; - _PO_Detail.PartCode = itm.零件号; + _PO_Detail.PartCode = itm.零件号.Trim(); _PO_Detail.BeginTime = DateTime.Parse(itm.零件开始时间); _PO_Detail.EndTime = DateTime.Parse(itm.零件截至日期); _PO_Detail.PlanQty = decimal.Parse(itm.数量); @@ -3725,7 +3725,7 @@ namespace CK.SCP.Controller p_order_list.ForEach(p => { var _count1 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.行号 == p.行号); - var _count2 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.零件号 == p.零件号); + var _count2 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.零件号.Trim() == p.零件号.Trim()); if (_count1 > 1 && p_modtype == BillModType.Contract) { lineError.Add(string.Format("导入订单编号【{0}】行号【{1}】有重复", p.订单编号, p.行号)); @@ -3853,7 +3853,7 @@ namespace CK.SCP.Controller p_order_list.ForEach(p => { var _count1 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.行号 == p.行号); - var _count2 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.零件号 == p.零件号); + var _count2 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.零件号.Trim() == p.零件号.Trim()); if (_count1 > 1 && p_modtype == BillModType.Contract) @@ -3863,7 +3863,7 @@ namespace CK.SCP.Controller } if (_count2 > 1) { - lineError.Add(string.Format("导入订单编号【{0}】零件编码【{1}】有重复", p.订单编号, p.零件号)); + lineError.Add(string.Format("导入订单编号【{0}】零件编码【{1}】有重复", p.订单编号, p.零件号.Trim())); ErrorList = lineError; } @@ -3992,8 +3992,8 @@ namespace CK.SCP.Controller list.ForEach((itm) => { int _poline = Int32.Parse(itm.行号); - var _PO_Detail = db.TB_PO_DETAIL.FirstOrDefault(t => t.PartCode == itm.零件号 && t.PoLine == _poline && t.PoBillNum == itm.订单编号 /*&& t.State == state*/ && t.Site == site && t.SubSite == subsite) ?? - new TB_PO_DETAIL { GUID = Guid.NewGuid(), PartCode = itm.零件号.ToUpper(), PoLine = _poline, PoBillNum = itm.订单编号.ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite }; + var _PO_Detail = db.TB_PO_DETAIL.FirstOrDefault(t => t.PartCode == itm.零件号.Trim() && t.PoLine == _poline && t.PoBillNum == itm.订单编号 /*&& t.State == state*/ && t.Site == site && t.SubSite == subsite) ?? + new TB_PO_DETAIL { GUID = Guid.NewGuid(), PartCode = itm.零件号.Trim().ToUpper(), PoLine = _poline, PoBillNum = itm.订单编号.ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite }; _PO_Detail.Currency = "CNY"; _PO_Detail.PoUnit = itm.单位; _PO_Detail.CreateTime = DateTime.Parse(itm.订单创建时间); @@ -4014,7 +4014,7 @@ namespace CK.SCP.Controller _PO_Detail.Scheduledays = string.IsNullOrEmpty(itm.日程天数) ? 7 : int.Parse(itm.日程天数); _PO_Detail.Scheduleweeks = string.IsNullOrEmpty(itm.日程周数) ? 2 : int.Parse(itm.日程周数); _PO_Detail.Schedulemonth = string.IsNullOrEmpty(itm.日程月数) ? 1 : int.Parse(itm.日程月数); - _PO_Detail.Supplieritem = itm.供应商零件.ToUpper(); + _PO_Detail.Supplieritem = itm.供应商零件.Trim().ToUpper(); _PO_Detail.Dliverypatterncode = itm.发货样式; _PO_Detail.Deliverytimecode = itm.发货时间样式; _PO_Detail.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); @@ -4100,7 +4100,7 @@ namespace CK.SCP.Controller _PO_Detail.Scheduledays = string.IsNullOrEmpty(itm.日程天数) ? 7 : int.Parse(itm.日程天数); _PO_Detail.Scheduleweeks = string.IsNullOrEmpty(itm.日程周数) ? 2 : int.Parse(itm.日程周数); _PO_Detail.Schedulemonth = string.IsNullOrEmpty(itm.日程月数) ? 1 : int.Parse(itm.日程月数); - _PO_Detail.Supplieritem = itm.供应商零件; + _PO_Detail.Supplieritem = itm.供应商零件.Trim(); _PO_Detail.Dliverypatterncode = itm.发货样式; _PO_Detail.Deliverytimecode = itm.发货时间样式; _PO_Detail.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); @@ -4344,7 +4344,7 @@ namespace CK.SCP.Controller _t_ASK_Detail.PoUnit = itm.单位; _t_ASK_Detail.CreateTime = DateTime.Now; _t_ASK_Detail.CreateUser = _ask.CreateUser; - _t_ASK_Detail.PartCode = itm.零件号.ToUpper(); + _t_ASK_Detail.PartCode = itm.零件号.Trim().ToUpper(); _t_ASK_Detail.BeginTime = DateTime.Parse(itm.订货日期); _t_ASK_Detail.EndTime = DateTime.Parse(itm.要求到货日期); _t_ASK_Detail.TempQty = decimal.Parse(itm.数量); diff --git a/北京北汽/Controller/SCP_TB_PRICE_CONTROLLER.cs b/北京北汽/Controller/SCP_TB_PRICE_CONTROLLER.cs index d53972f..59838db 100644 --- a/北京北汽/Controller/SCP_TB_PRICE_CONTROLLER.cs +++ b/北京北汽/Controller/SCP_TB_PRICE_CONTROLLER.cs @@ -509,6 +509,7 @@ namespace CK.SCP.Controller public static ResultObject Save_TB_PRICE(List p_entitys,PriceState p_state) { ResultObject _ret = new ResultObject(); + List errorlist = new List(); try { using (ScpEntities db = EntitiesFactory.CreateScpInstance()) @@ -522,18 +523,30 @@ namespace CK.SCP.Controller _entity.TemporaryPrice = itm.TemporaryPrice; _entity.Creator = itm.Creator; _entity.EndTime = itm.EndTime; + if (_entity.EndTime<_entity.StartTime) + { + errorlist.Add("修改后的结束日期不允许小于开始日期!"); + break; + } //_entity.UpdateTime = itm.UpdateTime; //_entity.UpdateUser = itm.UpdateUser; //_entity.UpdateInfo = itm.UpdateInfo; db.TB_PRICE.AddOrUpdate(p => p.UID, _entity); } - if (p_state == PriceState.FConfirm) - { + //if (p_state == PriceState.FConfirm) + //{ + //} + // 如果错误存在 就抛 + if (errorlist.Count>0) + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = errorlist.FirstOrDefault(); + return _ret; } - - if (db.SaveChanges() != -1) + else if (db.SaveChanges() != -1) { _ret.State = ReturnStatus.Succeed; _ret.Result = true; diff --git a/北京北汽/SCP/SCP.csproj b/北京北汽/SCP/SCP.csproj index cf06d0d..6525f1c 100644 --- a/北京北汽/SCP/SCP.csproj +++ b/北京北汽/SCP/SCP.csproj @@ -48,6 +48,9 @@ false + + ..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll + C:\Users\asus\Desktop\ChangKeTec.Utils.dll True @@ -75,10 +78,16 @@ ..\..\..\..\Interop.grsvr6Lib.dll True + + ..\packages\MailKit.3.1.1\lib\net452\MailKit.dll + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + ..\packages\MimeKit.3.1.1\lib\net452\MimeKit.dll + False ..\packages\Newtonsoft.Json.10.0.3\lib\net20\Newtonsoft.Json.dll @@ -96,10 +105,14 @@ ..\packages\NPOI.2.3.0\lib\net40\NPOI.OpenXmlFormats.dll + + ..\packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll + + diff --git a/北京北汽/SCP/Views/BasicData/Price.aspx.cs b/北京北汽/SCP/Views/BasicData/Price.aspx.cs index a3efb5f..03a1fb6 100644 --- a/北京北汽/SCP/Views/BasicData/Price.aspx.cs +++ b/北京北汽/SCP/Views/BasicData/Price.aspx.cs @@ -267,10 +267,11 @@ namespace SCP.BasicData } var list = ConvertHelper.ToList(ExcelHelper.RemoveEmpty(_dt)).ToList(); - List partCodeList = list.Select(a => a.零件编码).ToList(); + List partCodeList = list.Select(a => a.零件编码.Trim()).ToList(); if (partCodeList.Count == 0) { Alert.Show(GetResourceKey("未填写零件编码!")); + FileUp.Reset(); return; } List list1 = new List(); @@ -278,6 +279,7 @@ namespace SCP.BasicData if (list1.Count()>0 ) { Alert.Show(GetResourceKey(string.Format( "导入文件中有不存在的零件,如{0}", list1.FirstOrDefault()))); + FileUp.Reset(); return; } var ret = SCP_PO_CONTROLLER.EXCEL_PRICE_MOD(list, CurrentUser.Name,CurrentUser.RoleList); @@ -340,6 +342,11 @@ namespace SCP.BasicData Alert.Show(GetResourceKey("结束时间不能为空!")); return; } + if (DateTime.Parse( modifyValue["EndTime"].ToString())< _entity.StartTime) + { + Alert.Show(GetResourceKey("结束时间不能小于开始时间!")); + return; + } _entity.EndTime = ConvertHelper.To(modifyValue["EndTime"]); //SCPDB.V_TB_ARRIVE_DETAIL.Count(p => p.ShipTime > _entity.EndTime && p.PartCode == _entity.PartCode && p.SubSite==_entity.SubSite && p.Site==p.Site); //SCPDB.V_TB_ASK_DETAIL.Count(p => p.BeginTime > _entity.EndTime && p.PartCode == _entity.PartCode && p.SubSite == _entity.SubSite && p.Site == p.Site); @@ -748,7 +755,7 @@ namespace SCP.BasicData protected void BtnEdit_Click(object sender, EventArgs e) { - if (this.Grid1.SelectedRowIndexArray.Length == 0 && this.Grid1.SelectedRowIndexArray.Length>1) + if (this.Grid1.SelectedRowIndexArray.Length == 0 || this.Grid1.SelectedRowIndexArray.Length>1) { Alert.Show(GetResourceKey("请选择一行要操作的记录,不能选多条记录!")); return; diff --git a/北京北汽/SCP/Views/BasicData/PriceUpdate.aspx.cs b/北京北汽/SCP/Views/BasicData/PriceUpdate.aspx.cs index 32ffb3e..d171cea 100644 --- a/北京北汽/SCP/Views/BasicData/PriceUpdate.aspx.cs +++ b/北京北汽/SCP/Views/BasicData/PriceUpdate.aspx.cs @@ -15,6 +15,7 @@ using System.Linq.Expressions; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; +using static System.Net.WebRequestMethods; namespace SCP.BasicData { @@ -192,7 +193,7 @@ namespace SCP.BasicData } var list = ConvertHelper.ToList(ExcelHelper.RemoveEmpty(_dt)).ToList(); - List partCodeList = list.Select(a => a.零件编码).ToList(); + List partCodeList = list.Select(a => a.零件编码.Trim()).ToList(); if (partCodeList.Count == 0) { Alert.Show("未填写零件编码!"); @@ -216,6 +217,7 @@ namespace SCP.BasicData else { Alert.Show(string.Join("
", ret.MessageList)); + FileUpload1.Reset(); return; } } diff --git a/北京北汽/SCP/Views/BasicData/SCP_PRICE_EDIT.aspx.cs b/北京北汽/SCP/Views/BasicData/SCP_PRICE_EDIT.aspx.cs index 7a0dd98..8bb57ea 100644 --- a/北京北汽/SCP/Views/BasicData/SCP_PRICE_EDIT.aspx.cs +++ b/北京北汽/SCP/Views/BasicData/SCP_PRICE_EDIT.aspx.cs @@ -92,7 +92,7 @@ namespace SCP.Views.BasicData } else { - Alert.Show("更新价格失败!"); + Alert.Show("更新价格失败!原因:"+rs.Message); } } } diff --git a/北京北汽/SCP/Views/PlanData/SCP_PO.aspx.cs b/北京北汽/SCP/Views/PlanData/SCP_PO.aspx.cs index 8b3cb9e..09119db 100644 --- a/北京北汽/SCP/Views/PlanData/SCP_PO.aspx.cs +++ b/北京北汽/SCP/Views/PlanData/SCP_PO.aspx.cs @@ -196,6 +196,7 @@ namespace SCP.PlanData if (string.IsNullOrEmpty(_fileName)) { Alert.Show("选择文件为空!"); + FileUp.Reset(); return; } string _lx = _fileName.Split('.')[1]; @@ -211,10 +212,11 @@ namespace SCP.PlanData } var list = ConvertHelper.ToList(ExcelHelper.RemoveEmpty(_dt)).ToList(); - List partCodeList = list.Select(a => a.零件号).ToList(); + List partCodeList = list.Select(a => a.零件号.Trim()).ToList(); if (partCodeList.Count == 0) { Alert.Show("未填写零件编码!"); + FileUp.Reset(); return; } List list1 = new List(); @@ -222,12 +224,14 @@ namespace SCP.PlanData if (list1.Count()>0) { Alert.Show(string.Format("导入文件中有不存在的零件,如{0}", list1.FirstOrDefault())); + FileUp.Reset(); return; } var checkret = SCP_PO_CONTROLLER.Check_EXCEL_PO_MOD(list, p_modtype, CurrentUser.FactoryList[0], CurrentUser.SubSiteList[0]); if (checkret.State == ReturnStatus.Failed && checkret.Result == false) { Alert.Show(string.Join("
", checkret.MessageList)); + FileUp.Reset(); return; } if (CurrentUser.ConfigList.ContainsKey("数据中心接口")) @@ -258,6 +262,7 @@ namespace SCP.PlanData { //Alert.Show(string.Join("
", saveret.MessageList)); Alert.Show(saveret.Message); + FileUp.Reset(); return; } } diff --git a/北京北汽/SCP/Views/PlanData/SCP_PO_CQ.aspx.cs b/北京北汽/SCP/Views/PlanData/SCP_PO_CQ.aspx.cs index ece66f0..9de53de 100644 --- a/北京北汽/SCP/Views/PlanData/SCP_PO_CQ.aspx.cs +++ b/北京北汽/SCP/Views/PlanData/SCP_PO_CQ.aspx.cs @@ -210,7 +210,7 @@ namespace SCP.Views.PlanData } var list = ConvertHelper.ToList(ExcelHelper.RemoveEmpty(_dt)).ToList(); - List partCodeList = list.Select(a => a.零件号).ToList(); + List partCodeList = list.Select(a => a.零件号.Trim()).ToList(); if (partCodeList.Count == 0) { Alert.Show("未填写零件编码!"); diff --git a/北京北汽/SCP/Web.config b/北京北汽/SCP/Web.config index 34e84d1..5257cda 100644 --- a/北京北汽/SCP/Web.config +++ b/北京北汽/SCP/Web.config @@ -1,4 +1,4 @@ - + - - - - - - + + + + + + - - + + - - - - - + + + + + - - - + + + - + - + - + - + - + - + - + - + - + - - + + @@ -84,28 +84,28 @@ - - + + - - + + - - + + - - + + - - + + - - + + @@ -119,14 +119,14 @@ - + - + @@ -134,37 +134,37 @@ - - - + + + - - + + - + - - + + - + - + - - - - - - - + + + + + + + @@ -175,18 +175,18 @@ --> - + - + - - + + diff --git a/北京北汽/SCP/default_hb.aspx.cs b/北京北汽/SCP/default_hb.aspx.cs index c71031e..ab5a3e8 100644 --- a/北京北汽/SCP/default_hb.aspx.cs +++ b/北京北汽/SCP/default_hb.aspx.cs @@ -17,6 +17,8 @@ using System.Configuration; using SCP.Code; using CK.SCP.Models.Enums; using System.Drawing; +using static CK.SCP.Common.MyWebSmtpMail; +using MailKit.Security; namespace SCP { @@ -366,6 +368,7 @@ namespace SCP if (!user.Enabled) { Alert.Show(GetResourceKey("用户未启用,请联系管理员!")); + img.ImageUrl = DrawToBase64(4); } else { @@ -380,26 +383,38 @@ namespace SCP int a = GenerateRandomNo(); string b = random(); - - + + string mailbody = ""; mailbody += "尊敬的供应商
"; - mailbody += "你好!密码已经重置为" + b + "@"+ a + "请点击链接进行登录并修改密码 < br>
"; + mailbody += "你好!密码已经重置为" + b + "@"+ a + "请点击链接进行登录并修改密码

"; string str = ConfigurationManager.AppSettings["ResetPassWord"].ToString(); //mailbody += string.Format("