FrmAnnouncement.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. using LYFZ.Software.MainBusiness.DoorCityProcess;
  11. namespace LYFZ.Software.MainBusiness.BulletinBoard
  12. {
  13. public partial class FrmAnnouncement : LYFZ.Software.UI.BulletinBoard.FrmAnnouncement
  14. {
  15. bool bl = false;
  16. public FrmAnnouncement()
  17. {
  18. this.FormClosed += FrmAnnouncement_FormClosed;
  19. }
  20. void FrmAnnouncement_FormClosed(object sender, FormClosedEventArgs e)
  21. {
  22. if (bl)
  23. {
  24. this.DialogResult = DialogResult.OK;
  25. }
  26. }
  27. #region 发送
  28. protected override void btnRelease_Click(object sender, EventArgs e)
  29. {
  30. try
  31. {
  32. LYFZ.Model.Model_ErpInternalMail model = new Model.Model_ErpInternalMail();
  33. LYFZ.BLL.BLL_ErpInternalMail bll = new BLL.BLL_ErpInternalMail();
  34. if (string.IsNullOrEmpty(txtImail_Content.Text))
  35. {
  36. MessageBoxCustom.Show("消息内容不能为空!");
  37. return;
  38. }
  39. model.Imail_Type = "0";
  40. model.Imail_Title = "";
  41. model.Imail_Content = txtImail_Content.Text;
  42. model.Imail_FromName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  43. model.Imail_ToName = "";
  44. if (!string.IsNullOrEmpty(txtImail_Attachment.Text))
  45. {
  46. string[] d = txtImail_Attachment.Text.ToString().Split('\\');
  47. string path = d.Last();
  48. File.Copy(PhotoFilePath, BLL.BLL_ErpInternalMail.GetAnnouncementPath()+"\\" + path);
  49. //File.Copy(PhotoFilePath, Application.StartupPath + "\\公告\\" + path);
  50. model.Imail_Attachment = path;
  51. }
  52. else { model.Imail_Attachment = ""; }
  53. model.Imail_Status = "OK";
  54. model.Imail_ReadList = "";
  55. model.Imail_OwnerList = "";
  56. model.Imail_ToSendDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  57. model.Imail_DeleteList = "";
  58. model.Imail_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  59. model.Imail_UpdateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  60. if (bll.Add(model) == true)
  61. {
  62. MessageBoxCustom.Show("公告发布成功!");
  63. txtImail_Attachment.Text = "";
  64. txtImail_Content.Text = "";
  65. bl = true;
  66. }
  67. }
  68. catch (Exception ex)
  69. {
  70. MessageBoxCustom.Show(ex.Message);
  71. }
  72. }
  73. #endregion
  74. #region 浏览
  75. string PhotoFilePath = "";
  76. protected override void btnBrowse_Click(object sender, EventArgs e)
  77. {
  78. openFileDialog1.Filter = "全部|*.*|Excel文件(*.xls)|*.xls|Excel文件(*.xlsx)|*.xlsx|Word文件(*.doc)|*.doc|文本文件(*.txt)|*.txt|图片文件(*.jpg)|*.jpg|图片文件(*.gif)|*.gif|图片文件(*.bmp)|*.bmp|图片文件(*.png)|*.png";
  79. openFileDialog1.FileName = "";
  80. if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  81. {
  82. PhotoFilePath = openFileDialog1.FileName;
  83. txtImail_Attachment.Text = PhotoFilePath;
  84. //判断文件大小
  85. FileInfo fileInfo = new FileInfo(PhotoFilePath);
  86. int ShowFileSize = Convert.ToInt32(fileInfo.Length) / Convert.ToInt32(1024);//文件大小
  87. if (ShowFileSize > 215040)
  88. {
  89. MessageBoxCustom.Show("文件过大,不能超过210K!");
  90. txtImail_Attachment.Text = "";
  91. }
  92. }
  93. }
  94. #endregion
  95. #region 关闭
  96. protected override void btnClose_Click(object sender, EventArgs e)
  97. {
  98. this.Close();
  99. }
  100. #endregion
  101. }
  102. }