diff --git a/UICode/CustPOSendMailUI/WebPart/CustPOSendMailUIFormWebPartCodeBehindExtend.cs b/UICode/CustPOSendMailUI/WebPart/CustPOSendMailUIFormWebPartCodeBehindExtend.cs index 7944872..4c9efeb 100644 --- a/UICode/CustPOSendMailUI/WebPart/CustPOSendMailUIFormWebPartCodeBehindExtend.cs +++ b/UICode/CustPOSendMailUI/WebPart/CustPOSendMailUIFormWebPartCodeBehindExtend.cs @@ -45,78 +45,78 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI #region Custome eventBind string filePath = " C:\\U8NetPrintResult\\Guest"; - string filePathD = " D:\\U8NetPrintResult\\Guest"; - + string filePathD = " E:\\U8NetPrintResult\\Guest"; + string PurMail = ""; //DropDownList_Notices_TextChanged... - private void DropDownList_Notices_TextChanged_Extend(object sender, EventArgs e) - { - //调用模版提供的默认实现.--默认实现可能会调用相应的Action. - - Action.OnSend(sender, new UIActionEventArgs()); - - string SelSQL = @"SELECT PrintTemplateText FROM Cust_PrintTemplateText WHERE PrintTemplateTypeName='" + this.DropDownList_Notices.Text + "'"; - DataSet SelSQLDs = new DataSet(); - UFSoft.UBF.Util.DataAccess.DataAccessor.RunSQL(UFSoft.UBF.Util.DataAccess.DataAccessor.GetConn(), SelSQL.ToString(), null, out SelSQLDs); - DataTable dt = new DataTable(); - dt = SelSQLDs.Tables[0]; - if (dt.Rows.Count<1) + private void DropDownList_Notices_TextChanged_Extend(object sender, EventArgs e) + { + //调用模版提供的默认实现.--默认实现可能会调用相应的Action. + + Action.OnSend(sender, new UIActionEventArgs()); + + string SelSQL = @"SELECT PrintTemplateText FROM Cust_PrintTemplateText WHERE PrintTemplateTypeName='" + this.DropDownList_Notices.Text + "'"; + DataSet SelSQLDs = new DataSet(); + UFSoft.UBF.Util.DataAccess.DataAccessor.RunSQL(UFSoft.UBF.Util.DataAccess.DataAccessor.GetConn(), SelSQL.ToString(), null, out SelSQLDs); + DataTable dt = new DataTable(); + dt = SelSQLDs.Tables[0]; + if (dt.Rows.Count < 1) { throw new Exception("配置表Cust_PrintTemplateText中不存在对应信息,请先维护"); } - - this.MailText53.Text = dt.Rows[0][0].ToString(); - this.DataCollect(); - this.DataBind(); + this.MailText53.Text = dt.Rows[0][0].ToString(); + this.DataCollect(); + this.DataBind(); - DropDownList_Notices_TextChanged_DefaultImpl(sender,e); - } - - //OnSend273_Click... - private void OnSend273_Click_Extend(object sender, EventArgs e) - { - //调用模版提供的默认实现.--默认实现可能会调用相应的Action. - IUIRecordCollection records = this.Model.CustPOSendMailPerson.SelectRecords; + DropDownList_Notices_TextChanged_DefaultImpl(sender, e); + } - if (records == null || records.Count == 0) - { - throw new Exception("请先勾选发件人"); - } - string MailAddress = string.Empty; + //OnSend273_Click... + private void OnSend273_Click_Extend(object sender, EventArgs e) + { + //调用模版提供的默认实现.--默认实现可能会调用相应的Action. + IUIRecordCollection records = this.Model.CustPOSendMailPerson.SelectRecords; - if (records.Count > 0) - { - foreach (var item in records) - { - string RcvPerson = string.Empty; - string Telephone = string.Empty; + if (records == null || records.Count == 0) + { + throw new Exception("请先勾选发件人"); + } + string MailAddress = string.Empty; - RcvPerson = item["RcvPerson"].ToString(); - Telephone = item["Telephone"].ToString(); - if (string.IsNullOrWhiteSpace(item["MailAddress"].ToString())) - { - throw new Exception("邮箱地址为空"); - } - MailAddress += item["MailAddress"].ToString() + ";"; - if (string.IsNullOrWhiteSpace(MailAddress)) - { - throw new Exception("邮箱地址为空"); - } + if (records.Count > 0) + { + foreach (var item in records) + { + string RcvPerson = string.Empty; + string Telephone = string.Empty; - } - } + RcvPerson = item["RcvPerson"].ToString(); + Telephone = item["Telephone"].ToString(); + if (string.IsNullOrWhiteSpace(item["MailAddress"].ToString())) + { + throw new Exception("邮箱地址为空"); + } + MailAddress += item["MailAddress"].ToString() + ";"; + if (string.IsNullOrWhiteSpace(MailAddress)) + { + throw new Exception("邮箱地址为空"); + } + + } + } - SendMail(MailAddress); + SendMail(MailAddress); - OnSend273_Click_DefaultImpl(sender,e); - } + + OnSend273_Click_DefaultImpl(sender, e); + } private void SendMail(string TOAddress) @@ -215,13 +215,14 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI SmtpClient client = new SmtpClient(); client.Host = SendHost;//SMTP服务器地址 - //client.EnableSsl = true; + client.EnableSsl = true; client.UseDefaultCredentials = false; //发件人邮箱账号 client.Credentials = new System.Net.NetworkCredential(SendAddress, SendPassword); + MailAddress from = new MailAddress(SendAddress, SendPassword); //邮件的发件人 MailMessage message = new MailMessage(); try @@ -238,14 +239,43 @@ namespace UFIDA.U9.Cust.WC.CustPOSendMailUI message.CC.Add(CCAddress);//抄送人邮箱 } + string SelSQL = @"SELECT top 1 PrintTemplateText FROM Cust_PrintTemplateText "; + DataSet SelSQLDs = new DataSet(); + UFSoft.UBF.Util.DataAccess.DataAccessor.RunSQL(UFSoft.UBF.Util.DataAccess.DataAccessor.GetConn(), SelSQL.ToString(), null, out SelSQLDs); + DataTable dt = new DataTable(); + dt = SelSQLDs.Tables[0]; + if (dt.Rows.Count < 1) + { + throw new Exception("配置表Cust_PrintTemplateText中不存在对应信息,请先维护"); + } + message.From = new MailAddress(SendAddress);//发件人邮箱 message.Subject = this.MailTitle86.Text;//邮件标题 message.SubjectEncoding = Encoding.UTF8;//标题格式为UTF8 - string _Body = this.MailText53.Text; + string _Body = dt.Rows[0][0].ToString(); string[] strArray = _Body.Split(new char[1] { ' ' }); + + + + string _SelSQL = @"select c.DefaultEmail from PM_PurchaseOrder a + left join CBO_Operators b on a.PurOper = b.ID + left join Base_Contact c on b.Contact = c.ID + where a.DocNo ='" + CurrentState["POCode"].ToString() + "' and a.Org='" + CurrentState["OrgID"].ToString() + "'"; + DataSet _SelSQLDs = new DataSet(); + UFSoft.UBF.Util.DataAccess.DataAccessor.RunSQL(UFSoft.UBF.Util.DataAccess.DataAccessor.GetConn(), _SelSQL.ToString(), null, out _SelSQLDs); + DataTable dtPur = new DataTable(); + dtPur = _SelSQLDs.Tables[0]; + if (dtPur.Rows.Count == 0) + { + throw new Exception("采购员未维护邮箱"); + } + + string PurMail = dtPur.Rows[0]["DefaultEmail"].ToString();//采购员收件邮箱 + + string mailMessage = @"
{0} | +
{0} | +