You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何限制DataGridView中同一机器数据不重复,仅特定条件允许单次重复?

需求说明
  • 常规规则:DataGridView中不允许同一机器的数据重复提交
  • 例外规则:仅当问题类型为#Temperature Monitoring时,允许该机器的数据重复提交一次

![DataGridView]

现有代码实现
while (read.Read())
{
    if (read["Selected_Problem"] != DBNull.Value && read["Selected_Problem"].ToString() == "#Temperature Monitoring")
    {
        submitToPending2();
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('该机器已通知技术人员。')", true);

        if (read.HasRows)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('该机器当前处于待处理或处理中状态,无法再次提交。')", true);
            clearTextBox();
        }
        else
        {
            submitToPending2();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('该机器已通知技术人员。')", true);
            //Response.Redirect("operatorView.aspx");
        }

        //read.Close();
        //con.Close();
    }
}
read.Close();
con.Close();
while (read.Read())
{
    if (read["Selected_Problem"] != DBNull.Value && read["Selected_Problem"].ToString() == "#Temperature Monitoring")
    {
        submitToPending2();
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('该机器已通知技术人员。')", true);

        if (read.HasRows)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('该机器当前处于待处理或处理中状态,无法再次提交。')", true);
            clearTextBox();
        }
        else
        {
            submitToPending2();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('该机器已通知技术人员。')", true);
            //Response.Redirect("operatorView.aspx");
        }

        //read.Close();
        //con.Close();
    }
}
read.Close();
con.Close();

内容的提问来源于stack exchange,提问作者IZZAT HATTA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 09:38:09