如何限制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
相关产品推荐
相关产品推荐

