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 fProjectSummary : FCOMMON.fBase
    {
        string fn_fpcolsize = "";
        public fProjectSummary()
        {
            InitializeComponent();
            fn_fpcolsize = util.MakeFilePath(util.CurrentPath, "formSetting", "fp_" + this.Name + ".ini");
            this.dsMSSQL.Projects.TableNewRow += Projects_TableNewRow;
            this.FormClosed += __Closed;

        }

        void __Closed(object sender, FormClosedEventArgs e)
        {

        }

        private void __Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            //프로젝트 목록을 처리함
            this.tbRequest.Text = FCOMMON.info.Login.nameK;
            cmbDateType.SelectedIndex = 0;  //기본시작일 기준으로 한다

            //분류 - 190905
            var dt_cate = FCOMMON.DBM.getCodeTable("20");
            cmbCate.Items.Clear();
            cmbCate.Items.Add("--전체--");
            foreach (DataRow dr in dt_cate.Rows)
                cmbCate.Items.Add(dr["Value"].ToString());
            cmbCate.SelectedIndex = 0;


            this.cmbProcess.Items.Clear();
            this.cmbProcess.Items.Add("전체");
            var procesList = FCOMMON.DBM.getProcessList();
            foreach (DataRow dr in procesList.Rows)
                cmbProcess.Items.Add(dr["Value"].ToString());
            cmbProcess.Text = FCOMMON.info.Login.process;
            if (cmbProcess.SelectedIndex < 0) cmbProcess.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"));
                cmbYearE.Items.Add(i.ToString("0000"));
            }
            //this.cmbYearS.Text = DateTime.Now.AddYears(-2).Year.ToString("0000");
            //this.cmbYearE.Text = DateTime.Now.Year.ToString("0000");
            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; //목록에서 저장버튼은 제거한다.
            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()
        {

            string state = "";

            {
                state = "[status] in (";

                //if (chk진행.Checked)
                {
                    if (state.EndsWith("(") == false) state += ",";
                    state += "'진행'";
                }

                // if (chk완료.Checked)
                {
                    if (state.EndsWith("(") == false) state += ",";
                    state += "'완료'";
                }
                //if (chk완료보고.Checked)
                {
                    if (state.EndsWith("(") == false) state += ",";
                    state += "'완료(보고)'";
                }
                state += ")";
            }


            string State_Select = " SELECT  [idx],[pidx],[gcode],[isdel],[status],[asset],[level],[rev],[process],[part],[pdate],[name],[userManager],[usermain],[usersub],[userhw2],[reqstaff],[costo],[costn],[cnt],[remark_req],[remark_ans],[sdate],[ddate],[edate],[odate],[progress],[memo],[wuid],[wdate],[orderno],[crdue],[import],[path],[userprocess],[bCost],[bFanOut],[div],dbo.getScheduleProgress(idx) as ProgressPrj, dbo.getLastHistory(idx) AS lasthistory,'' AS wws, '' AS wwo, '' AS wwe, '' AS wwd,model,serial FROM Projects";
            string State_where = " WHERE gcode=@gcode and isnull(div,'') <> 'EB' and ";

            State_where += " (ISNULL(userManager, '') LIKE @username OR " +
             "ISNULL(usermain, '') LIKE @username OR " +
             "ISNULL(reqstaff, '') LIKE @username OR " +
             "ISNULL(usersub, '') LIKE @username) ";

            if (state != "") State_where += " AND " + state;
            if (cmbCate.SelectedIndex > 0) State_where += " AND isnull(category,'') = '" + cmbCate.Text + "'";
            if (cmbProcess.SelectedIndex > 0) State_where += " and isnull(userprocess,'') = '" + cmbProcess.Text.Trim() + "'";
            string State_order = " ORDER BY (CASE " +
                " WHEN ([status] = '진행') THEN '0' " +
                " WHEN ([status] = '검토') THEN '1' " +
                " WHEN ([status] = '대기') THEN '2' " +
                " WHEN ([status] = '완료') THEN '3' " +
                " WHEN ([status] = '완료(보고)') THEN '4' " +
                " WHEN ([status] = '보류') THEN '5' " +
                " WHEN ([status] = '취소') THEN '9' " +
                " ELSE '5' END),userManager,sdate";

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

            var SQL = State_Select + State_where + State_order;
            System.Data.SqlClient.SqlCommand selCmd = new System.Data.SqlClient.SqlCommand();
            selCmd.Connection = ta.Connection;
            selCmd.CommandText = "select min(sw),max(ew) from EETGW_ProjectsSchedule where project in (" +
                "SELECT  idx FROM Projects " + State_where + " )";
            selCmd.Parameters.Add("gcode", SqlDbType.VarChar).Value = FCOMMON.info.Login.gcode;
            selCmd.Parameters.Add("username", SqlDbType.VarChar);
            selCmd.Parameters["username"].Value = request;
            if(selCmd.Connection.State == ConnectionState.Closed)
            selCmd.Connection.Open();
            var dar = selCmd.ExecuteReader();
            string min_sw, max_ew;
            while(dar.Read())
            {
                min_sw = dar[0].ToString();
                max_ew = dar[1].ToString();
            }
            dar.Close();

            selCmd.CommandText = SQL;
   

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

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

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

            sbSumE.Text = this.dsMSSQL.Projects.Sum(t => t.coste).ToString("N2");
            sbSumO.Text = this.dsMSSQL.Projects.Sum(t => t.costo).ToString("N2");
            sbSumI.Text = this.dsMSSQL.Projects.Sum(t => t.costn).ToString("N2");

            FormattingData();
            FPUtil.ColSizeLoad(ref this.fpSpread1, fn_fpcolsize);
        }

        void FormattingData()
        {

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

                this.fpSpread1.ActiveSheet.Rows[i].BackColor = Color.White;
                switch (stateStr.ToLower())
                {
                    case "검토":
                        this.fpSpread1.ActiveSheet.Rows[i].ForeColor = Color.Blue;
                        break;
                    case "취소":
                        this.fpSpread1.ActiveSheet.Rows[i].ForeColor = Color.Red;
                        break;
                    case "진행":
                        this.fpSpread1.ActiveSheet.Rows[i].ForeColor = Color.Green;
                        break;
                    case "보류":
                        this.fpSpread1.ActiveSheet.Rows[i].ForeColor = Color.Tomato;
                        break;
                    case "완료(보고)":
                        this.fpSpread1.ActiveSheet.Rows[i].ForeColor = Color.Gray;
                        break;
                    case "완료":
                        this.fpSpread1.ActiveSheet.Rows[i].ForeColor = Color.Magenta;
                        break;
                    default:
                        this.fpSpread1.ActiveSheet.Rows[i].ForeColor = Color.Black;
                        break;
                }

            }
            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.tam.UpdateAll(this.dsMSSQL);
                dsMSSQL.AcceptChanges();
                FPUtil.ColSizeLoad(ref this.fpSpread1, fn_fpcolsize);
            }
            catch (Exception ex)
            {
                FCOMMON.Util.MsgE(ex.Message);
            }
        }

        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;
        }

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

        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 partListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            menu_partlist();
        }


        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 btSearch_Click(object sender, EventArgs e)
        {

        }

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

            refreshData();
        }

        private void scheduleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.ProjectsRow;
            var f = new fProjectSchedule(dr.idx);
            f.MdiParent = this.MdiParent;
            f.Show();
        }

        private void makeRepeatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            funcCopy();
        }
        void funcCopy()
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.ProjectsRow;
            var dlg = FCOMMON.Util.MsgQ("선택된 프로젝트를 복사하시겠습니까?\n\n생성된 자료는 [검토] 상태로 전환 됩니다.");
            if (dlg == System.Windows.Forms.DialogResult.Yes)
            {
                var ta = new dsPRJTableAdapters.QueriesTableAdapter();
                int? newidx = -1;
                var retval = ta.CopyProjectData(dr.idx, FCOMMON.info.Login.no, ref newidx);
                refreshData();
                if (newidx != null)
                {
                    var newdr = this.dsMSSQL.Projects.Where(t => t.idx == newidx).FirstOrDefault();
                    newdr.userprocess = FCOMMON.info.Login.process;
                    var f = new fProjectData(newdr);
                    if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        int curLevel = Math.Max(FCOMMON.info.Login.level, FCOMMON.DBM.getAuth(FCOMMON.DBM.eAuthType.project));
                        if (curLevel < 5)
                        {
                            funcSave(false); //자동저장
                        }
                    }
                }
            }
        }

        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 iOMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            menu_iomap();
        }

        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[] {
                        "name","process","reqstaff","usermain",
                        "orderno","usersub","userManager",
                        "remark_req"};
                    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|*.xls");
            var dlg = sd.ShowDialog();
            if (dlg == System.Windows.Forms.DialogResult.OK)
            {
                this.fpSpread1.SaveExcel(sd.FileName,
                    FarPoint.Excel.ExcelSaveFlags.SaveAsViewed
                    | FarPoint.Excel.ExcelSaveFlags.SaveAsFiltered
                    | FarPoint.Excel.ExcelSaveFlags.NoFormulas
                    | FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders);

                FCOMMON.Util.MsgI("파일생성 완료\n\n" + sd.FileName);
            }
        }

        private void 메일발송주소관리ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.ProjectsRow;
            var f = new fMailList(dr.idx);
            f.ShowDialog();
        }

        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.ProjectsRow;
            this.label1.Text = string.Format("[{0}] {1}", dr.name, dr.memo);

            var sql = "select  ((sum((case when isnull(qtybuy,0) = isnull(qtyin,0) then 1 else 0 end))*1.0) / count(*))*100  from ProjectsPart where project = " + dr.idx.ToString();
            var stR_result = FCOMMON.DBM.ExecuteScalar(sql);
            if (string.IsNullOrEmpty(stR_result))
            {
                tableLayoutPanel3.Visible = false;
            }
            else
            {
                tableLayoutPanel3.Visible = true;
                var perc = float.Parse(stR_result);
                this.label17.Text = string.Format("구매 완료({0:N0}%)", perc);
                this.prb1.ProgressMin = 0;
                this.prb1.ProgressMax = 100;
                this.prb1.ProgressValue = perc;
            }

            try
            {
                taHist.Fill(this.dsMSSQL.ProjectsHistory, dr.idx);
            }
            catch
            {

            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.ProjectsRow;
            var f = new fProejctHistory(dr.idx);
            f.StartPosition = FormStartPosition.CenterScreen;
            var dlg = f.ShowDialog();
            bs_CurrentChanged(sender, e);
        }

        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            var newdr = this.dsMSSQL.Projects.NewProjectsRow();
            newdr.wuid = FCOMMON.info.Login.no;
            newdr.wdate = DateTime.Now;
            newdr.pdate = DateTime.Now.ToString("yyyy-MM-dd");
            newdr.sdate = DateTime.Now.ToString("yyyy-MM-dd");
            newdr.userManager = FCOMMON.info.Login.nameK;
            newdr.progress = 0;
            newdr.userprocess = FCOMMON.info.Login.process;
            newdr.costn = 0;
            newdr.costo = 0;
            newdr.cnt = 1;
            newdr.name = "Project Title";
            var f = new fProjectData(newdr);
            f.StartPosition = FormStartPosition.CenterScreen;
            var dlg = f.ShowDialog();
            if (dlg == System.Windows.Forms.DialogResult.OK)
            {
                this.dsMSSQL.Projects.AddProjectsRow(newdr);
                try
                {

                    ta.Update(newdr);
                }
                catch (Exception ex)
                {
                    FCOMMON.Util.MsgE("Save Error\n" + ex.Message);
                }

            }
            else newdr.Delete();
        }

        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.ProjectsRow;
            var f = new fProjectData(dr);
            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                int curLevel = Math.Max(FCOMMON.info.Login.level, FCOMMON.DBM.getAuth(FCOMMON.DBM.eAuthType.project));
                if (curLevel < 5)
                {
                    funcSave(false); //자동저장
                }
                FormattingData();
            }
        }

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

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


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

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            menu_partlist();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            menu_iomap();
        }

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

        private void 공유폴더ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showfolder();
        }
        void showfolder()
        {
            var drv = this.bs.Current as DataRowView;
            if (drv == null) return;
            var dr = drv.Row as dsPRJ.ProjectsRow;

            var tbPath = dr.path;

            if (tbPath == "") tbPath = "/" + dr.idx.ToString();

            if (tbPath.StartsWith("\\") == false)
            {
                if (tbPath.StartsWith("/")) tbPath = tbPath.Replace("/", "\\");
                else tbPath = "\\" + tbPath;
            }
            //\\10.131.32.29\Data
            var datapath = FCOMMON.DBM.getCodeSvalue("55", "01");
            var serverpath = System.IO.Path.Combine( "Data", "Project");
            if (System.IO.Directory.Exists(serverpath) == false)
            {
                FCOMMON.Util.MsgE("프로젝트 기본경로가 존재하지 않아 진행할 수 없습니다\n\n" +
                    serverpath);
                return;
            }

            var path = serverpath + tbPath;
            if (System.IO.Directory.Exists(path) == false)
            {
                try
                {
                    System.IO.Directory.CreateDirectory(path);

                    string[] subdir = new string[] { "Source", "Document", "Draw", "Estimate" };
                    foreach (var dir in subdir)
                        System.IO.Directory.CreateDirectory(path + "\\" + dir);

                }
                catch (Exception eX)
                {
                    FCOMMON.Util.MsgE("프로젝트 저장소 생성실패\n" + eX.Message);
                    return;
                }
            }

            FCOMMON.Util.RunExplorer(path);
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            showfolder();
        }

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

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

        private void richTextBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void cmbDateType_Click(object sender, EventArgs e)
        {

        }

        private void cmbYearE_Click(object sender, EventArgs e)
        {

        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {

            this.fpSpread2_Sheet1.ColumnCount = 0;
            this.fpSpread2_Sheet1.ColumnHeader.RowCount = 2;
            this.fpSpread2_Sheet1.ClearColumnHeaderSpanCells();

            int idx = 0;

            this.fpSpread2_Sheet1.ColumnCount = 15;
            this.fpSpread2_Sheet1.ColumnHeader.RowCount = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx++).Value = "상태";

            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx++).Value = "완료";

            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx++).Value = "진행\r\n(%)";

            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx++).Value = "요청";

            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).ColumnSpan = 3;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).Value = "협업";
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(1, idx++).Value = "설계";
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(1, idx++).Value = "전장";
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(1, idx++).Value = "프로그램";




            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx++).Value = "프로젝트";

            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 1;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).Value = "일정";

            var wwmin = 30;
            var wwmax = 31;
            var wwspan = wwmax - wwmin + 1;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).ColumnSpan = wwspan;
            for (int ww = wwmin; ww <= wwmax; ww++)
                this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(1, idx++).Value = $"{ww}";

            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).Value = "대수";


            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx++).Value = "Original\r\n($K)";

            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).StyleName = " ";
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx++).Value = "Input\r\n($K)";

            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx++).Value = "Effect\r\n($K)";

            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx).RowSpan = 2;
            this.fpSpread2_Sheet1.ColumnHeader.Cells.Get(0, idx++).Value = "비고";






        }
    }
}