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 FPJ0000.JobReport_
{
    public partial class rJobReportPrjSche : fBase
    {
        Boolean binit = false;
        public rJobReportPrjSche()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
        }

        private void rJobReport_Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();

            var myCI = new System.Globalization.CultureInfo("ko-KR");
            var myCal = myCI.Calendar;
            var myCWR = myCI.DateTimeFormat.CalendarWeekRule;
            DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;
            var dat = myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW);
            tbWW.Tag = dat;
            tbWW.Text = $"ww{dat:00}";


            this.tbProcess.Items.Clear();
            tbProcess.Items.Add("--전체--");
         //   var taProcess = new dsReportTableAdapters.ProcessListTableAdapter();
            var dtProcessList = FCOMMON.DBM.GroupUserProcessList();// taProcess.GetData(FCOMMON.info.Login.gcode);
            foreach (var dr in dtProcessList)
                tbProcess.Items.Add(dr);

            //this.tbProcess.Text = FCOMMON.info.Login.process;
            tbProcess.SelectedIndex = 0;
            tbProcess.Enabled = false;
            //사용자 목록을 선택한다
            UpdateUserList();

            var curLevel = Math.Max(FCOMMON.info.Login.level, FCOMMON.DBM.getAuth(FCOMMON.DBM.eAuthType.jobreport));
            if(curLevel < 5)
            {
                tbProcess.Enabled = false;
                cmbUser.Enabled = false;
            }

            refrehData();
            binit = true;
        }
        void UpdateUserList()
        {
            var ta = new dsPRJTableAdapters.vJobReportForUserListTableAdapter();

            cmbUser.Items.Clear();
            cmbUser.Items.Add("--전체--"); ;
            //일반사용자 목록 가져온다
            dsPRJ.vJobReportForUserListDataTable userlist;

            if (tbProcess.SelectedIndex <= 0)
            {
                //공정구분없이 전체사용자를 가져온다
                userlist = ta.GetData(FCOMMON.info.Login.gcode, "%");
                //  db.vJobReportForUser.Where(t => t.gcode == FCOMMON.info.Login.gcode).OrderBy(t => t.name).GroupBy(t => t.name);
            }
            else
            {
                userlist = ta.GetData(FCOMMON.info.Login.gcode, tbProcess.Text);
                //db.vJobReportForUser.Where(t => t.gcode == FCOMMON.info.Login.gcode && t.userProcess == tbProcess.Text).OrderBy(t => t.name).GroupBy(t => t.name);
            }

            //if (tbProcess.SelectedIndex != 0) userlist = userlist.Where(t => t.processs == tbProcess.Text); //해당 공정의 인원만 처리한다

            uids = new List<string>();
            names = new List<string>();
            foreach (var dr in userlist)
            {
                //var dr = item.First();
                cmbUser.Items.Add(String.Format("[{0}] {1}", dr.id.Trim(), dr.name.Trim()));
                uids.Add(dr.id.Trim());
                names.Add(dr.name.Trim());
            }

            //if (tbProcess.SelectedIndex > 0)
            cmbUser.Text = string.Format("[{0}] {1}", FCOMMON.info.Login.no, FCOMMON.info.Login.nameK);

            if (cmbUser.SelectedIndex < 0 && cmbUser.Items.Count > 0) cmbUser.SelectedIndex = 0;  //기본전체로 선택해준다.
        }

        List<string> uids, names;

        void refrehData()
        {

            //근문일수,시간
            // var vSD = dts.Value.ToString("yyyy-MM-dd");
            //var vED = dte.Value.ToString("yyyy-MM-dd");
            var curww = int.Parse(DateTime.Now.ToString("yy") + "00") + int.Parse(tbWW.Tag.ToString());

            string prcname = tbProcess.SelectedIndex < 1 ? "%" : tbProcess.Text.Trim();
            var taH = new dsReportTableAdapters.UserScheduleTableTableAdapter();

            var username = cmbUser.Text.Trim();
            var userfilter = "%";
            var uid = string.Empty;
            if (cmbUser.SelectedIndex > 0)
            {
                uid = username.Substring(1, username.IndexOf("]") - 1);// "395552";
                userfilter = cmbUser.SelectedIndex == 0 ? "%" : "%" + uid + "%";
            }

            taH.Fill(this.dsReport.UserScheduleTable, FCOMMON.info.Login.gcode, userfilter);

            //담당자별로 데이터를 쪼개야한다 230209
            var dtnew = new dsReport.UserScheduleTableDataTable();
            foreach (dsReport.UserScheduleTableRow dr in dsReport.UserScheduleTable)
            {
                var userlist = dr.uid.Replace(",", "/").Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                var namelist = dr.uidname.Replace(",", "/").Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < userlist.Length; i++)
                {
                    var userid = userlist[i].Trim();
                    if (uid.isEmpty() == false && uid.Equals(userid) == false) continue;
                    var usernm = userid;
                    if (userlist.Length == namelist.Length) usernm = namelist[i].Trim();

                    //없는 사용자 제외
                    if (uids.Contains(userid) == false && names.Contains(usernm) == false) continue;

                    //모든 컬럼의 데이터를 쓴다 단 idx는 제외한다
                    var newdr = dtnew.NewUserScheduleTableRow();
                    newdr.idx = dtnew.Rows.Count;
                    newdr.uid = userid.Trim();
                    newdr.uidname = usernm.Trim();
                    foreach (DataColumn dc in dtnew.Columns)
                    {
                        var colname = dc.ColumnName.ToLower();
                        if (colname.Equals("idx")) continue;
                        if (colname.Equals("uid")) continue;
                        if (colname.Equals("uidname")) continue;
                        newdr[colname] = dr[colname];
                    }
                    newdr.userprocess = newdr.userprocess.Trim();
                    dtnew.AddUserScheduleTableRow(newdr);
                }
            }

            //this.reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            //this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
            //this.reportViewer1.RefreshReport();

            //그리드뷰 생성
            fp1.ActiveSheet.RowCount = 0;
            fp1.ActiveSheet.Columns.Clear();


            var wekklist = new string[] { "일", "월", "화", "수", "목", "금", "토" };


            var colidx = 0;
            fp1.ActiveSheet.Columns.Add(colidx, 1); fp1.ActiveSheet.Columns[colidx++].Label = "공정";
            fp1.ActiveSheet.Columns.Add(colidx, 1); fp1.ActiveSheet.Columns[colidx++].Label = "담당자";
            fp1.ActiveSheet.Columns.Add(colidx, 1); fp1.ActiveSheet.Columns[colidx++].Label = "사번";
            fp1.ActiveSheet.Columns.Add(colidx, 1); fp1.ActiveSheet.Columns[colidx++].Label = "상태";
            fp1.ActiveSheet.Columns.Add(colidx, 1); fp1.ActiveSheet.Columns[colidx++].Label = "프로젝트";
            fp1.ActiveSheet.Columns.Add(colidx, 1); fp1.ActiveSheet.Columns[colidx++].Label = "시작";
            fp1.ActiveSheet.Columns.Add(colidx, 1); fp1.ActiveSheet.Columns[colidx++].Label = "만료";
            //dv1.Columns.Add("dvcu_hrs", "시간");

            //오늘의WW추가
            //var myCI = new System.Globalization.CultureInfo("ko-KR");
            //var myCal = myCI.Calendar;
            //var myCWR = myCI.DateTimeFormat.CalendarWeekRule;
            //DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;
            //var dat = myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW);
            //var curwwstr = (DateTime.Now.Year - 2000).ToString() + dat.ToString("00");


            //ww컬럼생성
            List<int> wwlist = new List<int>();
            wwlist.Add(curww);
            int ww = 0;
            foreach (dsReport.UserScheduleTableRow dr in dtnew)
            {
                if (dr.sw.Equals("00-00") == false)
                {
                    ww = int.Parse(dr.sw.Replace("-", ""));
                    if (wwlist.Contains(ww) == false) wwlist.Add(ww);
                }
                if (dr.ew.Equals("00-00") == false)
                {
                    ww = int.Parse(dr.ew.Replace("-", ""));
                    if (wwlist.Contains(ww) == false) wwlist.Add(ww);
                }
                if (dr.swa.Equals("00-00") == false)
                {
                    ww = int.Parse(dr.swa.Replace("-", ""));
                    if (wwlist.Contains(ww) == false) wwlist.Add(ww);
                }
                if (dr.ewa.Equals("00-00") == false)
                {
                    ww = int.Parse(dr.ewa.Replace("-", ""));
                    if (wwlist.Contains(ww) == false) wwlist.Add(ww);
                }

            }

            //var wwlist = dsReport.UserScheduleTable.GroupBy(t => t.ww).Select(t => int.Parse(t.Key)).OrderBy(t => t).ToList();
            var wwfont = new Font("Consolas", 8f);

            var curyystr = DateTime.Now.ToString("yy");
            foreach (var item in wwlist.OrderBy(t => t))
            {
                var wwname = item.ToString("0000");
                var yy1 = wwname.Substring(0, 2);
                var ww1 = wwname.Substring(2);


                fp1.ActiveSheet.Columns.Add(colidx, 1);

                fp1.ActiveSheet.Columns[colidx].Tag = item;
                if (item == curww)   //이번주라면?
                {
                    fp1.ActiveSheet.Columns[colidx].Label = $"(ww{ww1:00})";
                    fp1.ActiveSheet.Columns[colidx].BackColor = Color.LightSlateGray;
                }
                else
                {
                    if (curyystr.Equals(yy1))
                        fp1.ActiveSheet.Columns[colidx].Label = $"ww{ww1:00}";  //같은년도
                    else
                        fp1.ActiveSheet.Columns[colidx].Label = $"ww{ww1:00}\ny{yy1}";  //다른년도
                }
                colidx += 1;
            }

            //사용자별로 그룹을 먼저 짓는다
            var ridx = 0;
            var gidx = 0;

            if (radioButton1.Checked)
            {
                //var grp_prc = dtnew.GroupBy(t => t.userprocess).OrderBy(t => t.Key);
                //foreach (var prc in grp_prc)
                {
                    gidx += 1;
                    var grp_user = dtnew.GroupBy(t => t.uid).OrderBy(t => t.Key);
                    foreach (var user in grp_user)
                    {
                        //프로젝트별로 데이터를 표시한다.
                        var grp_list = user.GroupBy(t => t.name).OrderBy(t => t.Key);
                        foreach (var grp in grp_list)
                        {
                            var prjname = grp.Key;
                            var sdate = grp.Max(t => t.sdate);
                            var ddate = grp.Max(t => t.ddate);
                            var uname = grp.Max(t => t.uidname);
                            var status = grp.Max(t => t.status);
                            var processName = grp.Max(t => t.userprocess);
                            //string[] columns = new string[dv1.ColumnCount];

                            //var row = 0;
                            //columns[row++] = grp.Max(t => t.idx).ToString();
                            //columns[row++] = prjname;
                            //columns[row++] = sdate;
                            //columns[row++] = ddate;


                            var cidx = 0;
                            fp1.ActiveSheet.RowCount += 1;//.AddRows(ridx, 1);

                            var ctdef = new FarPoint.Win.Spread.CellType.TextCellType();
                            ctdef.WordWrap = true;
                            ctdef.Multiline = true;

                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = $"{processName}";


                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = $"{uname}";
                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = $"{user.Key}";

                            if (status.Equals("진행"))
                            {
                                fp1.ActiveSheet.Cells[ridx, cidx].BackColor = Color.White;
                                fp1.ActiveSheet.Cells[ridx, cidx + 1].BackColor = Color.White;
                            }
                            else if (status.Equals("검토"))
                            {
                                fp1.ActiveSheet.Cells[ridx, cidx].BackColor = Color.SkyBlue;
                                fp1.ActiveSheet.Cells[ridx, cidx + 1].BackColor = Color.SkyBlue;
                            }


                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = status;// grp.Max(t => t.idx);
                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = prjname;
                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = sdate;
                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = ddate;



                            //세부항목데이터를 넣는다
                            foreach (var dr in grp)
                            {
                                //예측일
                                var sw = dr.sw;
                                if (sw.Equals("00-00")) continue;
                                var ew = dr.ew;
                                if (ew.Equals("00-00")) continue;

                                var isw = int.Parse(sw.Replace("-", ""));
                                var iew = int.Parse(ew.Replace("-", ""));
                                bool first = true;
                                int startcol = -1;
                                int endcol = -1;
                                for (int i = 4; i < fp1.ActiveSheet.ColumnCount; i++)
                                {
                                    var col = fp1.ActiveSheet.Columns[i];
                                    if (col.Tag == null) continue;
                                    var colno = int.Parse(col.Tag.ToString());
                                    if (colno >= isw && colno <= iew)
                                    {
                                        // columns[i] = "O";

                                        if (dr.complete || dr.progress > 99)
                                            fp1.ActiveSheet.Cells[ridx, i].BackColor = Color.Lime;
                                        else if (dr.progress < 50)
                                            fp1.ActiveSheet.Cells[ridx, i].BackColor = Color.Tomato;
                                        else
                                            fp1.ActiveSheet.Cells[ridx, i].BackColor = Color.Gold;

                                        if (first)
                                        {
                                            fp1.ActiveSheet.Cells[ridx, i].Value = dr.title + "\n" + dr.progress.ToString("N0") + "%";
                                            fp1.ActiveSheet.Cells[ridx, i].Note = dr.title + "\n" + dr.progress.ToString("N0") + "%";
                                            first = false;
                                            startcol = i;
                                        }
                                        else
                                        {
                                            endcol = i;
                                        }
                                    }

                                    fp1.ActiveSheet.Cells[ridx, i].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
                                    fp1.ActiveSheet.Cells[ridx, i].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
                                    fp1.ActiveSheet.Cells[ridx, i].Font = new Font("맑은 고딕", 7);
                                    fp1.ActiveSheet.Cells[ridx, i].CellType = ctdef;
                                }
                                if (startcol != -1 && endcol != -1)
                                {
                                    fp1.ActiveSheet.AddSpanCell(ridx, startcol, 1, (endcol - startcol + 1));
                                    //    fp1.ActiveSheet.Cells[ridx, startcol].CellType = ctdef;

                                }

                            }
                            // dv1.Rows.Add(columns);
                            ridx += 1;
                        }
                    }

                }
            }
            else
            {
                //프로젝트 담당자
                var grp_prj = dtnew.GroupBy(t => t.name).OrderBy(t => t.Key);
                foreach (var prj in grp_prj)
                {
                    var grp_user = prj.GroupBy(t => t.uid).OrderBy(t => t.Key);
                    foreach (var user in grp_user)
                    {
                        //프로젝트별로 데이터를 표시한다.
                        var grp_prc = user.GroupBy(t => t.userprocess).OrderBy(t => t.Key);
                        foreach (var prc in grp_prc)
                        {
                            var prjname = prc.Key;
                            var sdate = prc.Max(t => t.sdate);
                            var ddate = prc.Max(t => t.ddate);
                            var uname = prc.Max(t => t.uidname);
                            var status = prc.Max(t => t.status);
                            //string[] columns = new string[dv1.ColumnCount];

                            //var row = 0;
                            //columns[row++] = grp.Max(t => t.idx).ToString();
                            //columns[row++] = prjname;
                            //columns[row++] = sdate;
                            //columns[row++] = ddate;


                            var cidx = 0;
                            fp1.ActiveSheet.RowCount += 1;//.AddRows(ridx, 1);

                            var ctdef = new FarPoint.Win.Spread.CellType.TextCellType();
                            ctdef.WordWrap = true;
                            ctdef.Multiline = true;

                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = prc.Key;


                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = uname;
                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = user.Key;

                            if (status.Equals("진행"))
                            {
                                fp1.ActiveSheet.Cells[ridx, cidx].BackColor = Color.White;
                                fp1.ActiveSheet.Cells[ridx, cidx + 1].BackColor = Color.White;
                            }
                            else if (status.Equals("검토"))
                            {
                                fp1.ActiveSheet.Cells[ridx, cidx].BackColor = Color.SkyBlue;
                                fp1.ActiveSheet.Cells[ridx, cidx + 1].BackColor = Color.SkyBlue;
                            }


                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = status;// grp.Max(t => t.idx);
                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = prj.Key;
                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = sdate;
                            fp1.ActiveSheet.Cells[ridx, cidx].CellType = ctdef; fp1.ActiveSheet.Cells[ridx, cidx].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; fp1.ActiveSheet.Cells[ridx, cidx++].Value = ddate;



                            //세부항목데이터를 넣는다
                            foreach (var dr in prc)
                            {
                                //예측일
                                var sw = dr.sw;
                                if (sw.Equals("00-00")) continue;
                                var ew = dr.ew;
                                if (ew.Equals("00-00")) continue;

                                var isw = int.Parse(sw.Replace("-", ""));
                                var iew = int.Parse(ew.Replace("-", ""));
                                bool first = true;
                                int startcol = -1;
                                int endcol = -1;
                                for (int i = 4; i < fp1.ActiveSheet.ColumnCount; i++)
                                {
                                    var col = fp1.ActiveSheet.Columns[i];
                                    if (col.Tag == null) continue;
                                    var colno = int.Parse(col.Tag.ToString());
                                    if (colno >= isw && colno <= iew)
                                    {
                                        // columns[i] = "O";

                                        if (dr.complete || dr.progress > 99)
                                            fp1.ActiveSheet.Cells[ridx, i].BackColor = Color.Lime;
                                        else if (dr.progress < 50)
                                            fp1.ActiveSheet.Cells[ridx, i].BackColor = Color.Tomato;
                                        else
                                            fp1.ActiveSheet.Cells[ridx, i].BackColor = Color.Gold;

                                        if (first)
                                        {
                                            fp1.ActiveSheet.Cells[ridx, i].Value = dr.title + "\n" + dr.progress.ToString("N0") + "%";
                                            fp1.ActiveSheet.Cells[ridx, i].Note = dr.title + "\n" + dr.progress.ToString("N0") + "%";
                                            first = false;
                                            startcol = i;
                                        }
                                        else
                                        {
                                            endcol = i;
                                        }
                                    }

                                    fp1.ActiveSheet.Cells[ridx, i].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
                                    fp1.ActiveSheet.Cells[ridx, i].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
                                    fp1.ActiveSheet.Cells[ridx, i].Font = new Font("맑은 고딕", 7);
                                    fp1.ActiveSheet.Cells[ridx, i].CellType = ctdef;
                                }
                                if (startcol != -1 && endcol != -1)
                                {
                                    fp1.ActiveSheet.AddSpanCell(ridx, startcol, 1, (endcol - startcol + 1));
                                    //    fp1.ActiveSheet.Cells[ridx, startcol].CellType = ctdef;

                                }

                            }
                            // dv1.Rows.Add(columns);
                            ridx += 1;
                        }
                    }

                }
            }

            fp1.ActiveSheet.FrozenColumnCount = 7;
            fp1.ActiveSheet.AllowNoteEdit = true;
            fp1.ActiveSheet.AutoUpdateNotes = true;
            for (int i = 0; i < fp1.ActiveSheet.RowCount; i++)
            {
                fp1.ActiveSheet.Rows[i].Height = 40;
            }

            fp1.ActiveSheet.Columns[0].Width = 90;
            fp1.ActiveSheet.Columns[1].Width = 50;
            fp1.ActiveSheet.Columns[2].Width = 50;
            fp1.ActiveSheet.Columns[3].Width = 35;
            fp1.ActiveSheet.Columns[4].Width = 250;
            fp1.ActiveSheet.Columns[5].Width = 75;
            fp1.ActiveSheet.Columns[6].Width = 75;


            return;
        }

        private void btSave_Click(object sender, EventArgs e)
        {
            //dv1.ExportData(string.Empty);
            var sd = new SaveFileDialog();
            sd.Filter = "excel file|*.xlsx";
            if (sd.ShowDialog() != DialogResult.OK) return;
            fp1.SaveExcel(sd.FileName);

            if (FCOMMON.Util.MsgQ("저장된 파일을 열까요?") == DialogResult.Yes)
                FCOMMON.Util.RunExplorer(sd.FileName);
        }

        private void btRefresh_Click(object sender, EventArgs e)
        {
            refrehData();
        }

        private void tbProcess_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (binit == false) return;
            UpdateUserList();
        }


        private void cmbUser_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (binit == false) return;
            refrehData();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
    }
}
