FrmSureAddCom.cs 3.9 KB


using log4net; 
using System;
using System.Collections.Generic; 
using System.Linq;
using System.Reflection; 
using System.Windows.Forms; 
using TSA_V.DeviceLibrary; 

namespace TSA_V
{
    public partial class FrmSureAddCom : FrmBase
    {
        public List<BoardInfo> boardInfos = new List<BoardInfo>();
        public List<BoardInfo> SelBoardList = new List<BoardInfo>();
        public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public FrmSureAddCom(List<BoardInfo> boardInfos)
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
            LanguagePro();
            this.boardInfos = boardInfos;
            LoadBoardInfo();
        }
        private void LanguagePro()
        {

            this.dataGridViewImageColumn1.HeaderText = ResourceCulture.GetString(ResourceCulture.ItemText_Up, "上升");
            this.dataGridViewImageColumn2.HeaderText = ResourceCulture.GetString(ResourceCulture.ItemText_Down, "下降");


            this.Column_BoardName.HeaderText = ResourceCulture.GetString("boardName", "程序名称");
            this.Column_bomName.HeaderText = ResourceCulture.GetString("bomName", "Bom名称");
            this.Column_num.HeaderText = ResourceCulture.GetString("poingtNum", "组装数量");
            this.Column_NeedAdd.HeaderText = ResourceCulture.GetString("NeedAdd", "需要添加");

        }
        private void FrmSureAddCom_Load(object sender, EventArgs e)
        {

            LanguageProcess();
            LanguagePro();
        }


        private void LoadBoardInfo()
        {

            this.dgvList.Rows.Clear();
            foreach (BoardInfo board in boardInfos)
            {
                if (board != null)
                {
                    dgvList.Rows.Add(setBoard(null, board));
                }
            }


        }
        private DataGridViewRow setBoard(DataGridViewRow view, BoardInfo board)
        {
            if (view == null)
            {
                view = new DataGridViewRow();
                view.CreateCells(dgvList);
            }

            view.Cells[Column_NeedAdd.Index].Value = true;
            view.Cells[Column_bomName.Index].Value = board.bomName;
            view.Cells[Column_BoardName.Index].Value = board.boardName;
            view.Cells[Column_num.Index].Value = board.smtList.Count;

            return view;
        }

        private bool isRun = false;
        private bool IsProcess = false;
        private void timer_Elapsed(object sender, EventArgs e)
        {
            if (IsProcess) { return; }
            IsProcess = true;

            IsProcess = false;
        }

        private void FrmBoardInfo_FormClosing(object sender, FormClosingEventArgs e)
        {
        }


        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1 && e.ColumnIndex >= 0)
            {
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            SelBoardList = new List<BoardInfo>();
            for (int i = 0; i < dgvList.Rows.Count; i++)
            {
                bool check = Convert.ToBoolean(dgvList.Rows[i].Cells[Column_NeedAdd.Index].Value);
                if (check)
                {
                    string boardName = Convert.ToString(dgvList.Rows[i].Cells[Column_BoardName.Index].Value);
                    var v = (from m in boardInfos where m.boardName == boardName select m).FirstOrDefault();
                    if (v != null)
                    {
                        SelBoardList.Add(v);
                    }
                }
            }
            this.DialogResult = DialogResult.OK;
            Close();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;

            Close();
        }
    }
}