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
{
    public partial class fProjectPartListEdit : FCOMMON.fBase
    {
        dsPRJ.ProjectPartStatusRow dr;
        public fProjectPartListEdit(dsPRJ.ProjectPartStatusRow dr_)
        {
            InitializeComponent();
            this.UseFormSetting = false;
            this.dr = dr_;
            this.bs.DataSource = this.dr;
        }

        private void fProjectData_Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            //ta.FillByIdx(this.dsPRJ.ProjectPartStatus, FCOMMON.info.Login.gcode, this.dr);
            memoTextBox.Text = memoTextBox.Text.Trim();
            itemSupplyTextBox.Text = itemSupplyTextBox.Text.Trim();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            //공백제거 210121
            memoTextBox.Text = memoTextBox.Text.Trim();
            itemSupplyTextBox.Text = itemSupplyTextBox.Text.Trim();

            this.Validate();
            this.bs.EndEdit();

            //var cnt = this.ta.Update(this.dsPRJ.ProjectPartStatus);
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            //this.tableAdapterManager.UpdateAll(this.dsPRJ);
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var f = new FCOMMON.fSelectDay(DateTime.Now);
            if (f.ShowDialog() == DialogResult.OK)
            {
                var sd = f.dtPick.SelectionStart;
                var dlg = FCOMMON.Util.MsgQ(string.Format("CR# Due Date 값을 변경 할까요?\n" +
                    "변경전 : {0} -> 변경후 : {1}", textBox2.Text, sd.ToString("yyyy-MM-dd")));
                if (dlg == DialogResult.Yes)
                {
                    var taprj = new dsPRJTableAdapters.ProjectsTableAdapter();
                    var cnt = taprj.UpdateCRDue(sd.ToString("yyyy-MM-dd"), int.Parse(projectTextBox.Text), FCOMMON.info.Login.gcode);
                    if(cnt != 1)
                    {
                        FCOMMON.Util.MsgE($"적용실패 {cnt}건의 자료가 업데이트 됨");
                    }
                }

            }
        }
    }
}
