123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using LYFZ.Software.MainBusiness.DoorCityProcess;
- namespace LYFZ.Software.MainBusiness.BulletinBoard
- {
- public partial class FrmAnnouncement : LYFZ.Software.UI.BulletinBoard.FrmAnnouncement
- {
- bool bl = false;
- public FrmAnnouncement()
- {
- this.FormClosed += FrmAnnouncement_FormClosed;
- }
- void FrmAnnouncement_FormClosed(object sender, FormClosedEventArgs e)
- {
- if (bl)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- #region 发送
- protected override void btnRelease_Click(object sender, EventArgs e)
- {
- try
- {
- LYFZ.Model.Model_ErpInternalMail model = new Model.Model_ErpInternalMail();
- LYFZ.BLL.BLL_ErpInternalMail bll = new BLL.BLL_ErpInternalMail();
- if (string.IsNullOrEmpty(txtImail_Content.Text))
- {
- MessageBoxCustom.Show("消息内容不能为空!");
- return;
- }
- model.Imail_Type = "0";
- model.Imail_Title = "";
- model.Imail_Content = txtImail_Content.Text;
- model.Imail_FromName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- model.Imail_ToName = "";
- if (!string.IsNullOrEmpty(txtImail_Attachment.Text))
- {
- string[] d = txtImail_Attachment.Text.ToString().Split('\\');
- string path = d.Last();
- File.Copy(PhotoFilePath, BLL.BLL_ErpInternalMail.GetAnnouncementPath()+"\\" + path);
- //File.Copy(PhotoFilePath, Application.StartupPath + "\\公告\\" + path);
- model.Imail_Attachment = path;
- }
- else { model.Imail_Attachment = ""; }
- model.Imail_Status = "OK";
- model.Imail_ReadList = "";
- model.Imail_OwnerList = "";
- model.Imail_ToSendDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Imail_DeleteList = "";
- model.Imail_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Imail_UpdateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- if (bll.Add(model) == true)
- {
- MessageBoxCustom.Show("公告发布成功!");
- txtImail_Attachment.Text = "";
- txtImail_Content.Text = "";
- bl = true;
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 浏览
- string PhotoFilePath = "";
- protected override void btnBrowse_Click(object sender, EventArgs e)
- {
- openFileDialog1.Filter = "全部|*.*|Excel文件(*.xls)|*.xls|Excel文件(*.xlsx)|*.xlsx|Word文件(*.doc)|*.doc|文本文件(*.txt)|*.txt|图片文件(*.jpg)|*.jpg|图片文件(*.gif)|*.gif|图片文件(*.bmp)|*.bmp|图片文件(*.png)|*.png";
- openFileDialog1.FileName = "";
- if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- PhotoFilePath = openFileDialog1.FileName;
- txtImail_Attachment.Text = PhotoFilePath;
- //判断文件大小
- FileInfo fileInfo = new FileInfo(PhotoFilePath);
- int ShowFileSize = Convert.ToInt32(fileInfo.Length) / Convert.ToInt32(1024);//文件大小
- if (ShowFileSize > 215040)
- {
- MessageBoxCustom.Show("文件过大,不能超过210K!");
- txtImail_Attachment.Text = "";
- }
- }
- }
- #endregion
- #region 关闭
- protected override void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- }
- }
|