private void Btnsend_Click(object sender, EventArgs e) { if (ListReceiver.SelectedIndex == -1) { return; } if (gridView.RowCount < 1) { return; } if (gridView.FocusedRowHandle < 0) { MessageBox.Show("请选择相应的物料", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string Receiver = ListReceiver.Text.Substring(0, ListReceiver.Text.IndexOf(':')); string mail = ListReceiver.SelectedValue.ToString(); string supper = gridView.GetFocusedRowCellValue("供应商").ToString(); string productcode = gridView.GetFocusedRowCellValue("物料编码").ToString(); string productmodel = gridView.GetFocusedRowCellValue("型号").ToString(); string sql = " "; DataTable dt = null; string Directory = ""; string title = ""; if (gridView.Columns.Count == 23) { sql = " update IQC_SupperROHS set SendState = 'OK' ,SendUser = '******' ,SendDate = GETDATE(),Receiver = '" + Receiver + "' where supper = '" + supper + "' and productcode = '" + productcode + "' "; dt = rohsreport(supper, productcode); Directory = "共享文件目录为:" + "\\\\QMSSVR\\rohs\\" + supper + "\\" + productcode + "\\" + productmodel; title = "ROHS供应商测试报告"; } else if (gridView.Columns.Count == 17) { sql = " update IQC_SupperHF set SendState = 'OK' ,SendUser = '******' ,SendDate = GETDATE(),Receiver = '" + Receiver + "' where supper = '" + supper + "' and productcode = '" + productcode + "' "; dt = hfreport(supper, productcode); Directory = "共享文件目录为:" + "\\\\QMSSVR\\hf\\" + supper + "\\" + productcode + "\\" + productmodel; title = "HF测试报告"; } bool flag = DbAccess.ExecuteSql(sql); string content = ProdTest.HtmlBoy(dt, title, "请注意查收,供应商:" + supper + " ,物料编码:" + productcode + " 需要你审核," + Directory, "供应商:" + supper + " ,物料编码:" + productcode); if (flag == true) { try { ProdTest.SendHTMLboyMail(mail, "QMS系统:" + DateTime.Now.ToString("yyyyMMdd") + "供应商" + supper + "物料" + productcode + "测试报告提醒", content); } catch { } } }
private void sBtnsend_Click(object sender, EventArgs e) { if (gridView.RowCount < 1) { return; } if (gridView.FocusedRowHandle < 0) { MessageBox.Show("请选择相应的物料", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (gridViewmail.RowCount < 1) { return; } if (gridViewmail.FocusedRowHandle < 0) { MessageBox.Show("请选择相应的负责人", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string materialcode = gridView.GetFocusedRowCellValue("materialcode").ToString(); string vendorcode = gridView.GetFocusedRowCellValue("vendorcode").ToString(); string Mouldcode = gridView.GetFocusedRowCellValue("Mouldcode").ToString(); string Mouldtype = gridView.GetFocusedRowCellValue("Mouldtype").ToString(); string MouldQty = gridView.GetFocusedRowCellValue("MouldQty").ToString(); string MouldLife = gridView.GetFocusedRowCellValue("MouldLife").ToString(); string RestQty = gridView.GetFocusedRowCellValue("RestQty").ToString(); string userName = gridViewmail.GetFocusedRowCellValue("userName").ToString(); string userMail = gridViewmail.GetFocusedRowCellValue("userMail").ToString(); string content = "物料编码(" + materialcode + "),模具为:" + MouldQty + ";类型为:" + Mouldtype + ";寿命为:" + MouldLife + ";剩余次数为:" + RestQty; if ((int.Parse(RestQty) < int.Parse(MouldLife) * 0.2) && (int.Parse(RestQty) > int.Parse(MouldLife) * 0.1)) { content += " ;剩余量少于20%,请提醒相应的供应商 "; } else if (int.Parse(RestQty) <= int.Parse(MouldLife) * 0.1) { content += " ;剩余量少于10%,请提醒相应的供应商 "; } try { Outlook.Application olApp = new Outlook.Application(); Outlook.MailItem mailItem = (Outlook.MailItem)olApp.CreateItem(Outlook.OlItemType.olMailItem); mailItem.To = userMail; mailItem.Subject = "QMS系统:" + DateTime.Now.ToString("yyyyMMdd") + "_模具寿命提醒"; mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML; mailItem.HTMLBody = content; ((Outlook._MailItem)mailItem).Send(); MessageBox.Show("发送成功", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information); mailItem = null; olApp = null; } catch { ProdTest.SendMail(userMail, "QMS系统:" + DateTime.Now.ToString("yyyyMMdd") + "_模具寿命提醒", content); } }