using CasunCommon.BaseUI;
using Pms.UserEvent.Model;
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 PMSUI.UI.库位状态显示
{
    public partial class FrmShowWareHouseStatus : CasunForm
    {
        public FrmShowWareHouseStatus()
        {
            InitializeComponent();
        }

        private void findData()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append($" SELECT ");
            sb.Append($" * ");
            sb.Append($" from ");
            sb.Append($" UpStation");
            DataTable dt = ConDataBase.reDt(sb.ToString());
            if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int StationSelect = int.Parse(dt.Rows[i]["StationSelect"].ToString());
                    switch (StationSelect)
                    {
                        case 1:
                            {
                                string StationNum = dt.Rows[i]["StationNum"].ToString();
                                int StationValue = int.Parse(dt.Rows[i]["StationValue"].ToString());
                                switch (StationValue)
                                {
                                    case 0:
                                        {
                                            btn_Up1.Text = StationNum;
                                            btn_Up1.BackColor = Color.Red;
                                            break;
                                        }
                                    case 1:
                                        {
                                            btn_Up1.Text = StationNum;
                                            btn_Up1.BackColor = Color.Green;
                                            break;
                                        }
                                }
                                break;
                            }
                        case 2:
                            {
                                string StationNum = dt.Rows[i]["StationNum"].ToString();
                                int StationValue = int.Parse(dt.Rows[i]["StationValue"].ToString());
                                switch (StationValue)
                                {
                                    case 0:
                                        {
                                            btn_Up2.Text = StationNum;
                                            btn_Up2.BackColor = Color.Red;
                                            break;
                                        }
                                    case 1:
                                        {
                                            btn_Up2.Text = StationNum;
                                            btn_Up2.BackColor = Color.Green;
                                            break;
                                        }
                                }
                                break;
                            }
                    }
                }
            }
        }

        private void FrmShowWareHouseStatus_Load(object sender, EventArgs e)
        {
            findData();
        }

        private void btn_Up1_Click(object sender, EventArgs e)
        {
            EditWareHouseMsg sd = new EditWareHouseMsg();
            sd.StationNum = btn_Up1.Text.Trim();
            sd.ShowDialog();
            findData();
        }

        private void btn_Up2_Click(object sender, EventArgs e)
        {
            EditWareHouseMsg sd = new EditWareHouseMsg();
            sd.StationNum = btn_Up2.Text.Trim();
            sd.ShowDialog();
            findData();
        }

        private void FrmShowWareHouseStatus_Activated(object sender, EventArgs e)
        {
            findData();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            findData();
        }
    }
}
