using LYFZ.Software.MainBusiness.DoorCityProcess;
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;

namespace LYFZ.Software.MainBusiness.BulletinBoard
{
    public partial class FrmSelectAnnouncement : LYFZ.Software.UI.BulletinBoard.FrmSelectAnnouncement
    {
        public int ID;
        public FrmSelectAnnouncement()
        {
        }

        #region 加载
        protected override void FrmSelectAnnouncement_Load(object sender, EventArgs e)
        {
            try
            {
                if (ID > 0)
                {
                    LYFZ.BLL.BLL_ErpInternalMail bll = new BLL.BLL_ErpInternalMail();
                    DataTable dt = bll.View_ErpInternalMail("ID=" + ID + "").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        txtImail_Attachment.Text = dt.Rows[0]["Imail_Attachment"].ToString();
                        txtImail_Content.Text = dt.Rows[0]["Imail_Content"].ToString();
                        lblNR.Text = "发布人(" + dt.Rows[0]["Imail_FromNames"] + ")     时间(" + dt.Rows[0]["Imail_ToSendDatetime"] + ")   内容:";
                    }
                }
            }
            catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
        }
        #endregion

        #region 查询
        protected override void btnSelect_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtImail_Attachment.Text))
            {
                try
                {
                   // string path = Application.StartupPath + "\\公告\\" + txtImail_Attachment.Text;
                    string path = BLL.BLL_ErpInternalMail.GetAnnouncementPath() + "\\" + txtImail_Attachment.Text;
                    System.Diagnostics.Process.Start(path);
                }
                catch (System.ComponentModel.Win32Exception we) { MessageBoxCustom.Show(we.Message); return; }
            }

            //if (ID > 0)
            //{
            //    LYFZ.BLL.BLL_ErpInternalMail bll = new BLL.BLL_ErpInternalMail();
            //    DataTable dt = bll.GetList("ID=" + ID + "").Tables[0];
            //    if (dt.Rows.Count > 0)
            //    {
            //        if (!string.IsNullOrEmpty(dt.Rows[0]["Imail_Attachment"].ToString()))
            //        {
            //            byte[] path = PublicCodeClasses.StringToByte(dt.Rows[0]["Fd_PhotoAlbum"].ToString());
            //            System.Diagnostics.Process.Start(path).ToString();
            //        }
            //    }
            //}
           
        }
        #endregion

        #region 取消
        protected override void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        #endregion

    }
}