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 FCM0000
{
    public partial class fJRForm : FCOMMON.fBase
    {
        public fJRForm()
        {
            InitializeComponent();
            Properties.Settings.Default["gwcs"] = FCOMMON.info.CS;

            this.dsMSSQL1.EETGW_DocuForm.TableNewRow += MailForm_TableNewRow;
        }

        void MailForm_TableNewRow(object sender, DataTableNewRowEventArgs e)
        {
            e.Row["wuid"] = FCOMMON.info.Login.no;
            e.Row["wdate"] = DateTime.Now;
            e.Row["title"] = "분류제목";
            e.Row["cate"] = "--";
            e.Row["gcode"] = FCOMMON.info.Login.gcode;
        }
        
        private void fMailform_Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            refreshData(); 
        }

        void refreshData()
        {
            try
            {
                ta.Fill(this.dsMSSQL1.EETGW_DocuForm, FCOMMON.info.Login.gcode);
            }
            catch (Exception ex)
            {
                FCOMMON.Util.MsgE(ex.Message);
            }
        }

        private void mailFormBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.dr.body = this.richTextBoxEx1.Rtf;
            this.bs.EndEdit();
            this.ta.Update(this.dsMSSQL1.EETGW_DocuForm);

        }
        dsMSSQL.EETGW_DocuFormRow dr = null;
        private void bs_CurrentChanged(object sender, EventArgs e)
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            dr = drv.Row as dsMSSQL.EETGW_DocuFormRow;
            try
            {
                this.richTextBoxEx1.Rtf = dr.body;
            }
            catch
            {
                this.richTextBoxEx1.Text = dr.body;
            }

            //this.htmlEditor2.Html = dr.tail;
        }


        private void mailFormDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {

        }

        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            var dlg = FCOMMON.Util.MsgQ("선택된 자료를 삭제하시겠습니까?");
            if (dlg != System.Windows.Forms.DialogResult.Yes) return;
            bs.RemoveCurrent();
        }

        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {

        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
