using FarPoint.Win.Spread;
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.Threading.Tasks;
using System.Windows.Forms;

namespace FCM0000
{
    public partial class fSIDListSelect : fBase
    {
        public string selectbatch = "";
        public fSIDListSelect(string sid,DataTable dt)
        {
            InitializeComponent();
            this.bs.DataSource = dt;
            this.dv1.DataSource = this.bs;
            this.bs.Sort = "quantity desc";
            this.Text = $"SPM/NR 검색 결과 SID:{sid}";
            this.KeyPreview = true;
            this.KeyDown += (s1, e1) => {
                if (e1.KeyCode == Keys.Escape) this.Close();
            };
            this.Width += 150;
            this.dv1.Tag = sid;
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            DBM.InsertLog("SIDCHK", this.Text);
            var drv = this.bs.Current as DataRowView;
            var dr = drv.Row as DataRow;
            var v_vatch = dr["batch_no"];
            if (v_vatch != null) selectbatch = v_vatch.ToString();
            else selectbatch = "";

            DialogResult = DialogResult.OK;
        }

        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {

        }

        private void fSIDListSelect_Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            this.dv1.AutoResizeColumns();
        }
      

        private void btopenspm_Click(object sender, EventArgs e)
        {
            var drv = this.bs.Current as DataRowView;
            var dr = drv.Row as DataRow;
            var sid = this.dv1.Tag.ToString();

            var url = @"https://atknet.amkor.co.kr/#/department/ee/spm";
            FCOMMON.Util.RunExplorer(url);
        }
    }
}
