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 util = FCOMMON.Util;

namespace FPJ0000
{
    public partial class fEboardList : FCOMMON.fBase
    {
        string fn_fpcolsize = "";
        public fEboardList()
        {
            InitializeComponent();
            fn_fpcolsize = util.MakeFilePath(util.CurrentPath, "formSetting", "fp_" + this.Name + ".ini");
            this.dsMSSQL.Projects.TableNewRow += Projects_TableNewRow;
            this.FormClosed += __Closed;
            this.fpSpread1.KeyDown += FpSpread1_KeyDown;

        }

        private void FpSpread1_KeyDown(object sender, KeyEventArgs e)
        {
            var cell = this.fpSpread1.ActiveSheet.ActiveCell;
            if (cell == null) return;
            var colIndex = cell.Column.Index;
            var rowIndex = cell.Row.Index;
            if (e.KeyCode == Keys.L && e.Alt)
            {

            }
        }

        void __Closed(object sender, FormClosedEventArgs e)
        {

        }

        private void __Load(object sender, EventArgs e)
        {
            //프로젝트 목록을 처리함
            this.tbRequest.Text = FCOMMON.info.Login.nameK;

            //this.cmbSort.SelectedIndex = 0;
            this.cmbYearS.Items.Clear();
            this.cmbYearE.Items.Clear();
            for (int i = 2010; i <= DateTime.Now.Year; i++)
            {
                cmbYearS.Items.Add(i.ToString("0000") + "-01-01");
                cmbYearE.Items.Add(i.ToString("0000") + "-01-01");
            }
            this.cmbYearS.Text = DateTime.Now.Year.ToString("0000") + "-01-01";
            this.cmbYearE.Text = DateTime.Now.Year.ToString("0000") + "-12-31";
            refreshData();

            //일반사용자의경우에는 상태를 변경하지 못한다.
            //int curLevel = Math.Max(FCOMMON.info.Login.level, FCOMMON.DBM.getAuth(FCOMMON.DBM.eAuthType.project));
            //if (curLevel >= 5)
            //{
            //    btSave.Visible = true;
            //}
            //else
            //{
            //    btSave.Visible = false; //목록에서 저장버튼은 제거한다.
            //    //btViewDel.Visible = false;
            //    //fpSpread1.EditMode = false;
            //    //fpSpread1.Sheets[0].SelectionUnit = FarPoint.Win.Spread.Model.SelectionUnit.Row;
            //    //fpSpread1.EditModePermanent = false;
            //    //fpSpread1.EditModeReplace = false;

            //    //foreach (FarPoint.Win.Spread.Column col in fpSpread1.ActiveSheet.Columns)
            //    //    col.Locked = true;
            //}


        }

        void refreshData()
        {
            //수리지연추가 210208 - 장은철


            if (this.dsMSSQL.EETGW_JobReport_EBoard.GetChanges() != null)
            {
                var dlg = util.MsgQ("변경된 내용이 있습니다. 지금 새로고침 하면 해당 자료는 손실 됩니다. 진행 할까요?");
                if (dlg != DialogResult.Yes) return;
            }

            //string state = "[status] like  '" + cmbStat.Text + "'"; //아무것도 선택안하면 진행을 선택해준다.

            string State_Select = " SELECT  * FROM  EETGW_JobReport_EBoard";
            string State_where = " WHERE gcode=@gcode and  pdate between ";
            State_where += "'" + cmbYearS.Text + "' and '" + cmbYearE.Text + "' AND (ISNULL(uid, '')) LIKE @username ";

            if (chkDelay.Checked)
            {
                var 시작일 = DateTime.Now.AddDays(-int.Parse(tbSd.Text));  //일반기간
                var 시작일2 = DateTime.Now.AddDays(-int.Parse(tbSD2.Text));    //외주기간
                State_where += string.Format("and isnull(수리완료일,'') = '' and ((isnull(분류,'') like '%외주%' and pdate <= '{0}') or (isnull(분류,'') not like '%외주%' and pdate <= '{1}'))", 시작일2.ToShortDateString(), 시작일.ToShortDateString());
                tbSd.BackColor = Color.Gold;
                tbSD2.BackColor = Color.Gold;
            }
            else
            {
                tbSd.BackColor = Color.WhiteSmoke;
                tbSD2.BackColor = Color.WhiteSmoke;
            }

            //if (cmbCate.SelectedIndex > 0) State_where += " AND isnull(분류,'') = '" + cmbCate.Text + "'";
            //if (cmbProcess.SelectedIndex > 0) State_where += " and isnull(Process,'') = '" + cmbProcess.Text.Trim() + "'";
            string State_order = " ORDER BY pdate desc,uid";

            string request = "%";

            if (tbRequest.Text.Trim() != "") request = "%" + this.tbRequest.Text.Trim() + "%";

            System.Data.SqlClient.SqlCommand selCmd = new System.Data.SqlClient.SqlCommand();
            selCmd.Connection = ta.Connection;
            selCmd.CommandText = State_Select + State_where + State_order;
            selCmd.Parameters.Add("gcode", SqlDbType.VarChar).Value = FCOMMON.info.Login.gcode;
            selCmd.Parameters.Add("username", SqlDbType.VarChar);
            selCmd.Parameters["username"].Value = request;

            System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter();
            sda.SelectCommand = selCmd;

            this.dsMSSQL.EETGW_JobReport_EBoard.Clear();
            sda.Fill(this.dsMSSQL.EETGW_JobReport_EBoard);

            //this.ta.Adapter.SelectCommand = selCmd;
            //this.ta.Fill(this.dsMSSQL.Projects, state,request);
            //  this.ta.Adapter.SelectCommand.CommandText = orgQuery;
            this.dsMSSQL.EETGW_JobReport_EBoard.AcceptChanges();

            sbSumReduction.Text = this.dsMSSQL.EETGW_JobReport_EBoard.Sum(t => t.OPrice).ToString("N2");
            sbSumO.Text = this.dsMSSQL.EETGW_JobReport_EBoard.Sum(t => t.RepairCost).ToString("N2");
            sbSumRepair.Text = this.dsMSSQL.EETGW_JobReport_EBoard.Sum(t => t.CostReduction).ToString("N2");

            FormattingData();
            FPUtil.ColSizeLoad(ref this.fpSpread1, fn_fpcolsize);
            this.bs.Sort = "pdate desc,idx";
        }

        void FormattingData()
        {
            //삭제컬럼인덱스
            this.fpSpread1.SuspendLayout();
            var col_status = this.fpSpread1.ActiveSheet.Columns["status"].Index;
            var col_costreduc = this.fpSpread1.ActiveSheet.Columns["costreduction"].Index;
            var col_refdata = this.fpSpread1.ActiveSheet.Columns["refdata"].Index;
            for (int i = 0; i < this.fpSpread1.ActiveSheet.Rows.Count; i++)
            {
                var state = this.fpSpread1.ActiveSheet.GetValue(i, col_status);
                string stateStr = string.Empty;
                if (state != null) stateStr = state.ToString();

                var vrefdata = this.fpSpread1.ActiveSheet.GetValue(i, col_refdata);
                Boolean refdata = false;
                if (vrefdata != null) refdata = (bool)vrefdata;


                if (stateStr.ToLower().Contains("완료")) this.fpSpread1.ActiveSheet.Rows[i].BackColor = Color.FromArgb(240, 240, 240);
                else if (stateStr.ToLower().Contains("외주")) this.fpSpread1.ActiveSheet.Rows[i].BackColor = Color.LightSteelBlue;
                else
                    this.fpSpread1.ActiveSheet.Rows[i].BackColor = Color.White;
                this.fpSpread1.ActiveSheet.Cells[i, col_costreduc].BackColor = Color.FromArgb(240, 240, 240);

                if(refdata)
                {
                    this.fpSpread1.ActiveSheet.Rows[i].ForeColor = Color.Magenta;
                }
                else
                {
                    this.fpSpread1.ActiveSheet.Rows[i].ForeColor = Color.Black;
                }
            }
            FPUtil.ColSizeLoad(ref this.fpSpread1, fn_fpcolsize);
            this.fpSpread1.ResumeLayout();
        }

        void funcSave(Boolean pmt)
        {
            this.Validate();
            this.bs.EndEdit();

            if (pmt)
            {
                var dlg = FCOMMON.Util.MsgQ("변경 사항을 저장하시겠습니까?");
                if (dlg != System.Windows.Forms.DialogResult.Yes) return;
            }

            try
            {
                this.ta.Update(this.dsMSSQL.EETGW_JobReport_EBoard);
                dsMSSQL.AcceptChanges();
                FPUtil.ColSizeLoad(ref this.fpSpread1, fn_fpcolsize);
            }
            catch (Exception ex)
            {
                FCOMMON.Util.MsgE(ex.Message);
            }
            FormattingData();
        }

        private void projectsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            funcSave(true);

        }
        void Projects_TableNewRow(object sender, DataTableNewRowEventArgs e)
        {
            e.Row["gcode"] = FCOMMON.info.Login.gcode;
            e.Row["wuid"] = FCOMMON.info.Login.no;
            e.Row["wdate"] = DateTime.Now;
        }


        void menu_partlist()
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.ProjectsRow;
            var f = new fPartList(dr.idx);
            f.StartPosition = FormStartPosition.CenterScreen;
            f.Show();
        }


        private void autoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.fpSpread1.ActiveSheet.DataAutoSizeColumns = true;

            for (int i = 0; i < this.fpSpread1.ActiveSheet.Rows.Count; i++)
                this.fpSpread1.ActiveSheet.SetRowHeight(i, 25);
            //dv1.AutoResizeColumns();
        }

        private void resetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (FarPoint.Win.Spread.Column col in this.fpSpread1.ActiveSheet.Columns)
            {
                col.ResetVisible();
                col.Width = 100;
            }
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FPUtil.ColsizeSave(this.fpSpread1, fn_fpcolsize);
        }

        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FPUtil.ColSizeLoad(ref this.fpSpread1, fn_fpcolsize);
        }


        private void toolStripLabel3_Click(object sender, EventArgs e)
        {
            //사용자목록처리
            if (tbRequest.Text != "")
            {
                tbRequest.Text = string.Empty;
            }
            else tbRequest.Text = FCOMMON.info.Login.nameK;

            refreshData();
        }


        void funcCopy()
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.EETGW_JobReport_EBoardRow;
            var dlg = FCOMMON.Util.MsgQ("선택된 데이터를 복사하시겠습니까?");
            if (dlg == System.Windows.Forms.DialogResult.Yes)
            {
                var newdr = this.dsMSSQL.EETGW_JobReport_EBoard.NewEETGW_JobReport_EBoardRow();
                //컬럼을 모두 돌아서 해당 값을 모두 복사한다.
                foreach (DataColumn dc in dsMSSQL.EETGW_JobReport_EBoard.Columns)
                {
                    if (dc.ColumnName.ToLower() == "idx") continue;
                    newdr[dc.ColumnName] = dr[dc.ColumnName];   //값을 모두 복사한다.
                }
                newdr.pdate = DateTime.Now.ToShortDateString();  //등록일을 오늘로한다
                newdr.수리완료일 = string.Empty;
                newdr.EndEdit();

                var f = new fEboardData(newdr);
                f.Show();
                f.FormClosed += (s1, e1) =>
                {
                    if (f.DialogResult == System.Windows.Forms.DialogResult.OK)
                    {
                        this.dsMSSQL.EETGW_JobReport_EBoard.AddEETGW_JobReport_EBoardRow(newdr);
                    }
                    else newdr.Delete();
                    this.Validate();
                    this.bs.EndEdit();
                    this.bs.Position = 0;
                };
            }
        }

        void menu_iomap()
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.ProjectsRow;
            var f = new fProjectIOMap(dr.idx);
            f.Show();
        }


        private void tbFind_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btFind.PerformClick();
        }

        private void btFind_Click(object sender, EventArgs e)
        {

            string search = tbFind.Text.Trim();
            if (search == "")
            {

                bs.Filter = "";
                tbFind.BackColor = SystemColors.Control;
                FormattingData();
            }
            else
            {
                try
                {
                    var cols = new string[] {
                        "Process","Equipment","Model","BoardName",
                        "원인","결과","외주업체","BoardVender",
                        "uid","요청자","SN"};
                    bs.Filter = FCOMMON.Util.MakeFilterString(cols, search);
                    tbFind.BackColor = Color.Lime;
                    tbFind.SelectAll();
                    tbFind.Focus();
                    FormattingData();
                }
                catch (Exception ex)
                {
                    bs.Filter = "";
                    FCOMMON.Util.MsgE(ex.Message);
                    tbFind.BackColor = Color.Red;
                    FormattingData();
                }
            }
        }

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

                //일반사용자는 바로 저장되도록 함
                int curLevel = Math.Max(FCOMMON.info.Login.level, FCOMMON.DBM.getAuth(FCOMMON.DBM.eAuthType.project));
                if (curLevel < 5)
                {
                    funcSave(false); //자동저장
                }
            }
        }
        private void 엑셀파일로저장ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sd = new SaveFileDialog();
            sd.Filter = ("excel|*.xlsx");
            var dlg = sd.ShowDialog();
            if (dlg == System.Windows.Forms.DialogResult.OK)
            {
                var book = new libxl.XmlBook();
                book.setKey("Amkor Technology", "windows-242f240302c3e50d6cb1686ba2q4k0o9");
                var fn = System.IO.Path.Combine(FCOMMON.Util.CurrentPath, "EBoardDailyform.xlsx");
                System.IO.File.Copy(fn, sd.FileName, true);
                book.load(sd.FileName);

                //week 기록
                var lastrow = dsMSSQL.EETGW_JobReport_EBoard.FirstOrDefault();
                if(lastrow != null)
                {
                    var ww = ISO8601.Calender.GetWorkWeek(DateTime.Parse( lastrow.pdate));
                    var sht1 = book.getSheet(2);
                    sht1.writeNum(1, 0, ww);
                }
                

                var sht = book.getSheet(0);
                //2번쨰 줄부터 데이터를 기록한다.
                var row = 1;
                foreach (dsPRJ.EETGW_JobReport_EBoardRow dr in this.dsMSSQL.EETGW_JobReport_EBoard.Select(this.bs.Filter, this.bs.Sort))
                {
                    if (dr.RowState == DataRowState.Detached || dr.RowState == DataRowState.Deleted) continue;
                    sht.writeStr(row, 3, dr.요청자);
                    sht.writeStr(row, 4, dr.pdate);
                    sht.writeStr(row, 5, dr.수리완료일);
                    sht.writeStr(row, 8, dr.분류);

                    sht.writeStr(row, 9, dr.Line);
                    sht.writeStr(row, 10, dr.Division);
                    sht.writeStr(row, 12, dr.Process);
                    sht.writeStr(row, 13, dr.Model);
                    sht.writeStr(row, 14, dr.BoardName);
                    sht.writeStr(row, 15, dr.BoardVender);
                    sht.writeStr(row, 16, dr.원인 + ":" + dr.결과);
                    sht.writeStr(row, 17, dr.SN);
                    sht.writeNum(row, 18, dr.QTY);
                    sht.writeNum(row, 19, (double)dr.NPrice);
                    sht.writeNum(row, 21, (double)dr.RepairCost);
                    sht.writeStr(row, 23, dr.외주업체.isEmpty() ? "자체" : "외주");
                    sht.writeStr(row, 24, dr.외주업체);
                    sht.writeNum(row, 25, dr.RepairTime);
                    sht.writeStr(row, 27, dr.uid);

                    row += 1;
                }
                var maxrow = sht.lastRow();
                for (int r = row; r <= maxrow; r++)
                {
                    sht.writeBlank(r, 3, sht.cellFormat(row, 3));//, String.Empty);
                    sht.writeBlank(r, 4, sht.cellFormat(row, 4));//, string.Empty);
                    sht.writeBlank(r, 5, sht.cellFormat(row, 5));//, dr.수리완료일);
                    sht.writeBlank(r, 8, sht.cellFormat(row, 8));//, dr.분류);
                    sht.writeBlank(r, 9, sht.cellFormat(row, 9));//, dr.Line);
                    sht.writeBlank(r, 10, sht.cellFormat(row, 10));//, dr.Division);
                    sht.writeBlank(r, 12, sht.cellFormat(row, 11));//, dr.Process);
                    sht.writeBlank(r, 13, sht.cellFormat(row, 12));//, dr.Model);
                    sht.writeBlank(r, 14, sht.cellFormat(row, 13));//, dr.BoardName);
                    sht.writeBlank(r, 15, sht.cellFormat(row, 14));//, dr.BoardVender);
                    sht.writeBlank(r, 16, sht.cellFormat(row, 15));//, dr.원인 + ":" + dr.결과);
                    sht.writeBlank(r, 17, sht.cellFormat(row, 16));//, dr.SN);
                    sht.writeBlank(r, 18, sht.cellFormat(row, 17));//, dr.QTY);
                    sht.writeBlank(r, 19, sht.cellFormat(row, 18));//, (double)dr.NPrice);
                    sht.writeBlank(r, 21, sht.cellFormat(row, 20));//, (double)dr.RepairCost);
                    sht.writeBlank(r, 23, sht.cellFormat(row, 22));//, dr.외주업체.isEmpty() ? "자체" : "외주");
                    sht.writeBlank(r, 24, sht.cellFormat(row, 23));//, dr.외주업체);
                    sht.writeBlank(r, 25, sht.cellFormat(row, 24));//, dr.RepairTime);
                    sht.writeBlank(r, 27, sht.cellFormat(row, 26));//, dr.uid);
                }

                //this.fpSpread1.SaveExcel(sd.FileName,
                //    FarPoint.Excel.ExcelSaveFlags.SaveAsViewed
                //    | FarPoint.Excel.ExcelSaveFlags.SaveAsFiltered
                //    | FarPoint.Excel.ExcelSaveFlags.NoFormulas
                //    | FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders);

                //var cols = new List<string>();
                //cols.Add("Mon");
                //cols.Add("수리완료");
                //cols.Add("Site");
                //cols.Add("Request");
                //cols.Add("입고일");
                //cols.Add("수리완료");
                //cols.Add("완료월");
                book.save(sd.FileName);
                var dlg2 = FCOMMON.Util.MsgQ("파일생성 완료\n\n열까요?" + sd.FileName);
                if (dlg2 == DialogResult.Yes) FCOMMON.Util.RunExplorer(sd.FileName);
            }
        }


        private void bs_CurrentChanged(object sender, EventArgs e)
        {
            //히스토리 데이터를 업데이트하고 첫번재 자료를 표시한다.
            var drv = this.bs.Current as DataRowView;
            if (drv == null)
            {
                // this.label1.Text = "프로젝트가 선택되지 않았습니다";
                return;
            }
            var dr = drv.Row as dsPRJ.EETGW_JobReport_EBoardRow;
            // this.label1.Text = string.Format("[{0}] {1}", dr.BoardName, dr.memo);

        }


        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            FuncAdd();
        }
        void FuncAdd()
        {
            var newdr = this.dsMSSQL.EETGW_JobReport_EBoard.NewEETGW_JobReport_EBoardRow();
            newdr.wuid = FCOMMON.info.Login.no;
            newdr.wdate = DateTime.Now;
            newdr.pdate = DateTime.Now.ToString("yyyy-MM-dd");
            newdr.수리완료일 = string.Empty;
            newdr.uid = FCOMMON.info.Login.nameK;
            newdr.gcode = FCOMMON.info.Login.gcode;
            newdr.Site = "ATK";
            //this.dsMSSQL.EETGW_JobReport_EBoard.AddEETGW_JobReport_EBoardRow(newdr);
            //this.bs.Position = this.bs.Count - 1;

            var f = new fEboardData(newdr);
            f.Show();
            f.FormClosed += (s1, e1) =>
            {
                if (f.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    this.dsMSSQL.EETGW_JobReport_EBoard.AddEETGW_JobReport_EBoardRow(newdr);
                }
                else newdr.Delete();
                this.Validate();
                this.bs.EndEdit();
            };
        }

        private void btEdit_Click(object sender, EventArgs e)
        {
            funcEdit();
        }
        void funcEdit()
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.EETGW_JobReport_EBoardRow;
            var f = new fEboardData(dr);
            f.Show();
            f.FormClosed += (s1, e1) =>
            {
                if (f.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    this.Validate();
                    this.bs.EndEdit();
                }
            };

        }

        private void 편집ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FuncAdd();
        }

        private void tbRequest_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btSearch.PerformClick();
        }


        private void 삭제ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            funcDelete();
        }


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

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

        private void fpSpread1_CellClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e)
        {

        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            var f = new fEBoardImport();
            f.ShowDialog();
            this.refreshData();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            //
        }

        private void btCopy_Click(object sender, EventArgs e)
        {
            funcCopy();
        }

        private void 복사ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            funcCopy();
        }

        private void 편집ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            funcEdit();
        }

        private void toolStripButton2_Click_1(object sender, EventArgs e)
        {
            var f = new EBoard.fEBoardReport();
            f.Show();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            var newdr = this.dsMSSQL.EETGW_JobReport_EBoard.NewEETGW_JobReport_EBoardRow();
            newdr.uid = FCOMMON.info.Login.nameK;
            newdr.wuid = FCOMMON.info.Login.no;
            newdr.wdate = DateTime.Now;
            newdr.gcode = FCOMMON.info.Login.gcode;
            newdr.pdate = DateTime.Now.ToShortDateString();
            newdr.Site = "ATK";
            this.dsMSSQL.EETGW_JobReport_EBoard.AddEETGW_JobReport_EBoardRow(newdr);
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            this.chkDelay.BackColor = chkDelay.Checked ? Color.Lime : SystemColors.Control;
            this.refreshData();
        }

        private void toolStripButton4_Click_1(object sender, EventArgs e)
        {
            var dt = DateTime.Parse(this.cmbYearS.Text);
            var f = new FCOMMON.fSelectDay(dt);
            if (f.ShowDialog() == DialogResult.OK)
            {
                this.cmbYearS.Text = f.dtPick.SelectionStart.ToShortDateString();
            }
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            var dt = DateTime.Parse(this.cmbYearE.Text);
            var f = new FCOMMON.fSelectDay(dt);
            if (f.ShowDialog() == DialogResult.OK)
            {
                this.cmbYearE.Text = f.dtPick.SelectionStart.ToShortDateString();
            }
        }

        private void btOpenFolder_Click(object sender, EventArgs e)
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.EETGW_JobReport_EBoardRow;
            if (dr != null && (dr.RowState == DataRowState.Modified || dr.RowState == DataRowState.Unchanged))
            {
                Util.openEboarditemPath(dr.idx);
            }
            else FCOMMON.Util.MsgE("자료가 저장되기 전에는 폴더를 확인할 수 없습니다.\r\n자료를 저장한 후 다시 시도하세요");
        }
    }
}