Esempio n. 1
0
        private void insertLastSetting()
        {
            try
            {
                bool          isInsert = false;
                YBChannelInfo ybc      = ProDefine.g_YBsetting.Where(m => m.YBName == comboBox1.Text).SingleOrDefault();
                if (ybc == null)
                {
                    ybc        = new YBChannelInfo();
                    isInsert   = true;
                    ybc.YBList = new List <YBSetuse>();
                    ybc.YBName = comboBox1.Text;
                }


                int settingCount = this.dataGridView1.Rows.Count - 1;

                for (int i = 0; i < settingCount; i++)
                {
                    YBSetuse ybs;
                    if (isInsert)
                    {
                        ybs = new YBSetuse();
                    }
                    else
                    {
                        ybs = ybc.YBList[i];
                    }

                    ybs.GNFunction = this.dataGridView1.Rows[i].Cells[0].Value.ToString();
                    string ChannelInfo = this.dataGridView1.Rows[i].Cells[1].Value.ToString();
                    string TypeStr     = this.dataGridView1.Rows[i].Cells[2].Value.ToString();
                    int    _index      = ChannelInfo.IndexOf('-');
                    int    ChannleID   = Convert.ToInt32(ChannelInfo.Substring(_index + 1, ChannelInfo.Length - _index - 1));
                    ybs.ChannelID   = ChannleID;
                    ybs.ChannelType = TypeStr;
                    if (isInsert)
                    {
                        ybc.YBList.Add(ybs);
                    }
                }
                if (isInsert)
                {
                    ProDefine.g_YBsetting.Add(ybc);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            NoSelcetYBName = this.comboBox1.Items[comboBox1.SelectedIndex].ToString();
            if (NoSelcetYBName != LastSelcetYBName)
            {
                if (LastSelcetYBName == "")
                {
                    LastSelcetYBName = this.comboBox1.Items[comboBox1.SelectedIndex].ToString();
                }
                else if ((this.dataGridView1.Rows.Count - 1) > 0)
                {
                    if (ProDefine.g_YBsetting.Count == 0)
                    {
                        insertANewYBSet();
                        ClearSettingColumn();
                    }
                    else
                    {
                        int PreCount = ProDefine.g_YBsetting[0].YBList.Count;
                        if (PreCount != (this.dataGridView1.Rows.Count - 1))
                        {
                            MessageBox.Show("本次配置样本通道数目和上次不符");
                            return;
                        }

                        YBChannelInfo ybc = ProDefine.g_YBsetting.Where(m => m.YBName == NoSelcetYBName).SingleOrDefault();
                        if (ybc == null)
                        {
                            insertANewYBSet();
                            ClearSettingColumn();
                        }
                        else
                        {
                            insertANewYBSet();
                            this.dataGridView1.Rows.Clear();
                            int RowCount = ybc.YBList.Count;
                            foreach (var info in ybc.YBList)
                            {
                                int RowIndex = this.dataGridView1.Rows.Add();
                                this.dataGridView1.Rows[RowIndex].Cells[0].Value = info.GNFunction;
                                this.dataGridView1.Rows[RowIndex].Cells[1].Value = info.ChannelType + "-" + info.ChannelID.ToString();
                                this.dataGridView1.Rows[RowIndex].Cells[2].Value = info.ChannelType;
                            }
                        }
                    }
                    LastSelcetYBName = NoSelcetYBName;
                    //ClearSettingColumn();
                }
            }
        }