Beispiel #1
0
        /// <summary>
        /// 比较按钮操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolVersionCompare_Click(object sender, EventArgs e)
        {
            //1.遍历列表中checkbox选中的记录
            IList <string> _compList = new List <string>();

            for (int i = 0; i < dgv_Product.Rows.Count; i++)
            {
                DataGridViewCheckBoxCell checkcell = (DataGridViewCheckBoxCell)dgv_Product.Rows[i].Cells[0];
                Boolean flag = Convert.ToBoolean(checkcell.Value);
                if (flag)
                {
                    string productId = dgv_Product.Rows[i].Cells[1].Value.ToString().Trim();
                    _compList.Add(productId);
                }
            }

            //2.判断是否只选择2条记录
            if (_compList.Count < 2)
            {
                MessageBox.Show("请选择需要比较的两个产品"); return;
            }
            if (_compList.Count > 2)
            {
                MessageBox.Show("只能选择两个产品"); return;
            }

            //3.打开产品比较页面,且将比较的两个产品ID作为参数传递给比较页面
            ProductsCompForm o = new ProductsCompForm(_compList[0].ToString(), _compList[1].ToString());

            o.StartPosition = FormStartPosition.CenterParent;
            o.ShowDialog();
        }
Beispiel #2
0
        /// <summary>
        /// 比较按钮操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolVersionCompare_Click(object sender, EventArgs e)
        {
            //1.遍历列表中checkbox选中的记录
            IList<string> _compList = new List<string>();
            for (int i = 0; i < dgv_Product.Rows.Count; i++)
            {
                DataGridViewCheckBoxCell checkcell = (DataGridViewCheckBoxCell)dgv_Product.Rows[i].Cells[0];
                Boolean flag = Convert.ToBoolean(checkcell.Value);
                if (flag)
                {
                    string productId = dgv_Product.Rows[i].Cells[1].Value.ToString().Trim();
                    _compList.Add(productId);
                }
            }

            //2.判断是否只选择2条记录
            if (_compList.Count < 2)
            {
                MessageBox.Show("请选择需要比较的两个产品"); return;
            }
            if (_compList.Count > 2)
            {
                MessageBox.Show("只能选择两个产品"); return;
            }

            //3.打开产品比较页面,且将比较的两个产品ID作为参数传递给比较页面
            ProductsCompForm o = new ProductsCompForm(_compList[0].ToString(), _compList[1].ToString());
            o.StartPosition = FormStartPosition.CenterParent;
            o.ShowDialog();
        }