datagirdview的单元格双击事件

private void dgvProcess_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
    //得到当前行
    dataGridViewRow = dgvProcess.CurrentRow;
    if (e.ColumnIndex < 0 || e.RowIndex < 0)
    {
        return;
    }
    if (dataGridViewRow != null)
    {
        //修改当前信息
        string lckh = dataGridViewRow.Cells[0].Value.ToString();
        string thick = dataGridViewRow.Cells[1].Value.ToString();
        string color = dataGridViewRow.Cells[2].Value.ToString();
        if (glassThickCom.SelectedValue.ToString() != thick || glasstypeCom.SelectedValue.ToString() != color)
        {
            DialogResult dr = MessageBox.Show("所选的流程卡对应的色系和厚度不一致!是否改成所选的色系厚度?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (dr == DialogResult.Yes)
            {
                //禁用添加行
                this.polyView.AllowUserToAddRows = false;
                while (this.polyView.Rows.Count != 0)
                {
                    this.polyView.Rows.RemoveAt(0);
                }
                //重新启用
                this.polyView.AllowUserToAddRows = true;
                glassThickCom.SelectedValue = thick;
                glasstypeCom.SelectedValue = color;
                polyView.EndEdit();
                if (polyView.CurrentRow != null)
                    refreshSTR(polyView.CurrentRow);
                foreach (DataGridViewRow row in polyView.Rows)
                {
                    //最后一行直接跳出循环
                    //下方定义的基本列用于保存在新的工程附表里
                    if (polyView.AllowUserToAddRows && row.Index == polyView.Rows.Count - 1) break;
                    string liuchengkahao = row.Cells[13].Value.ToString();
                    if (liuchengkahao == lckh)
                    {
                        return;
                    }
                }
                this.stockView.AllowUserToAddRows = false;
                while (this.stockView.Rows.Count != 0)
                { this.stockView.Rows.RemoveAt(0); }
                while (this.dgvProcess.Rows.Count != 0)
                { this.dgvProcess.Rows.RemoveAt(0); }
                //每次刷新重新绑定查询右方流程卡数据
                dgvProcessDataBind();
                this.stockView.AllowUserToAddRows = true;
                GetKuCunDataByYouHua(thick, color);
                GetXiaoPianByYouHua(lckh, thick, color);
            }
            List<string> strList = new List<string>();
            int count = this.polyView.Rows.Count - 1;
            if (count > 0) {
                for (int i = 0; i < count; i++)
                {
                    string alckh = polyView.Rows[i].Cells[13].Value.ToString();//流程卡号
                    strList.Add(alckh);//循环添加元素
                }
                string[] lckhArr = GetString(strList.Distinct().ToArray());//去除重复的流程卡号
                for(int j = 0; j < count; j++)
                {
                    string alckh = polyView.Rows[j].Cells[13].Value.ToString().Trim();//流程卡号
                    string jh = GetJH(alckh, lckhArr);
                    if (jh != "方法未完成")
                    {
                        polyView.Rows[j].Cells[21].Value = jh;
                    }
                }

            }
            return;
        }
        else
        {
            polyView.EndEdit();
            if (polyView.CurrentRow != null)
                refreshSTR(polyView.CurrentRow);
            foreach (DataGridViewRow row in polyView.Rows)
            {
                //最后一行直接跳出循环
                //下方定义的基本列用于保存在新的工程附表里
                if (polyView.AllowUserToAddRows && row.Index == polyView.Rows.Count - 1) break;
                string liuchengkahao = row.Cells[13].Value.ToString();
                if (liuchengkahao == lckh)
                {
                    return;
                }
            }
            //glassThickCom.SelectedValue = thick;//赋值下拉框
            //glasstypeCom.SelectedValue  = color;//赋值下拉框
            //MessageBox.Show(lckh + ","+ thick + ","+ color);
            this.stockView.AllowUserToAddRows = false;
            while (this.stockView.Rows.Count != 0)
            { this.stockView.Rows.RemoveAt(0); }
            while (this.dgvProcess.Rows.Count != 0)
            { this.dgvProcess.Rows.RemoveAt(0); }
            //每次刷新重新绑定查询右方流程卡数据
            dgvProcessDataBind();
            this.stockView.AllowUserToAddRows = true;
            GetKuCunDataByYouHua(thick, color);//库存信息匹配
            GetXiaoPianByYouHua(lckh, thick, color);
            List<string> strList = new List<string>();
            int count = this.polyView.Rows.Count - 1;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    string alckh = polyView.Rows[i].Cells[13].Value.ToString();//流程卡号
                    strList.Add(alckh);//循环添加元素
                }
                string[] lckhArr = GetString(strList.Distinct().ToArray());//去除重复的流程卡号
                for (int j = 0; j < count; j++)
                {
                    string alckh = polyView.Rows[j].Cells[13].Value.ToString().Trim();//流程卡号
                    string jh = GetJH(alckh, lckhArr);
                    if (jh != "方法未完成")
                    {
                        polyView.Rows[j].Cells[21].Value = jh;
                    }
                }

            }
        }
    }
  
}
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

no longer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值