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 FBS0000
{
    public partial class WorkTable : FCOMMON.fBase
    {
        public WorkTable()
        {
            InitializeComponent();
            Properties.Settings.Default["gwcs"] = FCOMMON.info.CS;

            var sd = DateTime.Now.ToString("yyyy-MM-01");
            var ed = DateTime.Parse(sd).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");//  DateTime.Now.AddMonths(1).ToString("yyyy-MM-01")).AddDays(-1).ToString("yyyy-MM-dd");

            tbSD.Text = sd;
            tbED.Text = ed;
            tbGrp.Text = string.Empty;
            //this.dv1.CellFormatting += dv1_CellFormatting;
        }


        private void __Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            //일반사용자의경우에는 상태를 변경하지 못한다.
            int curLevel = Math.Max(FCOMMON.info.Login.level, FCOMMON.DBM.getAuth(FCOMMON.DBM.eAuthType.holyday));
            if (curLevel >= 5)
            {
                //권한이 잇으므로 모든 사용자로 한다.
            }
            else
            {
                // this.cmbUser.Enabled = false;   //사용자를 고칠수 없게 한다.
            }

            RefreshData();
        }

        void RefreshData()
        {
            fpSpread1_Sheet1.Rows.Count = 0;


            //열제목
            var cols = new List<string>();
            cols.AddRange(new string[] { "분류", "사번", "직급", "성명" });

            var coltag = new List<DateTime>();
            var initdate = new DateTime(1982, 11, 23);
            coltag.AddRange(new DateTime[] { initdate, initdate, initdate, initdate });

            var sd = DateTime.Parse(tbSD.Text);
            var ed = DateTime.Parse(tbED.Text);
            var idx = 0; ;
            while (true)
            {
                var curDate = sd.AddDays(idx++);
                cols.Add(curDate.Day.ToString("00") + "\r\n" + curDate.DayOfWeek.ToString().Substring(0, 3));
                coltag.Add(curDate);

                if (curDate.ToString("yyyy-MM-dd") == ed.ToString("yyyy-MM-dd")) break;
            }
            cols.AddRange(new string[] { $"발생\n~{sd.AddDays(-1).ToString("MM/dd")}", "사용", $"잔여\n~{ed.ToString("MM/dd")}" });
            coltag.AddRange(new DateTime[] { initdate, initdate, initdate });

            //열제목 설정
            fpSpread1_Sheet1.Columns.Count = cols.Count;
            for (int c = 0; c < cols.Count; c++)
            {
                fpSpread1_Sheet1.Columns[c].Tag = new int[] { 0, 0, 0, 0 };
                fpSpread1_Sheet1.Columns[c].Label = cols[c];
                if (c < 4) fpSpread1_Sheet1.Columns[c].BackColor = Color.WhiteSmoke;
                else if (c > cols.Count - 5) fpSpread1_Sheet1.Columns[c].BackColor = Color.WhiteSmoke;
                else fpSpread1_Sheet1.Columns[c].BackColor = Color.White;
            }

            //업무일지 데이터
            var taJR = new dsMSSQLTableAdapters.vJobReportForUserTableAdapter();
            var JobReport = taJR.GetData(FCOMMON.info.Login.gcode, tbSD.Text, tbED.Text);
            var taHolyList = new dsMSSQLTableAdapters.HolidayLIstTableAdapter();
            var HolyList = taHolyList.GetData(tbSD.Text, tbED.Text);

            //해당 기간내의 사용
            //var taUser = new dsMSSQLTableAdapters.EETGW_WorkTableUserTableAdapter();
            //var dtUser = JobReport.OrderBy(t => t.userProcess + t.name).GroupBy(t => t.id);// taUser.GetData(FCOMMON.info.Login.gcode, tbGrp.Text);

            var dtUser = FCOMMON.DBM.getActiveUserTable(); //업무일지 미사용자로인해서 사용자 목록은 이것을 사용한다 220215
            int curLevel = Math.Max(FCOMMON.info.Login.level, FCOMMON.DBM.getAuth(FCOMMON.DBM.eAuthType.jobreport));
            var users = new List<userinfo>();
            var seq = 0;
            foreach (System.Data.DataRow dr in dtUser.Rows)
            {
                //var dr = item.First();
                //if (string.IsNullOrEmpty(dr.indate) == false)
                //{
                //    //입사일자를 체크해서. 이 날짜가 입사일 이전이면 넘어간다
                //}
                var newuser = new userinfo();


                if (dr["grade"] == null) newuser.grade = string.Empty;
                newuser.grade = dr["grade"].ToString();

                if (dr["name"] == null) newuser.name = string.Empty;
                newuser.name = dr["name"].ToString();

                if (dr["id"] == null) newuser.empno = string.Empty;
                newuser.empno = dr["id"].ToString();

                if (dr["process"] == null) newuser.seq = string.Empty;
                newuser.seq = dr["process"].ToString();

                if (dr["indate"] == null) newuser.indate = string.Empty;
                newuser.indate = dr["indate"].ToString();

                if (dr["outdate"] == null) newuser.outdate = string.Empty;
                newuser.outdate = dr["outdate"].ToString();

                if (curLevel >= 5 || newuser.empno == FCOMMON.info.Login.no)
                {
                    users.Add(newuser);
                    seq += 1;
                }
                    

                
            }

            //휴가테이블에서 데이터를 가져온다
            var taHoly = new dsMSSQLTableAdapters.HolydayTableAdapter();
            var dtHoly = taHoly.GetByDate(FCOMMON.info.Login.gcode, tbSD.Text, tbED.Text);

            var qta = new dsMSSQLTableAdapters.QueriesTableAdapter();



            //사용자 목록을 1번열에 나열한다.
            var rowindex = 0;
            foreach (var item in users)
            {
                fpSpread1_Sheet1.Rows.Count += 1;
                fpSpread1_Sheet1.Cells[rowindex, 0].Value = item.seq;
                fpSpread1_Sheet1.Cells[rowindex, 1].Value = item.empno;
                fpSpread1_Sheet1.Cells[rowindex, 2].Value = item.grade;
                fpSpread1_Sheet1.Cells[rowindex, 3].Value = item.name;

                if (item.empno == "395552")
                {

                }
                //이월잔액
                var jand = qta.WorkUserJan_Yesterday_Day(FCOMMON.info.Login.gcode, item.empno, sd.ToString("yyyy-01-01"), sd.AddDays(-1).ToString("yyyy-MM-dd"), "999999", "%");
                var jan = qta.WorkUserJan_Yesterday_Day(FCOMMON.info.Login.gcode, item.empno, sd.ToString("yyyy-01-01"), ed.ToString("yyyy-MM-dd"), "999999", "%");
                var used = 0.0;

                fpSpread1_Sheet1.Rows[rowindex].ResetBorder();
                fpSpread1_Sheet1.Rows[rowindex].Border = new FarPoint.Win.LineBorder(Color.Gainsboro, 1, false, false, true, true);

                //각 일자별로 특이사항을 찾는다
                int c = 0;
                for (c = 4; c < cols.Count - 3; c++)
                {
                    var ps = (int[])fpSpread1_Sheet1.Columns[c].Tag;



                    var curDate = sd.AddDays(c - 4);
                    var bholy = false;
                    //이날짜가 휴일인지 체크한다.
                    var drHoly = HolyList.Where(t => t.pdate == curDate.ToString("yyyy-MM-dd")).FirstOrDefault();

                    if (drHoly != null && drHoly.free)
                    {

                        bholy = true;
                        //fpSpread1_Sheet1.Cells[rowindex, c].BackColor = Color.LightPink;
                        fpSpread1_Sheet1.Cells[rowindex, c].Tag = drHoly.memo;
                        if (drHoly.memo == "토요일" || drHoly.memo == "일요일")
                        {
                            fpSpread1_Sheet1.Cells[rowindex, c].Note = string.Empty;
                        }
                        else
                        {
                            fpSpread1_Sheet1.Cells[rowindex, c].Note = drHoly.memo;
                        }
                        fpSpread1_Sheet1.Columns[c].BackColor = Color.FromArgb(250, 250, 250);
                    }
                    else
                    {
                        //휴일은 아님

                        fpSpread1_Sheet1.Cells[rowindex, c].Tag = null;
                        fpSpread1_Sheet1.Cells[rowindex, c].Note = string.Empty;
                        fpSpread1_Sheet1.Columns[c].BackColor = Color.White;
                    }

                    //기본으로 데이터를 초기화해준다.
                    fpSpread1_Sheet1.Cells[rowindex, c].Value = string.Empty;


                    //입사일이면 메세지 추가
                    if (item.indate == curDate.ToString("yyyy-MM-dd"))
                        fpSpread1_Sheet1.Cells[rowindex, c].Note += "입사";
                    if (item.outdate == curDate.ToString("yyyy-MM-dd"))
                        fpSpread1_Sheet1.Cells[rowindex, c].Note += "퇴사";

                    //현재인원값
                    var bIndate = DateTime.TryParse(item.indate, out DateTime dtIn);
                    var bOutdate = DateTime.TryParse(item.outdate, out DateTime dtOut);
                    // Boolean usePerson = true;

                    //
                    //if (bIndate == true && curDate.ToString("yyyy-MM-dd").CompareTo(dtIn.ToString("yyyy-MM-dd")) < 0)
                    //    usePerson = false;
                    //if (bOutdate == true && curDate.ToString("yyyy-MM-dd").CompareTo(dtOut.ToString("yyyy-MM-dd")) > 0)
                    //    usePerson = false;

                    ps[3] = bholy ? 1 : 0;
                    ps[2] += 1;

                    //근태기록에 자료가 있는지 확인한다.
                    var dr = dtHoly.Where(t => t.uid == item.empno && (t.term > 0 || t.CrTime > 0) && (t.sdate.ToString("yyyy-MM-dd").CompareTo(curDate.ToString("yyyy-MM-dd")) <= 0 && t.edate.ToString("yyyy-MM-dd").CompareTo(curDate.ToString("yyyy-MM-dd")) >= 0)).FirstOrDefault();
                    if (dr != null && fpSpread1_Sheet1.Cells[rowindex, c].Tag == null)  //휴일이 아니여야 한다
                    {


                        ps[1] += 1;


                        //휴가내역이 있다.
                        if (dr.term > 0)
                            used += 1;

                        //자료가있다.
                        if (string.IsNullOrEmpty(dr.tag) == false)
                        {
                            fpSpread1_Sheet1.Cells[rowindex, c].Value = dr.tag;
                        }
                        else
                        {
                            fpSpread1_Sheet1.Cells[rowindex, c].Value = dr.cate.Substring(0, 2);

                            if (dr.cate == "이월")
                                fpSpread1_Sheet1.Cells[rowindex, c].BackColor = Color.Gold;
                            else if (dr.cate == "경조")
                                fpSpread1_Sheet1.Cells[rowindex, c].BackColor = Color.Pink;
                            else if (dr.cate == "대체")
                                fpSpread1_Sheet1.Cells[rowindex, c].BackColor = Color.Gold;
                            else
                                fpSpread1_Sheet1.Cells[rowindex, c].BackColor = Color.LawnGreen;

                            fpSpread1_Sheet1.Cells[rowindex, c].Tag = "1";
                        }

                        //근태 시작일자가 조회시작일보다 적다면, 데이터가 걸쳐진 것이므로 회색으로 처리하자 2308320
                        if (dr.sdate.ToString("yyyy-MM-dd").CompareTo(sd.ToString("yyyy-MM-dd")) < 0)
                        {
                            fpSpread1_Sheet1.Cells[rowindex, c].BackColor = Color.DimGray;
                            fpSpread1_Sheet1.Cells[rowindex, c].ForeColor = Color.White;
                        }

                        if (string.IsNullOrEmpty(dr.contents) == false)
                        {
                            fpSpread1_Sheet1.Cells[rowindex, c].Note += $"({dr.cate}){dr.contents} 기간:{dr.sdate.ToString("yyyy-MM-dd")}~{dr.edate.ToString("yyyy-MM-dd")}";
                        }
                        else if (dr.sdate.ToString("yyyy-MM-dd") != dr.edate.ToString("yyyy-MM-dd"))
                        {
                            fpSpread1_Sheet1.Cells[rowindex, c].Note += $"({dr.cate}) 기간:{dr.sdate.ToString("yyyy-MM-dd")}~{dr.edate.ToString("yyyy-MM-dd")}";
                        }
                        //else fpSpread1_Sheet1.Cells[rowindex, c].Note = string.Empty;
                    }
                    else
                    {

                        ps[0] += 1;

                        var pdate = curDate.ToString("yyyy-MM-dd");
                        if (pdate == "2022-02-07" && item.empno == "66630")
                        {

                        }
                        var JRUser = JobReport.Where(t => t.id == item.empno && t.pdate == pdate);
                        var sum_hrs = 00.0;
                        var sum_ot = 00.0;//JRUser.Sum(t => t.ot);
                        var sum_ot2 = 00.0; //JRUser.Sum(t => t.ot2);
                        if (JRUser.Any())
                        {
                            sum_hrs = JRUser.Sum(t => t.hrs);
                            sum_ot = JRUser.Sum(t => t.ot);
                            sum_ot2 = JRUser.Sum(t => t.ot2);
                        }

                        if (bholy)   //주말이다
                        {
                            //주말이다.
                            if (sum_ot > 0 || sum_ot2 > 0)
                            {
                                if (sum_ot2 == 0)
                                    fpSpread1_Sheet1.Cells[rowindex, c].Note += $"휴일근무(미승인:{sum_ot}h)";
                                else
                                    fpSpread1_Sheet1.Cells[rowindex, c].Note += $"휴일근무({sum_ot2}h)";
                            }
                            //else
                            //fpSpread1_Sheet1.Cells[rowindex, c].BackColor = Color.White;
                        }
                        else
                        {
                            //평일인데 근무시간이 있다
                            if (sum_hrs > 0 || sum_ot > 0)
                            {
                                if (sum_ot > 0 || sum_ot2 > 0)
                                {
                                    //연장근무를 했다
                                    if (sum_ot2 == 0) fpSpread1_Sheet1.Cells[rowindex, c].Note += $"연장근무(미승인:{sum_ot}h)";
                                    else fpSpread1_Sheet1.Cells[rowindex, c].Note += $"연장근무({sum_ot2}h)";
                                }
                                else
                                {
                                    //평일근무
                                }
                            }
                            else
                            {
                                //근무를 안했다
                                var celltag = fpSpread1_Sheet1.Cells[rowindex, c].Tag;
                                if (celltag == null) //다른곳에서 지정했다면 처리하지 않는다.
                                {
                                    if (DateTime.Now.ToString("yyyy-MM-dd").CompareTo(pdate) > 0)
                                    {
                                        fpSpread1_Sheet1.Cells[rowindex, c].Value = "--";
                                        fpSpread1_Sheet1.Cells[rowindex, c].ForeColor = Color.Red;
                                    }
                                    else
                                    {
                                        fpSpread1_Sheet1.Cells[rowindex, c].Value = string.Empty;
                                        fpSpread1_Sheet1.Cells[rowindex, c].ForeColor = Color.Black;
                                    }


                                    fpSpread1_Sheet1.Cells[rowindex, c].BackColor = Color.White;
                                    //fpSpread1_Sheet1.Cells[rowindex, c].Note = string.Empty;
                                }
                            }
                        }
                    }

                    fpSpread1_Sheet1.Columns[c].Tag = ps;
                }

                used = (float)jand - (float)jan;
                //var jan = jand - used;
                fpSpread1_Sheet1.Cells[rowindex, c++].Value = jand != 0 ? jand.ToString() : string.Empty;
                fpSpread1_Sheet1.Cells[rowindex, c++].Value = used != 0 ? used.ToString() : string.Empty;
                fpSpread1_Sheet1.Cells[rowindex, c++].Value = jan != 0 ? jan.ToString() : string.Empty;

                rowindex += 1;
            } // --users

            //총요약을 넣는다
            fpSpread1_Sheet1.RowCount += 1;
            fpSpread1_Sheet1.RowCount += 1;
            fpSpread1_Sheet1.RowCount += 1;
            fpSpread1_Sheet1.Rows[rowindex + 0].Border = new FarPoint.Win.LineBorder(Color.Gainsboro, 1, false, false, true, true);
            fpSpread1_Sheet1.Rows[rowindex + 1].Border = new FarPoint.Win.LineBorder(Color.Gainsboro, 1, false, false, true, true);
            fpSpread1_Sheet1.Rows[rowindex + 2].Border = new FarPoint.Win.LineBorder(Color.Gainsboro, 1, false, false, true, true);
            //fpSpread1_Sheet1.RowCount += 1;

            fpSpread1_Sheet1.Cells[rowindex + 0, 3].Value = "근무";
            //fpSpread1_Sheet1.Cells[rowindex + 1, 3].Value = "휴가";
            fpSpread1_Sheet1.Cells[rowindex + 1, 3].Value = "근무율(%)";// ps[0].ToString();   //근무율
            fpSpread1_Sheet1.Cells[rowindex + 2, 3].Value = "총원";


            for (var col = 4; col < cols.Count - 3; col++)
            {
                var ps = (int[])fpSpread1_Sheet1.Columns[col].Tag;
                if (ps[3] == 1)
                {
                    fpSpread1_Sheet1.Cells[rowindex + 0, col].Value = "--";
                    fpSpread1_Sheet1.Cells[rowindex + 1, col].Value = "--";
                    fpSpread1_Sheet1.Cells[rowindex + 2, col].Value = "--";
                }
                else
                {
                    var krate = (ps[0] * 1f / ps[2]);
                    var trans = (int)(krate * 254);
                    fpSpread1_Sheet1.Cells[rowindex + 0, col].Value = ps[0].ToString();   //근무
                                                                                          //fpSpread1_Sheet1.Cells[rowindex + 1, col].Value = ps[1].ToString();   //휴가
                    fpSpread1_Sheet1.Cells[rowindex + 1, col].Value = (krate * 100f).ToString("N0");
                    fpSpread1_Sheet1.Cells[rowindex + 1, col].Note = $"근무:{ps[0]}\n휴가:{ps[1]}\n총원:{ps[2]}";


                    fpSpread1_Sheet1.Cells[rowindex + 2, col].Value = ps[2].ToString();   //총원

                    if (krate >= 0.8) fpSpread1_Sheet1.Cells[rowindex + 1, col].BackColor = Color.FromArgb(trans, Color.LightGreen);
                    else if (krate >= 0.6) fpSpread1_Sheet1.Cells[rowindex + 1, col].BackColor = Color.FromArgb(trans, Color.LightSkyBlue);
                    else if (krate >= 0.4) fpSpread1_Sheet1.Cells[rowindex + 1, col].BackColor = Color.FromArgb(trans, Color.HotPink);
                    else fpSpread1_Sheet1.Cells[rowindex + 1, col].BackColor = Color.FromArgb(trans, Color.Tomato);
                }


            }



        }
        private void boardBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            //  this.bs.EndEdit();
            var dlg = FCOMMON.Util.MsgQ("변경된 내용을 저장하시겠습니까?");
            if (dlg != System.Windows.Forms.DialogResult.Yes) return;
            try
            {

            }
            catch (Exception ex)
            {
                FCOMMON.Util.MsgE(ex.Message);
            }
        }

        class userinfo
        {
            public string seq { get; set; }
            public string empno { get; set; }
            public string name { get; set; }
            public string grade { get; set; }

            public string indate { get; set; }
            public string outdate { get; set; }
            public userinfo()
            {

            }
        }

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

        private void tbSD_KeyDown(object sender, KeyEventArgs e)
        {
            var tb = sender as ToolStripTextBox;
            if (e.KeyCode == Keys.Enter)
            {
                string datestring;
                if (FCOMMON.Util.MakeDateString(tb.Text, out datestring))
                {
                    tb.Text = datestring;
                    SendKeys.Send("{TAB}");
                }
            }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            var sd = new SaveFileDialog();
            sd.Filter = "Excel|*.xls";
            sd.FileName = string.Format("Worktable_{0}_{1}", tbSD.Text.Replace("-", ""), tbED.Text.Replace("-", ""));
            if (sd.ShowDialog() != DialogResult.OK) return;
            fpSpread1.SaveExcel(sd.FileName,
                    FarPoint.Excel.ExcelSaveFlags.SaveAsViewed
                    | FarPoint.Excel.ExcelSaveFlags.SaveAsFiltered
                    | FarPoint.Excel.ExcelSaveFlags.NoFormulas
                    | FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders);
        }

        private void lbStt_Click(object sender, EventArgs e)
        {
            var f = new FCOMMON.fSelectMonth();
            if (f.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
            var sdDate = DateTime.Parse(DateTime.Now.ToString("yyyy-") + f.selectmon.ToString() + "-01");
            tbSD.Text = sdDate.ToString("yyyy-MM-dd");
            tbED.Text = sdDate.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
            this.RefreshData();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {

            var FileName = FCOMMON.Util.CurrentPath + string.Format("Worktable_{0}_{1}", tbSD.Text.Replace("-", ""), tbED.Text.Replace("-", "")) + ".xls";
            fpSpread1.SaveExcel(FileName,
                    FarPoint.Excel.ExcelSaveFlags.SaveAsViewed
                    | FarPoint.Excel.ExcelSaveFlags.SaveAsFiltered
                    | FarPoint.Excel.ExcelSaveFlags.NoFormulas
                    | FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders
                    | FarPoint.Excel.ExcelSaveFlags.SaveAlternatingRowStyles
                    | FarPoint.Excel.ExcelSaveFlags.UseDefaultColorPalette
                     );


            Outlook.Application outlookApplication = new Outlook.Application();
            Outlook.MailItem newTask = outlookApplication.CreateItem(OlItemType.olMailItem) as Outlook.MailItem;
            newTask.Subject = tbSD.Text.Substring(0, 7) + "월 출근부";
            //newTask.To = "Chikyun.Kim@amkor.co.kr";
            //newTask.HTMLBody = "<i><b>this is test mail</b></i>";
            newTask.BodyFormat = OlBodyFormat.olFormatHTML;
            newTask.Attachments.Add(FileName);
            newTask.Display();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {

            var sd = DateTime.Parse(DateTime.Parse(tbSD.Text).ToString("yyyy-MM-01"));
            sd = sd.AddMonths(-1);
            var ed = sd.AddMonths(1).AddDays(-1);
            tbSD.Text = sd.ToString("yyyy-MM-dd");
            tbED.Text = ed.ToString("yyyy-MM-dd");
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            var sd = DateTime.Parse(DateTime.Parse(tbSD.Text).ToString("yyyy-MM-01"));
            sd = sd.AddMonths(1);
            var ed = sd.AddMonths(1).AddDays(-1);
            tbSD.Text = sd.ToString("yyyy-MM-dd");
            tbED.Text = ed.ToString("yyyy-MM-dd");
        }

        private void btXls_Click(object sender, EventArgs e)
        {



            SaveFileDialog sd = new SaveFileDialog();
            sd.Filter = "excel|*.xls";
            sd.FileName = "출근부(" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                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);
            }

            if (FCOMMON.Util.MsgQ("파일을 확인 할까요?") != DialogResult.Yes) return;

            FCOMMON.Util.RunExplorer(sd.FileName);
        }
    }
}
