using Models;
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 ProductionControl
{
    public partial class FrmShowSizeTag : Form
    {
        Order mOrder;
        public FrmShowSizeTag(Order order)
        {
            InitializeComponent();
            mOrder = order;
            #region dataGridView设置
            dataGridView1.AutoGenerateColumns = false;//自动创建列
            dataGridView1.AllowUserToAddRows = dataGridView1.AllowUserToDeleteRows = false;//用户添加删除行
            dataGridView1.AllowUserToResizeRows = false;//用户调整行大小
                                                        //dataGridView1.AllowUserToResizeColumns = false;//用户调整列大小
                                                        //显示行号与列宽度自动调整
            dataGridView1.RowHeadersVisible = true;
            dataGridView1.RowHeadersWidth = 50;
            dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;//数据量过百绑定太变
            dataGridView1.RowPostPaint += (sender, e) =>//序号列头
            {
                Utils.Util.showRowNum_onDataGrid_RowPostPaint(this.dataGridView1, sender, e);
            };
            dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            for (int i = 0; i < dataGridView1.Columns.Count; i++)//禁止点击列头排序 
                dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;

            //行列交叉处标题
            //if (dataGridView1.RowHeadersVisible) dataGridView1.TopLeftHeaderCell.Value = "SPH/CYL";
            #endregion
        }
        private void reLoadData()
        {
            if (mOrder == null || mOrder.SizeTagDataList == null)
            {
                this.dataGridView1.DataSource = null;
                return;
            };
            //int pageNum = 1;
            //int pageSize = 10;
            //int totalPage = 1;
            //var list = service.GetListNav(pageNum, pageSize, ref totalPage, null);
            var list = mOrder.SizeTagDataList;
            this.dataGridView1.DataSource = new BindingSource(list, null);
        }

        private void FrmShowSizeTag_Load(object sender, EventArgs e)
        {
            try
            {
                reLoadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void tsbtnRefesh_Click(object sender, EventArgs e)
        {
            try
            {
                reLoadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
