using FCOMMON;
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 FBS0000
{
    public partial class fMinutesDetail : fBase
    {
        int idx = -1;
        public fMinutesDetail(int idx_)
        {
            InitializeComponent();
            Properties.Settings.Default["gwcs"] = FCOMMON.info.CS;
            this.FormClosed += __Closed;
            this.idx = idx_;
        }

        void __Closed(object sender, FormClosedEventArgs e)
        {
            
        }

        private void __Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            this.Show();
            Application.DoEvents();

            //refresh Data
            this.ta.FillByIDX(this.dsMSSQL.minutes,this.idx);
        }
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var f = new FCM0000.fLovProject("");
            if(f.ShowDialog()  == System.Windows.Forms.DialogResult.OK)
            {
                this.tbPrj.Text = f.val_Index.ToString();
                this.tbPrjName.Text = f.val_Title;
                placeTextBox.Focus();
            }
        }

        private void tbPrjName_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode == Keys.Enter)
            {
                var search = tbPrjName.Text.Trim();
                if(search == "")
                {
                    SendKeys.Send("{TAB}");
                }
                else
                {
                    var f = new FCM0000.fLovProject("%" + search + "%");
                    if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        this.tbPrj.Text = f.val_Index.ToString();
                        this.tbPrjName.Text = f.val_Title;
                        SendKeys.Send("{TAB}");
                    }
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                this.Invalidate();
                this.bs.EndEdit();
                var cnt = ta.Update(this.dsMSSQL.minutes);
                FCOMMON.Util.MsgI(cnt.ToString() + "건의 자료가 저장 되었습니다.");
            }
            catch (Exception ex)
            {
                FCOMMON.Util.MsgE("save error\n\n" + ex.Message);
            }
        }
    }
}
