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 NetOffice;
using Outlook = NetOffice.OutlookApi;
using NetOffice.OutlookApi.Enums;

namespace FCM0000 
{
    public partial class fPatchList : FCOMMON.fBase
    {
        public fPatchList()
        {
            InitializeComponent();
            this.dsMSSQL.Board.TableNewRow += RequestItem_TableNewRow;
        }

        void RequestItem_TableNewRow(object sender, DataTableNewRowEventArgs e)
        {
            e.Row["wuid"] = FCOMMON.info.Login.no;
            e.Row["wdate"] = DateTime.Now;
            e.Row["bidx"] = 5;
            e.Row["pidx"] = -1;
            e.Row["gcode"] = FCOMMON.info.Login.gcode;
        }

        private void fRequestItem_Load(object sender, EventArgs e)
        {
            if (FCOMMON.info.Login.level >= 9)
            {
                bn.Enabled = true;
                BTsAVE.Enabled = true;
            }
            else
            {
                bn.Enabled = false;
                BTsAVE.Enabled = false;
                this.arDatagridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
            }
            refreshData();
        }

        private void boardBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.bs.EndEdit();
            this.tam.UpdateAll(this.dsMSSQL);

        }

        private void fillToolStripButton_Click(object sender, EventArgs e)
        {
           

        }

        void refreshData()
        {
            try
            {
                this.ta.Fill(this.dsMSSQL.Board,5, "%");
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }

        private void btSearch_Click(object sender, EventArgs e)
        {
            refreshData();
        }

        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            this.bs.AddNew();
            //var newdr = this.dsMSSQL.Board.NewBoardRow();//.NewRequestItemRow();
            //fRequestItem_Add f = new fRequestItem_Add(newdr);
            //if (f.ShowDialog() != System.Windows.Forms.DialogResult.OK) newdr.Delete();
            //else this.dsMSSQL.RequestItem.AddRequestItemRow(newdr);
        }

        private void btSearch_Click_1(object sender, EventArgs e)
        {
            refreshData();
        }

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

      
    }
}
