码迷,mamicode.com
首页 > 其他好文 > 详细

精轧跟踪

时间:2018-08-05 18:04:46      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:cep   where   不执行   pre   dialog   source   err   raw   draw   

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;
using Function;
using System.Threading;

namespace 大型二级系统.MATERIAL_Tracking
{
    public partial class CP1_Furnace : Form

    {
        public static string Material=string.Empty;
        public static string REASON_DESC = string.Empty;
        public static int value = 1;
        public static List<string> list = new List<string>();
        public static Dictionary<string, string> Heat = new Dictionary<string, string>();
        AutoSizeFormClass asc = new AutoSizeFormClass();
        public CP1_Furnace()
        {
            InitializeComponent();
        }
        string PTR_PO_ID = "";//定义用于存储批号的公用字符串
        string PTR_MATERIAL_ID = "";//定义用于存储跟踪号的公用字符串
        string STATUS = "";//定义用于存储批号状态的公用字符串
        string PTR_MATERIAL_ID_AUTO = "";//定义用于存储自动跟踪的跟踪号公用字符串
        //string PTR_PO_ID_AUTO = "";//定义用于存储自动跟踪的批号公用字符串
        int PTR_PRODUCT_ID = 0;//用于定义存储PRODUCT_ID的公用字符串



        private void CP1_Furnace_Load(object sender, EventArgs e)
        {
            asc.ControlAutoSize(this);
            this.WindowState = FormWindowState.Maximized;
            DB.ConInit();

            PO_comboBox.SelectedItem = -1;
            ScrapReason_comboBox.SelectedItem = -1;
            string sql = "select REASON_DESC from MAIN.CAT_SCRAP_REASON";
            DB.ComboBox_Binding(sql,ScrapReason_comboBox, "REASON_DESC", "reason");

        }


        private void Exit_button_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("确定退出画面吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.Yes)
            {
                this.Close();
            }
            else
            {
                return;
            }
        }
        #region 窗口自适应
        private void CP1_Furnace_SizeChanged(object sender, EventArgs e)
        {
            asc.ControlAutoSize(this);
        }
        #endregion

        private void timer_Furnace_Tick(object sender, EventArgs e)
        {
            timer_Furnace.Enabled = false;
            try
            {
                #region 冷上料台架
                //冷上料台架显示
                //dataGridView_ChargingGrid.Rows.Clear();
                string selStr_CGBZ = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘CGBZ‘ order by MATERIAL_ID desc";
                DB.DataGridView_Binding(selStr_CGBZ, dataGridView_ChargingGrid, "MAIN.MATERIAL");
                dataGridView_ChargingGrid.ClearSelection();//清除选中
                int PTR_CGBZ_NUM = dataGridView_ChargingGrid.Rows.Count;
                if (PTR_CGBZ_NUM == 0)
                {
                    ChargingGradeNUM_textBox.Text = "";
                }
                else
                {
                    ChargingGradeNUM_textBox.Text = Convert.ToString(PTR_CGBZ_NUM);
                }

                //给冷上料台架跟踪号赋值底色
                string selStr_CGBZ_color = "select MATERIAL_ID,PTR_MATERIAL_COLOR_ID,INFO from MAIN.MATERIAL where ZONE_NAME=‘CGBZ‘ order by MATERIAL_ID desc";
                string table_CGBZ_color = "table_CGBZ_color";
                DB.selectData(selStr_CGBZ_color, table_CGBZ_color);

                int CGBZ_rowNum = DB.Ds.Tables[table_CGBZ_color].Rows.Count;

                if (CGBZ_rowNum == 0)
                {
                    //return;
                }
                else
                {
                    PTR_MATERIAL_ID_AUTO = DB.Ds.Tables[table_CGBZ_color].Rows[0][0].ToString();
                    for (int i = 0; i < CGBZ_rowNum; i++)
                    {
                        string PTR_CGBZ_color = DB.Ds.Tables[table_CGBZ_color].Rows[i][1].ToString();
                        string PTR_CGBZ_info = DB.Ds.Tables[table_CGBZ_color].Rows[i][2].ToString();

                        if (PTR_CGBZ_info != "")
                        {
                            dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Red;
                        }
                        else
                        {
                            switch (PTR_CGBZ_color)
                            {
                                case "1":
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.BackColor = Color.Green;
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Green;
                                    break;
                                case "2":
                                    
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.BackColor = Color.Orange;
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Orange;
                                    break;
                                case "3":
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.BackColor = Color.SpringGreen;
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.SelectionBackColor = Color.SpringGreen;
                                    break;
                                case "4":
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Yellow;
                                    break;
                                case "5":
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.BackColor = Color.MediumOrchid;
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.SelectionBackColor = Color.MediumOrchid;
                                    break;
                                case "6":
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.BackColor = Color.SkyBlue;
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.SelectionBackColor = Color.SkyBlue;
                                    break;
                                case "7":
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.BackColor = Color.Olive;
                                    dataGridView_ChargingGrid.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Olive;
                                    break;

                            }
                        }
                    }
                }
                try
                {
                    PTR_PO_ID = PO_comboBox.SelectedValue.ToString();
                    string selStr_PO_num = "select NUM_PLANNED,NUM_ASSIGNED,STATUS from MAIN.PO_PLANNED where PO_ID=‘";
                    selStr_PO_num += PTR_PO_ID;
                    selStr_PO_num += "";
                    string table_PO_num = "table_PO_num";
                    DB.selectData(selStr_PO_num, table_PO_num);
                    PlanNum_textBox.Text = DB.Ds.Tables[table_PO_num].Rows[0][0].ToString();
                    AssignNum_textBox.Text = DB.Ds.Tables[table_PO_num].Rows[0][1].ToString();
                    STATUS = DB.Ds.Tables[table_PO_num].Rows[0][2].ToString();

                    if (STATUS == "RELEASED")
                    {
                        PO_ACT_textBox.Text = "0";
                    }
                    else
                    {
                        PTR_PO_ID = PO_comboBox.SelectedValue.ToString();
                        string selStr_MATERIAL_ID = "select MATERIAL_ID from MAIN.MATERIAL where PO_ID=‘";
                        selStr_MATERIAL_ID += PTR_PO_ID + "";
                        selStr_MATERIAL_ID += "and ZONE_NAME!=" + "‘SLAB‘";
                        selStr_MATERIAL_ID += "order by MATERIAL_ID desc";
                        string table_MATERIAL_ID = "table_MATERIAL_ID";
                        DB.selectData(selStr_MATERIAL_ID, table_MATERIAL_ID);
                        string PTR_MATERIAL_ID_1 = DB.Ds.Tables[table_MATERIAL_ID].Rows[0][0].ToString();
                        string Size = PTR_MATERIAL_ID_1.Substring(PTR_MATERIAL_ID_1.Length - 1);
                        if (Size == "H")
                        {
                            string PO_NUM_TO_1 = PTR_MATERIAL_ID_1.Substring(8, 3);
                            string PO_NUM_TO = Convert.ToString(Convert.ToInt32(PO_NUM_TO_1));

                            PO_ACT_textBox.Text = PO_NUM_TO;
                        }
                        else
                        {
                            string PO_NUM_TO_1 = PTR_MATERIAL_ID_1.Substring(PTR_MATERIAL_ID_1.Length - 4);
                            string PO_NUM_TO = Convert.ToString(Convert.ToInt32(PO_NUM_TO_1));

                            PO_ACT_textBox.Text = PO_NUM_TO;
                        }
                    }

                }
#pragma warning disable CS0168 // 声明了变量“EX”,但从未使用过
                catch (Exception EX)
#pragma warning restore CS0168 // 声明了变量“EX”,但从未使用过
                {

                }
                finally
                {

                }

                #endregion

                #region 加热炉入炉辊道
                //加热炉入炉辊道显示
                string selStr_RHEZ = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHEZ‘  ";
                DB.DataGridView_Binding(selStr_RHEZ, dataGridView_EntryRoll, "MAIN.MATERIAL");
                dataGridView_EntryRoll.ClearSelection();//清除选中


                //给入炉辊道跟踪号赋值底色
                string selStr_RHEZ_color = "select MATERIAL_ID,PTR_MATERIAL_COLOR_ID,INFO from MAIN.MATERIAL where ZONE_NAME=‘RHEZ‘";
                string table_RHEZ_color = "table_RHEZ_color";
                DB.selectData(selStr_RHEZ_color, table_RHEZ_color);
                int RHEZ_num = DB.Ds.Tables[table_RHEZ_color].Rows.Count;
                if (RHEZ_num == 0)
                {
                    //return;
                }
                else
                {
                    string PTR_RHEZ_color = DB.Ds.Tables[table_RHEZ_color].Rows[0][1].ToString();
                    string PTR_RHEZ_info = DB.Ds.Tables[table_RHEZ_color].Rows[0][2].ToString();

                    if (PTR_RHEZ_info != "")
                    {
                        dataGridView_EntryRoll.Rows[0].DefaultCellStyle.BackColor = Color.Red;
                        dataGridView_EntryRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Red;
                    }
                    else
                    {
                        switch (PTR_RHEZ_color)
                        {
                            case "1":
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.BackColor = Color.Green;
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Green;
                                break;
                            case "2":
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.BackColor = Color.Orange;
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Orange;
                                break;
                            case "3":
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.BackColor = Color.SpringGreen;
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.SpringGreen;
                                break;
                            case "4":
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.BackColor = Color.Yellow;
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Yellow;
                                break;
                            case "5":
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.BackColor = Color.MediumOrchid;
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.MediumOrchid;
                                break;
                            case "6":
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.BackColor = Color.SkyBlue;
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.SkyBlue;
                                break;
                            case "7":
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.BackColor = Color.Olive;
                                dataGridView_EntryRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Olive;
                                break;

                        }
                    }
                }
                #endregion

                #region 加热炉
                //加热炉显示
                string selStr_RHFZ = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHFZ‘ order by MATERIAL_ID asc";
                DB.DataGridView_Binding(selStr_RHFZ, dataGridView_Furnace, "MAIN.MATERIAL");
                dataGridView_Furnace.ClearSelection();//清除选中
                int PTR_RHFZ_NUM = dataGridView_Furnace.Rows.Count;
                if (PTR_RHFZ_NUM == 0)
                {
                    FurnaceNUM_textBox.Text = "";
                }
                else
                {
                    FurnaceNUM_textBox.Text = Convert.ToString(PTR_RHFZ_NUM);
                }

                //给加热炉跟踪号赋值底色
                string selStr_RHFZ_color = "select MATERIAL_ID,PTR_MATERIAL_COLOR_ID,INFO from MAIN.MATERIAL where ZONE_NAME=‘RHFZ‘ order by MATERIAL_ID asc";
                string table_RHFZ_color = "table_RHFZ_color";
                DB.selectData(selStr_RHFZ_color, table_RHFZ_color);
                int RHFZ_rowNum = DB.Ds.Tables[table_RHFZ_color].Rows.Count;
                if (RHFZ_rowNum == 0)
                {
                    //return;
                }
                else
                {
                    for (int i = 0; i < RHFZ_rowNum; i++)
                    {
                        string PTR_RHFZ_color = DB.Ds.Tables[table_RHFZ_color].Rows[i][1].ToString();
                        string PTR_RHFZ_info = DB.Ds.Tables[table_RHFZ_color].Rows[i][2].ToString();

                        if (PTR_RHFZ_info != "")
                        {
                            dataGridView_Furnace.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                            dataGridView_Furnace.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Red;
                        }
                        else
                        {
                            switch (PTR_RHFZ_color)
                            {
                                case "1":
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.BackColor = Color.Green;
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Green;
                                    break;
                                case "2":
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.BackColor = Color.Orange;
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Orange;
                                    break;
                                case "3":
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.BackColor = Color.SpringGreen;
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.SelectionBackColor = Color.SpringGreen;
                                    break;
                                case "4":
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Yellow;
                                    break;
                                case "5":
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.BackColor = Color.MediumOrchid;
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.SelectionBackColor = Color.MediumOrchid;
                                    break;
                                case "6":
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.BackColor = Color.SkyBlue;
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.SelectionBackColor = Color.SkyBlue;
                                    break;
                                case "7":
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.BackColor = Color.Olive;
                                    dataGridView_Furnace.Rows[i].DefaultCellStyle.SelectionBackColor = Color.Olive;
                                    break;

                            }
                        }
                    }
                }
                #endregion

                #region 加热炉出炉辊道
                //加热炉出炉辊道显示
                string selStr_RHDZ = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHDZ‘";
                DB.DataGridView_Binding(selStr_RHDZ, dataGridView_ExitRoll, "MAIN.MATERIAL");
                dataGridView_ExitRoll.ClearSelection();//清除选中
                                                       //string selStr_RHEZ_WGT = "select ";

                //给出炉辊道跟踪号赋值底色
                string selStr_RHDZ_color = "select MATERIAL_ID,PTR_MATERIAL_COLOR_ID,INFO from MAIN.MATERIAL where ZONE_NAME=‘RHDZ‘";
                string table_RHDZ_color = "table_RHDZ_color";
                DB.selectData(selStr_RHDZ_color, table_RHDZ_color);
                int RHDZ_num = DB.Ds.Tables[table_RHDZ_color].Rows.Count;
                if (RHDZ_num == 0)
                {
                    ExitNUM_textBox.Text = "";
                }
                else
                {
                    string PTR_RHDZ_color = DB.Ds.Tables[table_RHDZ_color].Rows[0][1].ToString();
                    string PTR_RHDZ_info = DB.Ds.Tables[table_RHDZ_color].Rows[0][2].ToString();
                    ExitNUM_textBox.Text = "1";

                    if (PTR_RHDZ_info != "")
                    {
                        dataGridView_ExitRoll.Rows[0].DefaultCellStyle.BackColor = Color.Red;
                        dataGridView_ExitRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Red;
                    }
                    else
                    {
                        switch (PTR_RHDZ_color)
                        {
                            case "1":
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.BackColor = Color.Green;
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Green;
                                break;
                            case "2":
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.BackColor = Color.Orange;
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Orange;
                                break;
                            case "3":
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.BackColor = Color.SpringGreen;
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.SpringGreen;
                                break;
                            case "4":
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.BackColor = Color.Yellow;
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Yellow;
                                break;
                            case "5":
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.BackColor = Color.MediumOrchid;
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.MediumOrchid;
                                break;
                            case "6":
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.BackColor = Color.SkyBlue;
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.SkyBlue;
                                break;
                            case "7":
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.BackColor = Color.Olive;
                                dataGridView_ExitRoll.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Olive;
                                break;

                        }
                    }
                }
                #endregion

                #region 高压水除鳞
                //高压水除鳞显示
                string selStr_DESC = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘DESC‘";
                DB.DataGridView_Binding(selStr_DESC, dataGridView_Desc, "MAIN.MATERIAL");
                dataGridView_Desc.ClearSelection();//清除选中


                //给高压水除鳞跟踪号赋值底色
                string selStr_DESC_color = "select MATERIAL_ID,PTR_MATERIAL_COLOR_ID,INFO from MAIN.MATERIAL where ZONE_NAME=‘DESC‘";
                string table_DESC_color = "table_DESC_color";
                DB.selectData(selStr_DESC_color, table_DESC_color);
                int DESC_num = DB.Ds.Tables[table_DESC_color].Rows.Count;
                if (DESC_num == 0)
                {
                    //return;
                }
                else
                {
                    string PTR_DESC_color = DB.Ds.Tables[table_DESC_color].Rows[0][1].ToString();
                    string PTR_DESC_info = DB.Ds.Tables[table_DESC_color].Rows[0][2].ToString();

                    if (PTR_DESC_info != "")
                    {
                        dataGridView_Desc.Rows[0].DefaultCellStyle.BackColor = Color.Red;
                        dataGridView_Desc.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Red;
                    }
                    else
                    {
                        switch (PTR_DESC_color)
                        {
                            case "1":
                                dataGridView_Desc.Rows[0].DefaultCellStyle.BackColor = Color.Green;
                                dataGridView_Desc.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Green;
                                break;
                            case "2":
                                dataGridView_Desc.Rows[0].DefaultCellStyle.BackColor = Color.Orange;
                                dataGridView_Desc.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Orange;
                                break;
                            case "3":
                                dataGridView_Desc.Rows[0].DefaultCellStyle.BackColor = Color.SpringGreen;
                                dataGridView_Desc.Rows[0].DefaultCellStyle.SelectionBackColor = Color.SpringGreen;
                                break;
                            case "4":
                                dataGridView_Desc.Rows[0].DefaultCellStyle.BackColor = Color.Yellow;
                                dataGridView_Desc.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Yellow;
                                break;
                            case "5":
                                dataGridView_Desc.Rows[0].DefaultCellStyle.BackColor = Color.MediumOrchid;
                                dataGridView_Desc.Rows[0].DefaultCellStyle.SelectionBackColor = Color.MediumOrchid;
                                break;
                            case "6":
                                dataGridView_Desc.Rows[0].DefaultCellStyle.BackColor = Color.SkyBlue;
                                dataGridView_Desc.Rows[0].DefaultCellStyle.SelectionBackColor = Color.SkyBlue;
                                break;
                            case "7":
                                dataGridView_Desc.Rows[0].DefaultCellStyle.BackColor = Color.Olive;
                                dataGridView_Desc.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Olive;
                                break;

                        }
                    }
                }

                #endregion

                #region 粗轧
                //粗轧显示
                string selStr_BDMZ = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘BDMZ‘";
                DB.DataGridView_Binding(selStr_BDMZ, dataGridView_BD, "MAIN.MATERIAL");
                dataGridView_BD.ClearSelection();//清除选中


                //给粗轧跟踪号赋值底色
                string selStr_BDMZ_color = "select MATERIAL_ID,PTR_MATERIAL_COLOR_ID,INFO from MAIN.MATERIAL where ZONE_NAME=‘BDMZ‘";
                string table_BDMZ_color = "table_BDMZ_color";
                DB.selectData(selStr_BDMZ_color, table_BDMZ_color);
                int BDMZ_num = DB.Ds.Tables[table_BDMZ_color].Rows.Count;
                if (BDMZ_num == 0)
                {
                    //return;
                }
                else
                {
                    string PTR_BDMZ_color = DB.Ds.Tables[table_BDMZ_color].Rows[0][1].ToString();
                    string PTR_BDMZ_info = DB.Ds.Tables[table_BDMZ_color].Rows[0][2].ToString();

                    if (PTR_BDMZ_info != "")
                    {
                        dataGridView_BD.Rows[0].DefaultCellStyle.BackColor = Color.Red;
                        dataGridView_BD.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Red;
                    }
                    else
                    {
                        switch (PTR_BDMZ_color)
                        {
                            case "1":
                                dataGridView_BD.Rows[0].DefaultCellStyle.BackColor = Color.Green;
                                dataGridView_BD.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Green;
                                break;
                            case "2":
                                dataGridView_BD.Rows[0].DefaultCellStyle.BackColor = Color.Orange;
                                dataGridView_BD.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Orange;
                                break;
                            case "3":
                                dataGridView_BD.Rows[0].DefaultCellStyle.BackColor = Color.SpringGreen;
                                dataGridView_BD.Rows[0].DefaultCellStyle.SelectionBackColor = Color.SpringGreen;
                                break;
                            case "4":
                                dataGridView_BD.Rows[0].DefaultCellStyle.BackColor = Color.Yellow;
                                dataGridView_BD.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Yellow;
                                break;
                            case "5":
                                dataGridView_BD.Rows[0].DefaultCellStyle.BackColor = Color.MediumOrchid;
                                dataGridView_BD.Rows[0].DefaultCellStyle.SelectionBackColor = Color.MediumOrchid;
                                break;
                            case "6":
                                dataGridView_BD.Rows[0].DefaultCellStyle.BackColor = Color.SkyBlue;
                                dataGridView_BD.Rows[0].DefaultCellStyle.SelectionBackColor = Color.SkyBlue;
                                break;
                            case "7":
                                dataGridView_BD.Rows[0].DefaultCellStyle.BackColor = Color.Olive;
                                dataGridView_BD.Rows[0].DefaultCellStyle.SelectionBackColor = Color.Olive;
                                break;

                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            finally
            {
                timer_Furnace.Enabled = true;
            }


        }

        private void CP1_Furnace_FormClosing(object sender, FormClosingEventArgs e)
        {
            DB.Con.Close();
            DB.Con.Dispose();
        }

        private void PO_comboBox_DropDown(object sender, EventArgs e)
        {
            string selStr_PO = "select PO_ID,STATUS from MAIN.PO_PLANNED where STATUS=‘RELEASED‘ or STATUS=‘STARTED‘";
            string table_PO = "table_PO";
            DB.selectData(selStr_PO, table_PO);
            int rownum = DB.Ds.Tables[table_PO].Rows.Count;
            if (rownum == 0)
            {
                //PO_comboBox.Text = "";
                return;
            }
            else
            {
                //DB.ComboBox_Binding(selStr_PO, PO_comboBox, "PO_ID", "MAIN.PO_PLANNED");
                PO_comboBox.DataSource = DB.Ds.Tables[table_PO];
                PO_comboBox.DisplayMember = "PO_ID";
                PO_comboBox.ValueMember = "PO_ID";
                PO_comboBox.SelectedIndex = -1;
            }
        }

        private void PO_comboBox_SelectionChangeCommitted(object sender, EventArgs e)
        {

            PTR_PO_ID = PO_comboBox.SelectedValue.ToString();
            
            string selStr_PO_num = "select NUM_PLANNED,NUM_ASSIGNED,STATUS from MAIN.PO_PLANNED where PO_ID=‘";
            selStr_PO_num += PTR_PO_ID;
            selStr_PO_num += "";
            string table_PO_num = "table_PO_num";
            DB.selectData(selStr_PO_num, table_PO_num);
            PlanNum_textBox.Text = DB.Ds.Tables[table_PO_num].Rows[0][0].ToString();
            AssignNum_textBox.Text = DB.Ds.Tables[table_PO_num].Rows[0][1].ToString();
            STATUS = DB.Ds.Tables[table_PO_num].Rows[0][2].ToString();

            try
            {

                if (STATUS == "RELEASED")
                {
                    PO_ACT_textBox.Text = "0";
                }
                else
                {
                    PTR_PO_ID = PO_comboBox.SelectedValue.ToString();
                    string selStr_MATERIAL_ID = "select MATERIAL_ID from MAIN.MATERIAL where PO_ID=‘";
                    selStr_MATERIAL_ID += PTR_PO_ID + "";
                    selStr_MATERIAL_ID += "and ZONE_NAME!=" + "‘SLAB‘";
                    selStr_MATERIAL_ID += "order by MATERIAL_ID desc";
                    string table_MATERIAL_ID = "table_MATERIAL_ID";
                    DB.selectData(selStr_MATERIAL_ID, table_MATERIAL_ID);
                    string PTR_MATERIAL_ID_1 = DB.Ds.Tables[table_MATERIAL_ID].Rows[0][0].ToString();
                    string Size = PTR_MATERIAL_ID_1.Substring(PTR_MATERIAL_ID_1.Length - 1);
                    if (Size == "H")
                    {
                        string PO_NUM_TO_1 = PTR_MATERIAL_ID_1.Substring(8, 3);
                        string PO_NUM_TO = Convert.ToString(Convert.ToInt32(PO_NUM_TO_1));

                        PO_ACT_textBox.Text = PO_NUM_TO;
                    }
                    else
                    {
                        string PO_NUM_TO_1 = PTR_MATERIAL_ID_1.Substring(PTR_MATERIAL_ID_1.Length - 4);
                        string PO_NUM_TO = Convert.ToString(Convert.ToInt32(PO_NUM_TO_1));

                        PO_ACT_textBox.Text = PO_NUM_TO;
                    }
                }

            }
#pragma warning disable CS0168 // 声明了变量“EX”,但从未使用过
            catch (Exception EX)
#pragma warning restore CS0168 // 声明了变量“EX”,但从未使用过
            {

            }
            finally
            {

            }



        }

        #region 跟踪号下装
        private void Load_pictureBox_Click(object sender, EventArgs e)
        {
            try
            {
                string HEAT_ID = "";
                string ORDER_IN_ZONE = "";
                string ORDER_IN_ZONE_1 = "";
                if (PO_comboBox.Text != "")
                {
                    PTR_PO_ID = PO_comboBox.SelectedValue.ToString();
                }
                else
                {
                    MessageBox.Show("请选择需要下装的批号");
                }

                if (STATUS == "RELEASED")
                {
                    //查询批号对应炉号的第一支钢
                    //查询出该批号ORDER_IN_ZONE为1的所对应的炉号
                    string selStr_HEAT_ID = "select HEAT_ID from MAIN.MATERIAL where PO_ID=‘";
                    selStr_HEAT_ID += PTR_PO_ID;
                    selStr_HEAT_ID += "";
                    selStr_HEAT_ID += "and ORDER_IN_ZONE=‘";
                    selStr_HEAT_ID += "1‘";

                    string table_HEAT_ID = "table_HEAT_ID";
                    DB.selectData(selStr_HEAT_ID, table_HEAT_ID);
                    int HEAT_ID_NUM = DB.Ds.Tables[table_HEAT_ID].Rows.Count;
                    if (HEAT_ID_NUM != 0)
                    {
                        HEAT_ID = DB.Ds.Tables[table_HEAT_ID].Rows[0][0].ToString();
                    }

                    if (list.Count <= 7)
                    {
                        list.Add(HEAT_ID);
                    }
                    else
                    {
                        list.RemoveAt(0);
                        list.Add(HEAT_ID);
                    }


                    if (value <= 7)
                    {
                        Heat.Add(HEAT_ID, value.ToString());
                        value++;
                    }
                    else
                    {
                        value = 1;
                        Heat.Remove(list[0]);
                        Heat.Add(HEAT_ID, value.ToString());
                    }
                    //查询出该改炉号所对应的全部ORDER_IN_ZONE,找出ORDER_IN_ZONE对应的最大的一个,即得出该炉号有多少支钢坯
                    string selStr_ORDER_IN_ZONE = "select ORDER_IN_ZONE from MAIN.MATERIAL where HEAT_ID=‘";
                    selStr_ORDER_IN_ZONE += HEAT_ID;
                    selStr_ORDER_IN_ZONE += "‘ and PO_ID=‘";
                    selStr_ORDER_IN_ZONE += PTR_PO_ID + "";
                    selStr_ORDER_IN_ZONE += "order by ORDER_IN_ZONE desc";
                    string table_ORDER_IN_ZONE = "table_ORDER_IN_ZONE";
                    DB.selectData(selStr_ORDER_IN_ZONE, table_ORDER_IN_ZONE);
                    ORDER_IN_ZONE = DB.Ds.Tables[table_ORDER_IN_ZONE].Rows[0][0].ToString();

                    string selStr_ORDER_IN_ZONE_1 = "select ORDER_IN_ZONE from MAIN.MATERIAL where ZONE_NAME=‘CGBZ‘order by ORDER_IN_ZONE desc";
                    string table_ORDER_IN_ZONE_1 = "table_ORDER_IN_ZONE_1";
                    DB.selectData(selStr_ORDER_IN_ZONE_1, table_ORDER_IN_ZONE_1);
                    int ORDER_IN_ZONE_num = DB.Ds.Tables[table_ORDER_IN_ZONE_1].Rows.Count;
                    if (ORDER_IN_ZONE_num == 0)
                    {
                        ORDER_IN_ZONE_1 = "0";
                    }
                    else
                    {
                        ORDER_IN_ZONE_1 = DB.Ds.Tables[table_ORDER_IN_ZONE_1].Rows[0][0].ToString();
                    }

                    //把改炉号的全部钢坯的区域改为冷上料台架
                    string updateStr_HEAT_ID = "update MAIN.MATERIAL set ";
                    updateStr_HEAT_ID += "ZONE_NAME=" + "‘CGBZ‘,";
                    updateStr_HEAT_ID += "ORDER_IN_ZONE=ORDER_IN_ZONE+";
                    updateStr_HEAT_ID += Convert.ToInt32(ORDER_IN_ZONE_1) + ",";
                    updateStr_HEAT_ID += "PTR_MATERIAL_COLOR_ID=‘";
                    updateStr_HEAT_ID += Heat[list[value - 2]] + "";
                    updateStr_HEAT_ID += "where HEAT_ID=";
                    updateStr_HEAT_ID += "" + HEAT_ID + "";
                    updateStr_HEAT_ID += "and PO_ID=";
                    updateStr_HEAT_ID += "" + PTR_PO_ID + "";
                    updateStr_HEAT_ID += "and ORDER_IN_ZONE between ‘1‘ and ";
                    updateStr_HEAT_ID += "" + ORDER_IN_ZONE + "";


                    string modifyresult = "";
                    DB.updateData(updateStr_HEAT_ID, out modifyresult);

                    //string selStr_ORDER_IN_ZONE_1 = "select ORDER_IN_ZONE from MAIN.MATERIAL where ZONE_NAME=‘";
                    //selStr_ORDER_IN_ZONE_1 += "‘SLAB‘ and PO_ID=‘";
                    //selStr_ORDER_IN_ZONE_1 += PTR_PO_ID;
                    //selStr_ORDER_IN_ZONE_1 += "‘";
                    //string table_ORDER_IN_ZONE_1 = "table_ORDER_IN_ZONE_1";
                    //DB.selectData(selStr_ORDER_IN_ZONE_1, table_ORDER_IN_ZONE_1);
                    //int ORDER_IN_ZONE_num = DB.Ds.Tables[table_ORDER_IN_ZONE_1].Rows.Count;

                    string updateStr_ORDER_IN_ZONE = "update MAIN.MATERIAL set ";
                    updateStr_ORDER_IN_ZONE += "ORDER_IN_ZONE=" + "ORDER_IN_ZONE -";
                    updateStr_ORDER_IN_ZONE += Convert.ToInt32(ORDER_IN_ZONE);
                    updateStr_ORDER_IN_ZONE += "where ZONE_NAME=" + "‘SLAB‘";
                    string modifyresult_1 = "";
                    DB.updateData(updateStr_ORDER_IN_ZONE, out modifyresult_1);

                    string updateStr_PO_PLANNED = "update MAIN.PO_PLANNED set ";
                    updateStr_PO_PLANNED += "STATUS=" + "‘STARTED‘";
                    updateStr_PO_PLANNED += "where PO_ID=";
                    updateStr_PO_PLANNED += "" + PTR_PO_ID + "";
                    string modifyresult1 = "";
                    DB.updateData(updateStr_PO_PLANNED, out modifyresult1);

                }
                if (STATUS == "STARTED")
                {
                    //string selStr_MATERIAL_ID_1 = "select MATERIAL_ID,HEAT_ID from MAIN.MATERIAL where PO_ID=‘";
                    //selStr_MATERIAL_ID_1 += PTR_PO_ID + "‘ and ZONE_NAME=";
                    //selStr_MATERIAL_ID_1 += "‘SLAB‘"+ "and ORDER_IN_ZONE=";
                    //selStr_MATERIAL_ID_1 += "1";
                    //string table_MATERIAL_ID_1 = "table_MATERIAL_ID_1";
                    //DB.selectData(selStr_MATERIAL_ID_1, table_MATERIAL_ID_1);

                    //PTR_MATERIAL_ID = DB.Ds.Tables[table_MATERIAL_ID_1].Rows[0][0].ToString();//获取原料库里第一支钢坯的跟踪号
                    //HEAT_ID = DB.Ds.Tables[table_MATERIAL_ID_1].Rows[0][1].ToString();//获取原料库里第一支钢坯的炉号

                    //获取进入跟踪系统的最后一支钢坯的跟踪号
                    string selStr_MATERIAL_ID_2 = "select MATERIAL_ID,PRODUCT_ID from MAIN.MATERIAL where PO_ID=‘";
                    selStr_MATERIAL_ID_2 += PTR_PO_ID + "‘ and ZONE_NAME!=";
                    selStr_MATERIAL_ID_2 += "‘SLAB‘" + "order by MATERIAL_ID desc";
                    string table_MATERIAL_ID_2 = "table_MATERIAL_ID_2";
                    DB.selectData(selStr_MATERIAL_ID_2, table_MATERIAL_ID_2);
                    PTR_MATERIAL_ID = DB.Ds.Tables[table_MATERIAL_ID_2].Rows[0][0].ToString();
                    PTR_PRODUCT_ID = Convert.ToInt32(DB.Ds.Tables[table_MATERIAL_ID_2].Rows[0][1].ToString());


                    string Size = PTR_MATERIAL_ID.Substring(PTR_MATERIAL_ID.Length - 1);
                    if (Size == "H")
                    {
                        string PO_NUM_TO_1 = PTR_MATERIAL_ID.Substring(8, 3);
                        string PO_NUM_TO = Convert.ToString(Convert.ToInt32(PO_NUM_TO_1));//获取当前批号进入跟踪系统的支数

                        string selStr_NUM_ASSIGNED = "select NUM_ASSIGNED from MAIN.PO_PLANNED where PO_ID=‘";
                        selStr_NUM_ASSIGNED += PTR_PO_ID;
                        selStr_NUM_ASSIGNED += "";
                        string table_NUM_ASSIGNED = "table_NUM_ASSIGNED";
                        DB.selectData(selStr_NUM_ASSIGNED, table_NUM_ASSIGNED);
                        string NUM_ASSIGNED = DB.Ds.Tables[table_NUM_ASSIGNED].Rows[0][0].ToString();//获取当前批号绑定支数

                        if (PO_NUM_TO == NUM_ASSIGNED)//如果进入跟踪系统的支数和当前批号绑定支数相同,不执行批号下装操作
                        {
                            MessageBox.Show("所绑定炉号已经全部下装");
                        }
                        else
                        {
                            string PO_NUM_FROM = Convert.ToString(Convert.ToInt32(PO_NUM_TO) + 1);//获取当前批号即将进入跟踪系统的开始号
                            int PTR_PRODUCT_ID_1 = PTR_PRODUCT_ID + 1;
                            string selStr_HEAT_ID = "select NUM_ASSIGNED from MAIN.PO_HEAT where PO_NUM_FROM=‘";
                            selStr_HEAT_ID += PO_NUM_FROM;
                            selStr_HEAT_ID += "‘ and PO_ID=‘";
                            selStr_HEAT_ID += PTR_PO_ID;
                            selStr_HEAT_ID += "";
                            string table_HEAT_ID = "table_HEAT_ID";
                            DB.selectData(selStr_HEAT_ID, table_HEAT_ID);
                            //HEAT_ID = DB.Ds.Tables[table_HEAT_ID].Rows[0][0].ToString();//获取当前批号即将进入跟踪系统的炉号
                            //string new_PO_NUM_TO = DB.Ds.Tables[table_HEAT_ID].Rows[0][0].ToString();//获取即将进入跟踪系统的该炉号的结束号
                            int new_ORDER_IN_ZONE = Convert.ToInt32(DB.Ds.Tables[table_HEAT_ID].Rows[0][0].ToString());//获取即将进入跟踪系统的支数
                            int PTR_PRODUCT_ID_2 = PTR_PRODUCT_ID_1 + new_ORDER_IN_ZONE;




                            string updateStr_HEAT_ID = "update MAIN.MATERIAL set ";
                            updateStr_HEAT_ID += "ZONE_NAME=" + "‘CGBZ‘,";
                            updateStr_HEAT_ID += "ORDER_IN_ZONE = ORDER_IN_ZONE + ";
                            updateStr_HEAT_ID += Convert.ToInt32(PO_NUM_TO);
                            updateStr_HEAT_ID += " where PRODUCT_ID between ";
                            updateStr_HEAT_ID += PTR_PRODUCT_ID_1 + " and ";
                            updateStr_HEAT_ID += PTR_PRODUCT_ID_2 + " and ZONE_NAME=";
                            updateStr_HEAT_ID += "‘SLAB‘";
                            string modifyresult = "";
                            DB.updateData(updateStr_HEAT_ID, out modifyresult);



                            string updateStr_HEAT_ID_1 = "update MAIN.MATERIAL set ";
                            updateStr_HEAT_ID_1 += "ORDER_IN_ZONE = ORDER_IN_ZONE - ";
                            updateStr_HEAT_ID_1 += new_ORDER_IN_ZONE;
                            //updateStr_HEAT_ID_1 += "where PO_ID=";
                            //updateStr_HEAT_ID_1+="‘"+PTR_PO_ID+"‘";
                            updateStr_HEAT_ID_1 += "where ZONE_NAME=";
                            updateStr_HEAT_ID_1 += "‘SLAB‘";
                            string modifyresult_1 = "";
                            DB.updateData(updateStr_HEAT_ID_1, out modifyresult_1);

                        }
                    }
                    else
                    {


                        string PO_NUM_TO_1 = PTR_MATERIAL_ID.Substring(PTR_MATERIAL_ID.Length - 4);
                        string PO_NUM_TO = Convert.ToString(Convert.ToInt32(PO_NUM_TO_1));//获取当前批号进入跟踪系统的支数

                        //string selStr_ORDER_IN_ZONE = "select ORDER_IN_ZONE,PO_ID from MAIN.MATERIAL where MATERIAL_ID=‘";
                        //selStr_ORDER_IN_ZONE += PTR_MATERIAL_ID;
                        //selStr_ORDER_IN_ZONE += "‘";
                        //string table_ORDER_IN_ZONE = "table_ORDER_IN_ZONE";
                        //DB.selectData(selStr_ORDER_IN_ZONE, table_ORDER_IN_ZONE);


                        //ORDER_IN_ZONE = DB.Ds.Tables[table_ORDER_IN_ZONE].Rows[0][0].ToString();//获取冷上料台架最后一支跟踪号的ORDER_IN_ZONE
                        //PTR_PO_ID = DB.Ds.Tables[table_ORDER_IN_ZONE].Rows[0][1].ToString();//获取当前的批号

                        string selStr_NUM_ASSIGNED = "select NUM_ASSIGNED from MAIN.PO_PLANNED where PO_ID=‘";
                        selStr_NUM_ASSIGNED += PTR_PO_ID;
                        selStr_NUM_ASSIGNED += "";
                        string table_NUM_ASSIGNED = "table_NUM_ASSIGNED";
                        DB.selectData(selStr_NUM_ASSIGNED, table_NUM_ASSIGNED);
                        string NUM_ASSIGNED = DB.Ds.Tables[table_NUM_ASSIGNED].Rows[0][0].ToString();//获取当前批号绑定支数

                        if (PO_NUM_TO == NUM_ASSIGNED)//如果进入跟踪系统的支数和当前批号绑定支数相同,不执行批号下装操作
                        {
                            MessageBox.Show("所绑定炉号已经全部下装");
                        }
                        else
                        {
                            string PO_NUM_FROM = Convert.ToString(Convert.ToInt32(PO_NUM_TO) + 1);//获取当前批号即将进入跟踪系统的开始号
                            int PTR_PRODUCT_ID_1 = PTR_PRODUCT_ID + 1;
                            string selStr_HEAT_ID = "select NUM_ASSIGNED from MAIN.PO_HEAT where PO_NUM_FROM=‘";
                            selStr_HEAT_ID += PO_NUM_FROM;
                            selStr_HEAT_ID += "‘ and PO_ID=‘";
                            selStr_HEAT_ID += PTR_PO_ID;
                            selStr_HEAT_ID += "";
                            string table_HEAT_ID = "table_HEAT_ID";
                            DB.selectData(selStr_HEAT_ID, table_HEAT_ID);
                            //HEAT_ID = DB.Ds.Tables[table_HEAT_ID].Rows[0][0].ToString();//获取当前批号即将进入跟踪系统的炉号
                            //string new_PO_NUM_TO = DB.Ds.Tables[table_HEAT_ID].Rows[0][0].ToString();//获取即将进入跟踪系统的该炉号的结束号
                            int new_ORDER_IN_ZONE = Convert.ToInt32(DB.Ds.Tables[table_HEAT_ID].Rows[0][0].ToString());//获取即将进入跟踪系统的支数
                            int PTR_PRODUCT_ID_2 = PTR_PRODUCT_ID_1 + new_ORDER_IN_ZONE;




                            string updateStr_HEAT_ID = "update MAIN.MATERIAL set ";
                            updateStr_HEAT_ID += "ZONE_NAME=" + "‘CGBZ‘,";
                            updateStr_HEAT_ID += "ORDER_IN_ZONE = ORDER_IN_ZONE + ";
                            updateStr_HEAT_ID += Convert.ToInt32(PO_NUM_TO);
                            updateStr_HEAT_ID += " where PRODUCT_ID between ";
                            updateStr_HEAT_ID += PTR_PRODUCT_ID_1 + " and ";
                            updateStr_HEAT_ID += PTR_PRODUCT_ID_2 + " and ZONE_NAME=";
                            updateStr_HEAT_ID += "‘SLAB‘";
                            string modifyresult = "";
                            DB.updateData(updateStr_HEAT_ID, out modifyresult);



                            string updateStr_HEAT_ID_1 = "update MAIN.MATERIAL set ";
                            updateStr_HEAT_ID_1 += "ORDER_IN_ZONE = ORDER_IN_ZONE - ";
                            updateStr_HEAT_ID_1 += new_ORDER_IN_ZONE;
                            //updateStr_HEAT_ID_1 += "where PO_ID=";
                            //updateStr_HEAT_ID_1+="‘"+PTR_PO_ID+"‘";
                            updateStr_HEAT_ID_1 += "where ZONE_NAME=";
                            updateStr_HEAT_ID_1 += "‘SLAB‘";
                            string modifyresult_1 = "";
                            DB.updateData(updateStr_HEAT_ID_1, out modifyresult_1);

                        }
                    }

                }
            }
            catch(Exception ex)
            {
                LogHelper.Error(ex);
            }
            finally
            {

            }
        }


        private void Load_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            Load_pictureBox.BackColor = Color.PaleGreen;
        }

        private void Load_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            Load_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 跟踪号上装
        private void UnLoad_pictureBox_Click(object sender, EventArgs e)
        {
            string HEAT_ID = "";
            string ORDER_IN_ZONE = "";
            string PO_NUM_TO = "";
            if (dataGridView_ChargingGrid.Rows.Count != 0)
            {
                PTR_MATERIAL_ID = dataGridView_ChargingGrid.Rows[0].Cells[0].Value.ToString();//获取冷上料台架最后一支的跟踪号

                string Size = PTR_MATERIAL_ID.Substring(PTR_MATERIAL_ID.Length - 1);
                if (Size == "H")
                {
                    string PO_NUM_TO_1 = PTR_MATERIAL_ID.Substring(8, 3);
                    PO_NUM_TO = Convert.ToString(Convert.ToInt32(PO_NUM_TO_1));
                }
                else
                {
                    string PO_NUM_TO_1 = PTR_MATERIAL_ID.Substring(PTR_MATERIAL_ID.Length - 4);
                    PO_NUM_TO = Convert.ToString(Convert.ToInt32(PO_NUM_TO_1));//获取当前批号进入跟踪系统的支数
                }

                string selStr_PTR_MATERIAL_COLOR_ID = "select PO_ID,HEAT_ID,ORDER_IN_ZONE,PRODUCT_ID from MAIN.MATERIAL where MATERIAL_ID=‘";
                selStr_PTR_MATERIAL_COLOR_ID += PTR_MATERIAL_ID;
                selStr_PTR_MATERIAL_COLOR_ID += "";
                string table_PTR_MATERIAL_COLOR_ID = "table_PTR_MATERIAL_COLOR_ID";
                DB.selectData(selStr_PTR_MATERIAL_COLOR_ID, table_PTR_MATERIAL_COLOR_ID);
                PTR_PO_ID = DB.Ds.Tables[table_PTR_MATERIAL_COLOR_ID].Rows[0][0].ToString();//获取冷上料台架最后一支的批号
                HEAT_ID = DB.Ds.Tables[table_PTR_MATERIAL_COLOR_ID].Rows[0][1].ToString();//获取冷上料台架最后一支的炉号
                ORDER_IN_ZONE = DB.Ds.Tables[table_PTR_MATERIAL_COLOR_ID].Rows[0][2].ToString();//获取冷上料台架最后一支的ORDER_IN_ZONE
                int PTR_PRODUCT_ID_1 = Convert.ToInt32(DB.Ds.Tables[table_PTR_MATERIAL_COLOR_ID].Rows[0][3].ToString());//获取获取冷上料台架最后一支的PRODUCT_ID

                string selStr_HEAT_ID = "select NUM_ASSIGNED,PO_NUM_FROM from MAIN.PO_HEAT where PO_ID=‘";
                selStr_HEAT_ID += PTR_PO_ID;
                selStr_HEAT_ID += "‘ and HEAT_ID=‘";
                selStr_HEAT_ID += HEAT_ID;
                selStr_HEAT_ID += "‘ and PO_NUM_TO=‘";
                selStr_HEAT_ID += PO_NUM_TO;
                selStr_HEAT_ID += "";
                string table_HEAT_ID = "table_HEAT_ID";
                DB.selectData(selStr_HEAT_ID, table_HEAT_ID);
                string NUM_ASSIGNED = DB.Ds.Tables[table_HEAT_ID].Rows[0][0].ToString();
                string PO_NUM_FROM = DB.Ds.Tables[table_HEAT_ID].Rows[0][1].ToString();

                PTR_PRODUCT_ID = PTR_PRODUCT_ID_1 - Convert.ToInt32(NUM_ASSIGNED) + 1;//获取要上装的这一炉的第一支的PRODUCT_ID

                //在MATERIAL表中删除上装的一炉的所有信息
                string deleteStr_PTR_PRODUCT_ID = "delete from MAIN.MATERIAL where PRODUCT_ID between ";
                deleteStr_PTR_PRODUCT_ID += PTR_PRODUCT_ID + " and ";
                deleteStr_PTR_PRODUCT_ID += PTR_PRODUCT_ID_1 + " and ZONE_NAME=";
                deleteStr_PTR_PRODUCT_ID += "‘SLAB‘";
                string result_PTR_PRODUCT_ID = "";

                //更新原料库中所有跟踪号的PRODUCT_ID
                string update_PTR_PRODUCT_ID = "update MAIN.MATERIAL set ";
                update_PTR_PRODUCT_ID += "PRODUCT_ID=PRODUCT_ID - " + Convert.ToInt32(NUM_ASSIGNED);
                update_PTR_PRODUCT_ID += " where ZONE_NAME=‘SLAB‘";
                string modifyresult = "";

                //删除MAIN.PO_HEAT表中该炉的炉号信息即解绑
                string deleteStr_PO_HEAT = "delete from MAIN.PO_HEAT where PO_ID=‘";
                deleteStr_PO_HEAT += PTR_PO_ID + "‘ and HEAT_ID=‘";
                deleteStr_PO_HEAT += HEAT_ID + "‘ and PO_NUM_TO=";
                deleteStr_PO_HEAT += Convert.ToInt32(PO_NUM_TO);
                string result_PO_HEAT = "";

                DialogResult dr = MessageBox.Show("确定上装这炉钢坯吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    DB.deleteData(deleteStr_PTR_PRODUCT_ID, out result_PTR_PRODUCT_ID);
                    DB.updateData(update_PTR_PRODUCT_ID, out modifyresult);
                    DB.deleteData(deleteStr_PO_HEAT, out result_PO_HEAT);

                    //如果该批号的炉号全部解绑,把批号的状态更新为RELEASED
                    if (Convert.ToInt32(PO_NUM_FROM) == 1)
                    {
                        string updateStr_PO_PLANNED = "update MAIN.PO_PLANNED set ";
                        updateStr_PO_PLANNED += "STATUS=‘NEW‘,";
                        updateStr_PO_PLANNED += "NUM_ASSIGNED=NUM_ASSIGNED-" + Convert.ToInt32(NUM_ASSIGNED);
                        updateStr_PO_PLANNED += " where PO_ID=‘";
                        updateStr_PO_PLANNED += PTR_PO_ID + "";
                        string modifyresult_PO_PLANNED = "";
                        DB.updateData(updateStr_PO_PLANNED, out modifyresult_PO_PLANNED);
                    }
                }
                else
                {
                    return;
                }
            }
        }

        private void UnLoad_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            UnLoad_pictureBox.BackColor = Color.Silver;
        }

        private void UnLoad_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            UnLoad_pictureBox.BackColor = SystemColors.Control;
        }

        #endregion

        #region 冷上料台架前进按钮
        private void ChargingGridForWard_pictureBox_Click(object sender, EventArgs e)
        {
            string selStr_CGBZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘CGBZ‘ order by MATERIAL_ID asc";
            string table_CGBZ_num = "table_CGBZ_num";
            DB.selectData(selStr_CGBZ_num, table_CGBZ_num);

            string selStr_RHEZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHEZ‘";
            string table_RHEZ_num = "table_RHEZ_num";
            DB.selectData(selStr_RHEZ_num, table_RHEZ_num);

            int CGBZ_num = DB.Ds.Tables[table_CGBZ_num].Rows.Count;
            int RHEZ_num = DB.Ds.Tables[table_RHEZ_num].Rows.Count;
            if (CGBZ_num == 0)
            {
                MessageBox.Show("冷上料台架无可以移动的钢坯");
            }
            else
            {
                if (RHEZ_num == 0)
                {
                    string selStr_CGBZ = "select MATERIAL_ID,PO_ID from MAIN.MATERIAL where ZONE_NAME=‘CGBZ‘ order by MATERIAL_ID asc";
                    string table_CGBZ = "table_CGBZ";
                    DB.selectData(selStr_CGBZ, table_CGBZ);
                    PTR_MATERIAL_ID = DB.Ds.Tables[table_CGBZ].Rows[0][0].ToString();//获取冷上料台架最前一支的跟踪号
                    //PTR_PO_ID = DB.Ds.Tables[table_CGBZ].Rows[0][1].ToString();//获取冷上料台架最前一支的批号

                    string updateStr_CGBZ = "update MAIN.MATERIAL set ";//把冷上料台架第一支的区域改为加热炉入炉辊道
                    updateStr_CGBZ += "ZONE_NAME=" + "‘RHEZ‘";
                    //updateStr_CGBZ += "ORDER_IN_ZONE=" + "‘1‘";
                    updateStr_CGBZ += "where MATERIAL_ID=";
                    updateStr_CGBZ += "" + PTR_MATERIAL_ID + "";
                    string modifyresult = "";
                    DB.updateData(updateStr_CGBZ, out modifyresult);

                    string updateStr_CGBZ_1 = "update MAIN.MATERIAL set ";//修改冷上料台架内跟踪号的ORDER_IN_ZONE
                    updateStr_CGBZ_1 += "ORDER_IN_ZONE = ORDER_IN_ZONE - " + "‘1‘";
                    //updateStr_CGBZ_1 += "where PO_ID=";
                    updateStr_CGBZ_1 += "where ZONE_NAME=";
                    updateStr_CGBZ_1 += "‘CGBZ‘";
                    string modifyresult_1 = "";
                    DB.updateData(updateStr_CGBZ_1, out modifyresult_1);



                }
                else
                {
                    MessageBox.Show("加热炉入炉辊道处有钢");
                }
            }
        }

        private void ChargingGridForWard_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            ChargingGridForWard_pictureBox.BackColor = Color.PaleGreen;
        }

        private void ChargingGridForWard_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            ChargingGridForWard_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 冷上料台架后退按钮
        private void ChargingGridBack_pictureBox_Click(object sender, EventArgs e)
        {
            string selStr_RHEZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHEZ‘";
            string table_RHEZ_num = "table_RHEZ_num";
            DB.selectData(selStr_RHEZ_num, table_RHEZ_num);

            int RHEZ_num = DB.Ds.Tables[table_RHEZ_num].Rows.Count;
            if (RHEZ_num == 0)
            {
                MessageBox.Show("加热炉入炉辊道无可以移动的钢坯");
            }
            else
            {
                PTR_MATERIAL_ID = dataGridView_EntryRoll.Rows[0].Cells[0].Value.ToString();//获取加热炉入炉辊道处的钢坯的跟踪号
                //PTR_PO_ID = PTR_MATERIAL_ID.Substring(0,8);

                string updateStr_CGBZ_1 = "update MAIN.MATERIAL set ";//修改冷上料台架内跟踪号的ORDER_IN_ZONE
                updateStr_CGBZ_1 += "ORDER_IN_ZONE = ORDER_IN_ZONE + " + "‘1‘";
                //updateStr_CGBZ_1 += "where PO_ID=";
                updateStr_CGBZ_1 += "where ZONE_NAME=";
                updateStr_CGBZ_1 += "‘CGBZ‘";
                string modifyresult_1 = "";
                DB.updateData(updateStr_CGBZ_1, out modifyresult_1);

                string updateStr_CGBZ = "update MAIN.MATERIAL set ";//把加热炉入炉辊道钢坯的区域改为冷上料台架
                updateStr_CGBZ += "ZONE_NAME=" + "‘CGBZ‘";
                //updateStr_CGBZ+= "ORDER_IN_ZONE=" + "‘1‘";
                updateStr_CGBZ += "where MATERIAL_ID=";
                updateStr_CGBZ += "" + PTR_MATERIAL_ID + "";
                string modifyresult = "";
                DB.updateData(updateStr_CGBZ, out modifyresult);
            }
        }

        private void ChargingGridBack_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            ChargingGridBack_pictureBox.BackColor = Color.Silver;
        }

        private void ChargingGridBack_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            ChargingGridBack_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 加热炉入炉辊道前进按钮
        private void EntryRollForWard_pictureBox_Click(object sender, EventArgs e)
        {
            string selStr_RHEZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHEZ‘";
            string table_RHEZ_num = "table_RHEZ_num";
            DB.selectData(selStr_RHEZ_num, table_RHEZ_num);

            int RHEZ_num = DB.Ds.Tables[table_RHEZ_num].Rows.Count;

            string selStr_RHFZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHFZ‘order by MATERIAL_ID asc";
            string table_RHFZ_num = "table_RHFZ_num";
            DB.selectData(selStr_RHFZ_num, table_RHFZ_num);

            int RHFZ_num = DB.Ds.Tables[table_RHFZ_num].Rows.Count;
            if (RHEZ_num == 0)
            {
                MessageBox.Show("加热炉入炉辊道无可以移动的钢坯");
            }
            else
            {
                PTR_MATERIAL_ID = dataGridView_EntryRoll.Rows[0].Cells[0].Value.ToString();//获取加热炉入炉辊道处的钢坯的跟踪号
                int ORDER_IN_ZONE = RHFZ_num + 1;

                string updateStr_RHEZ = "update MAIN.MATERIAL set ";
                updateStr_RHEZ += "ZONE_NAME=" + "‘RHFZ‘,";
                updateStr_RHEZ += "ORDER_IN_ZONE=";
                updateStr_RHEZ += "" + ORDER_IN_ZONE + "";
                updateStr_RHEZ += "where MATERIAL_ID= ";
                updateStr_RHEZ += "" + PTR_MATERIAL_ID + "";
                string modifyresult = "";
                DB.updateData(updateStr_RHEZ, out modifyresult);
            }
        }

        private void EntryRollForWard_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            EntryRollForWard_pictureBox.BackColor = Color.PaleGreen;
        }

        private void EntryRollForWard_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            EntryRollForWard_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 加热炉入炉辊道后退按钮
        private void EntryRollBack_pictureBox_Click(object sender, EventArgs e)
        {
            string selStr_RHEZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHEZ‘";
            string table_RHEZ_num = "table_RHEZ_num";
            DB.selectData(selStr_RHEZ_num, table_RHEZ_num);

            int RHEZ_num = DB.Ds.Tables[table_RHEZ_num].Rows.Count;

            string selStr_RHFZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHFZ‘order by MATERIAL_ID asc";
            string table_RHFZ_num = "table_RHFZ_num";
            DB.selectData(selStr_RHFZ_num, table_RHFZ_num);

            int RHFZ_num = DB.Ds.Tables[table_RHFZ_num].Rows.Count;

            if (RHEZ_num == 0)
            {
                //string selStr_RHFZ = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHFZ‘ order by MATERIAL_ID desc";
                //string table_RHFZ = "table_RHFZ";
                //DB.selectData(selStr_RHFZ, table_RHFZ);
                PTR_MATERIAL_ID = dataGridView_Furnace.Rows[RHFZ_num - 1].Cells[0].Value.ToString();//获取加热炉最后一支钢坯的跟踪号

                string updateStr_RHEZ = "update MAIN.MATERIAL set ";
                updateStr_RHEZ += "ZONE_NAME=" + "‘RHEZ‘,";
                updateStr_RHEZ += "ORDER_IN_ZONE=" + "‘1‘";
                updateStr_RHEZ += "where MATERIAL_ID= ";
                updateStr_RHEZ += "" + PTR_MATERIAL_ID + "";
                string modifyresult = "";
                DB.updateData(updateStr_RHEZ, out modifyresult);
            }
            else
            {
                MessageBox.Show("加热炉入炉辊道已经有钢坯");
            }
        }

        private void EntryRollBack_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            EntryRollBack_pictureBox.BackColor = Color.Silver;
        }

        private void EntryRollBack_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            EntryRollBack_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 加热炉前进按钮
        private void FurnaceForward_pictureBox_Click_1(object sender, EventArgs e)
        {
           

            string selStr_RHFZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHFZ‘order by MATERIAL_ID asc";
            string table_RHFZ_num = "table_RHFZ_num";
            DB.selectData(selStr_RHFZ_num, table_RHFZ_num);

            int RHFZ_num = DB.Ds.Tables[table_RHFZ_num].Rows.Count;

            string selStr_RHDZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHDZ‘";
            string table_RHDZ_num = "table_RHDZ_num";
            DB.selectData(selStr_RHDZ_num, table_RHDZ_num);

            int RHDZ_num = DB.Ds.Tables[table_RHDZ_num].Rows.Count;
            
            if (RHFZ_num == 0)
            {
                MessageBox.Show("加热炉内无可以移动的钢坯");
            }
            else
            {
                if (RHDZ_num == 0)
                {
                    PTR_MATERIAL_ID = dataGridView_Furnace.Rows[0].Cells[0].Value.ToString().Trim();//获取加热炉内第一支钢坯的跟踪号

                    string updateStr_RHFZ = "update MAIN.MATERIAL set ";
                    updateStr_RHFZ += "ZONE_NAME=" + "‘RHDZ‘";
                    //updateStr_RHFZ += "ORDER_IN_ZONE = " + "‘1‘";
                    updateStr_RHFZ += "where MATERIAL_ID= ";
                    updateStr_RHFZ += "" + PTR_MATERIAL_ID + "";
                    string modifyresult = "";
                    DB.updateData(updateStr_RHFZ, out modifyresult);

                    string updateStr_RHFZ_1 = "update MAIN.MATERIAL set ";
                    updateStr_RHFZ_1 += "ORDER_IN_ZONE = ORDER_IN_ZONE - " + "‘1‘";
                    //updateStr_RHFZ_1 += "where PO_ID=";
                    updateStr_RHFZ_1 += "where ZONE_NAME= ";
                    updateStr_RHFZ_1 += "‘RHFZ‘";
                    string modifyresult_1 = "";
                    DB.updateData(updateStr_RHFZ_1, out modifyresult_1);
                }
                else
                {
                    MessageBox.Show("加热炉出炉辊道有钢坯");
                }
            }
        }

        private void FurnaceForward_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            FurnaceForward_pictureBox.BackColor = Color.PaleGreen;
        }

        private void FurnaceForward_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            FurnaceForward_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 加热炉后退按钮
        private void FurnaceBack_pictureBox_Click(object sender, EventArgs e)
        {
            string selStr_RHDZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHDZ‘";
            string table_RHDZ_num = "table_RHDZ_num";
            DB.selectData(selStr_RHDZ_num, table_RHDZ_num);

            int RHDZ_num = DB.Ds.Tables[table_RHDZ_num].Rows.Count;
            if (RHDZ_num == 0)
            {
                MessageBox.Show("加热炉出炉辊道无可以移动的钢坯");
            }
            else
            {
                PTR_MATERIAL_ID = dataGridView_ExitRoll.Rows[0].Cells[0].Value.ToString();//获取加热炉出炉辊道钢坯的跟踪号

                string updateStr_RHFZ = "update MAIN.MATERIAL set ";
                updateStr_RHFZ += "ORDER_IN_ZONE = ORDER_IN_ZONE + " + "‘1‘";
                updateStr_RHFZ += "where ZONE_NAME= ";
                updateStr_RHFZ += "‘RHFZ‘";
                string modifyresult = "";
                DB.updateData(updateStr_RHFZ, out modifyresult);

                string updateStr_RHFZ_1 = "update MAIN.MATERIAL set ";
                updateStr_RHFZ_1 += "ZONE_NAME=" + "‘RHFZ‘";
                updateStr_RHFZ_1 += "where MATERIAL_ID= ";
                updateStr_RHFZ_1 += "" + PTR_MATERIAL_ID + "";
                string modifyresult_1 = "";
                DB.updateData(updateStr_RHFZ_1, out modifyresult_1);
            }

        }

        private void FurnaceBack_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            FurnaceBack_pictureBox.BackColor = Color.Silver;
        }

        private void FurnaceBack_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            FurnaceBack_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 加热炉出炉辊道前进按钮
        private void ExitRollForward_pictureBox_Click(object sender, EventArgs e)
        {
            string selStr_RHDZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHDZ‘";
            string table_RHDZ_num = "table_RHDZ_num";
            DB.selectData(selStr_RHDZ_num, table_RHDZ_num);

            int RHDZ_num = DB.Ds.Tables[table_RHDZ_num].Rows.Count;

            string selStr_DESC_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘DESC‘";
            string table_DESC_num = "table_DESC_num";
            DB.selectData(selStr_DESC_num, table_DESC_num);

            int DESC_num = DB.Ds.Tables[table_DESC_num].Rows.Count;
            //int DESC_num = dataGridView_Desc.Rows.Count;
            if (DESC_num == 0)
            {
                if (RHDZ_num == 0)
                {
                    MessageBox.Show("加热炉出炉辊道无可以移动的钢坯");
                }
                else
                {
                    PTR_MATERIAL_ID = dataGridView_ExitRoll.Rows[0].Cells[0].Value.ToString();//获取加热炉出炉辊道钢坯的跟踪号

                    string updateStr_RHDZ = "update MAIN.MATERIAL set ";
                    updateStr_RHDZ += "ZONE_NAME=" + "‘DESC‘";
                    updateStr_RHDZ += "where MATERIAL_ID= ";
                    updateStr_RHDZ += "" + PTR_MATERIAL_ID + "";
                    string modifyresult = "";
                    DB.updateData(updateStr_RHDZ, out modifyresult);
                }
            }
            else
            {
                MessageBox.Show("高压水除鳞处有钢");
            }
        }

        private void ExitRollForward_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            ExitRollForward_pictureBox.BackColor = Color.PaleGreen;
        }

        private void ExitRollForward_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            ExitRollForward_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 加热炉出炉辊道后退按钮
        private void ExitRollBack_pictureBox_Click(object sender, EventArgs e)
        {
            string selStr_RHDZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘RHDZ‘";
            string table_RHDZ_num = "table_RHDZ_num";
            DB.selectData(selStr_RHDZ_num, table_RHDZ_num);

            int RHDZ_num = DB.Ds.Tables[table_RHDZ_num].Rows.Count;

            string selStr_DESC_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘DESC‘";
            string table_DESC_num = "table_DESC_num";
            DB.selectData(selStr_DESC_num, table_DESC_num);

            int DESC_num = DB.Ds.Tables[table_DESC_num].Rows.Count;
            if (RHDZ_num == 0)
            {
                if (DESC_num == 0)
                {
                    MessageBox.Show("高压水除鳞处无可以移动的钢坯");
                }
                else
                {
                    PTR_MATERIAL_ID = dataGridView_Desc.Rows[0].Cells[0].Value.ToString();//获取高压水除鳞处钢坯的跟踪号

                    string updateStr_RHDZ = "update MAIN.MATERIAL set ";
                    updateStr_RHDZ += "ZONE_NAME=" + "‘RHDZ‘";
                    updateStr_RHDZ += "where MATERIAL_ID= ";
                    updateStr_RHDZ += "" + PTR_MATERIAL_ID + "";
                    string modifyresult = "";
                    DB.updateData(updateStr_RHDZ, out modifyresult);
                }
            }
            else
            {
                MessageBox.Show("加热炉出炉辊道处有钢");
            }
        }

        private void ExitRollBack_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            ExitRollBack_pictureBox.BackColor = Color.Silver;
        }

        private void ExitRollBack_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            ExitRollBack_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 高压水除鳞前进按钮
        private void DESCForward_pictureBox_Click(object sender, EventArgs e)
        {
            string selStr_DESC_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘DESC‘";
            string table_DESC_num = "table_DESC_num";
            DB.selectData(selStr_DESC_num, table_DESC_num);

            int DESC_num = DB.Ds.Tables[table_DESC_num].Rows.Count;

            string selStr_BDMZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘BDMZ‘";
            string table_BDMZ_num = "table_BDMZ_num";
            DB.selectData(selStr_BDMZ_num, table_BDMZ_num);

            int BDMZ_num = DB.Ds.Tables[table_BDMZ_num].Rows.Count;
            //int BDMZ_num = dataGridView_BD.Rows.Count;
            if (DESC_num == 0)
            {
                MessageBox.Show("高压水除鳞处无可移动的钢坯");
            }
            else
            {
                if (BDMZ_num == 0)
                {
                    PTR_MATERIAL_ID = dataGridView_Desc.Rows[0].Cells[0].Value.ToString();//获取高压水除鳞处钢坯的跟踪号

                    string updateStr_DESC = "update MAIN.MATERIAL set ";
                    updateStr_DESC += "ZONE_NAME=" + "‘BDMZ‘";
                    updateStr_DESC += "where MATERIAL_ID= ";
                    updateStr_DESC += "" + PTR_MATERIAL_ID + "";
                    string modifyresult = "";
                    DB.updateData(updateStr_DESC, out modifyresult);
                }
                else
                {
                    MessageBox.Show("粗轧有钢");
                }
            }
        }

        private void DESCForward_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            DESCForward_pictureBox.BackColor = Color.PaleGreen;
        }

        private void DESCForward_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            DESCForward_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        #region 高压水除鳞后退按钮
        private void DESCBack_pictureBox_Click(object sender, EventArgs e)
        {
            string selStr_DESC_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘DESC‘";
            string table_DESC_num = "table_DESC_num";
            DB.selectData(selStr_DESC_num, table_DESC_num);

            int DESC_num = DB.Ds.Tables[table_DESC_num].Rows.Count;

            string selStr_BDMZ_num = "select MATERIAL_ID from MAIN.MATERIAL where ZONE_NAME=‘BDMZ‘";
            string table_BDMZ_num = "table_BDMZ_num";
            DB.selectData(selStr_BDMZ_num, table_BDMZ_num);

            int BDMZ_num = DB.Ds.Tables[table_BDMZ_num].Rows.Count;

            if (DESC_num == 0)
            {
                if (BDMZ_num == 0)
                {
                    MessageBox.Show("粗轧处无可以移动的钢坯");
                }
                else
                {
                    PTR_MATERIAL_ID = dataGridView_BD.Rows[0].Cells[0].Value.ToString();//获取粗轧钢坯的跟踪号

                    string updateStr_DESC = "update MAIN.MATERIAL set ";
                    updateStr_DESC += "ZONE_NAME=" + "‘DESC‘";
                    updateStr_DESC += "where MATERIAL_ID= ";
                    updateStr_DESC += "" + PTR_MATERIAL_ID + "";
                    string modifyresult = "";
                    DB.updateData(updateStr_DESC, out modifyresult);
                }
            }
            else
            {
                MessageBox.Show("高压水除鳞有钢");
            }
        }

        private void DESCBack_pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            DESCBack_pictureBox.BackColor = Color.Silver;
        }

        private void DESCBack_pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            DESCBack_pictureBox.BackColor = SystemColors.Control;
        }
        #endregion

        private void dataGridView_ChargingGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Material = dataGridView_ChargingGrid.CurrentCell.Value.ToString();
            ScrapReason_textBox.Text = Material;
            Console.WriteLine(Material);
        }

        private void Scrap_button_Click(object sender, EventArgs e)
        {
            //剔除操作之后的区域更新
            string update = "UPDATE MAIN.MATERIAL SET ZONE_NAME = ‘DELZ‘ WHERE MATERIAL_ID = ‘";
            update += ScrapReason_textBox.Text;
            update += "";
            string mes = string.Empty;
            DB.updateData(update, out mes);
            //添加信息到MAIN.RES_BLOOM_SCRAP
            //查询物料号对应的批号
            string po = "select PO_ID from MAIN.MATERIAL where MATERIAL_ID=‘";
            po+= ScrapReason_textBox.Text;
            po += "";
            DB.selectData(po, "po");
            string v1 = DB.Ds.Tables["po"].Rows[0][0].ToString().Trim();
            //查询当前班次
            string shift = "select CREW_ID from MAIN.CAT_CREW where ACTUAL_CREW=‘Y‘";
            DB.selectData(shift,"shift");
            string v2 = DB.Ds.Tables["shift"].Rows[0][0].ToString().Trim();
            string insert = "insert into MAIN.RES_BLOOM_SCRAP(PO_ID,SCRAP_REASON,SCRAP_DATI,SHIFT,OPERATOR,MATERIAL_ID) values(";
            insert += "";
            insert += v1;
            insert += "‘,";
            insert += "";
            insert += REASON_DESC;
            insert += "‘,";
            insert += "sysdate";
            insert += ",‘";
            insert += v2;
            insert += "‘,‘";
            insert += "无‘";
            insert += ",‘";
            insert+= ScrapReason_textBox.Text;
            insert += "‘)";
            //执行插入
            string str = string.Empty;
            DB.insertData(insert,out str);
            //通过物料id查询重量
            string weight = "select BLOOM_WGT from MAIN.RES_BLOOM_ROLLING_DATA where MATERIAL_ID=‘";
            weight += ScrapReason_textBox.Text;
            weight += "";
            DB.selectData(weight, "weight");
            if (DB.Ds.Tables["weight"].Rows.Count == 0)
            {
            }
            else {
                string Weight = DB.Ds.Tables["weight"].Rows[0][0].ToString().Trim();
                //把查询出来的重量更新到MAIN.RES_PO表中的WGT_EXTRACT和NUM_EXTRACT字段
                string update_weight = "update MAIN.RES_PO set WGT_EXTRACT=‘WGT_EXTRACT+";
                update_weight += int.Parse(update_weight);
                update_weight += "‘,";
                update_weight += "NUM_EXTRACT=‘NUM_EXTRACT+1‘";
                update_weight += "where PO_ID=‘";
                update_weight += v1;
                update_weight += "";
                string a = string.Empty;
                DB.updateData(update_weight, out a);
            }        
            //获得剔除的物料号的order_inzone
            string get_order = "select ORDER_IN_ZONE from MAIN.MATERIAL where MATERIAL_ID=‘";
            get_order+= ScrapReason_textBox.Text;
            get_order += "";
            DB.selectData(get_order,"get");
            string v3 = DB.Ds.Tables["get"].Rows[0][0].ToString().Trim();
            //更新order_inzone
            string update_order_inzone = "update MAIN.MATERIAL set ORDER_IN_ZONE=ORDER_IN_ZONE-1 where ORDER_IN_ZONE>‘";
            update_order_inzone += v3;
            update_order_inzone += "‘ and ";
            update_order_inzone += "ZONE_NAME=‘CGBZ‘";
            string b = string.Empty;
            DB.updateData(update_order_inzone, out b);
        }
        private void ScrapReason_comboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            REASON_DESC = ScrapReason_comboBox.SelectedValue.ToString();      
            Console.WriteLine(REASON_DESC);
        }
    }
}

 

精轧跟踪

标签:cep   where   不执行   pre   dialog   source   err   raw   draw   

原文地址:https://www.cnblogs.com/Yolana/p/9426439.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!