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;
}
}
}
}
}
}
datagirdview的单元格双击事件
最新推荐文章于 2022-02-09 16:52:44 发布