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 FPJ0000
{
    public partial class fProejctHistory : FCOMMON.fBase
    {
        int pidx = 0;
        public fProejctHistory(int pidx_)
        {
            InitializeComponent();
            this.pidx = pidx_;
        }
        private void fProejctHistory_Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            try
            {
                this.ta.Fill(this.dsPRJ.ProjectsHistory, this.pidx);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }

        private void projectsHistoryBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.bs.EndEdit();
            try
            {
                this.tam.UpdateAll(this.dsPRJ);
                DialogResult = System.Windows.Forms.DialogResult.OK;
            }catch (Exception ex)
            {
                FCOMMON.Util.MsgE(ex.Message);
            }
        }

        private void fillToolStripButton_Click(object sender, EventArgs e)
        {
            

        }

        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.ProjectsHistoryRow;
            string msg = "다음 자료를 삭제하시겠습니까?\n\n" +
                "등록일 : " + dr.pdate;
            var dlg = FCOMMON.Util.MsgQ(msg);
            if(dlg == System.Windows.Forms.DialogResult.Yes)
            {
                bs.RemoveCurrent();
            }
        }

        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            var newdr = this.dsPRJ.ProjectsHistory.NewProjectsHistoryRow();
            newdr.pdate = DateTime.Now.ToString("yyyy-MM-dd");
            newdr.wuid = FCOMMON.info.Login.no;
            newdr.wdate = DateTime.Now;
            newdr.remark = string.Empty;
            newdr.pidx = this.pidx;
            this.dsPRJ.ProjectsHistory.AddProjectsHistoryRow(newdr);
            this.bs.Position = 0;
            textBox1.Focus();
        }

        private void projectsHistoryDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {

        }
    }
}
