如何获取确认对话框(“您是否要覆盖记录?”)在Side My For Loop C#代码中? [英] How Do I Get Confirm Dialog ("Do You Want To Override The Record?") In Side My For Loop C# Code?

查看:64
本文介绍了如何获取确认对话框(“您是否要覆盖记录?”)在Side My For Loop C#代码中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  for  int  j =  0 ; j <  noOfdays; j ++)
{
// 检查记录是否存在
int attCount = .... ........;
// 记录不存在
if (attCount == 0
{
// 这里我已经为数据库编写了插入代码
}
// 记录存在
else
{
// 这里我的wana show确认框(你是否覆盖现有记录?)
// **如果是,那么我通过函数调用覆盖记录,然后再次继续循环。
// **如果否则循环将继续
}
}

解决方案

  for  int  j =  0 ; j <  noOfdays; j ++)
{
// 检查记录是否存在
int attCount = ............;
// 记录不存在
if (attCount == 0
{
// 这里我已经为数据库编写了插入代码
}
// 记录存在
else
{
if (MessageBox.Show( 你是否覆盖现有记录?
确认!!,MessageBoxButtons.YesNo)== System.Windows .Forms.DialogResult.Yes){

// 通过函数调用覆盖记录,然后再次继续循环。
}

}
}


这个小片段可以帮助您开始学习。



 DialogResult dr = MessageBox.Show(  Are你确定要退出吗? 退出应用程序,MessageBoxButtons.YesNo, MessageBoxIcon.Question); 
if (dr == System.Windows.Forms.DialogResult.Yes)
{
.Close();
}


 System.Web.UI.ScriptManager.RegisterClientScriptBlock( this  this  .GetType(),  AlertBox  confirm('你想覆盖记录') ; true ); 


 for (int j = 0; j < noOfdays; j++)
 {
//check record present or not
  int attCount = ............;
//record is not there
  if (attCount == 0)
   {
     //here i have written insert code to data base                     
   }
//record present
   else
   {
   //here i wana show confirm box(do you wana override the existing record?)
    // ** if yes then i override the record by a function call,then continue the loop again.
     //** if no then the loop will continue
   }
  }

解决方案

for (int j = 0; j < noOfdays; j++)
 {
//check record present or not
  int attCount = ............;
//record is not there
  if (attCount == 0)
   {
     //here i have written insert code to data base
   }
//record present
   else
   {
      if (MessageBox.Show("do you wana override the existing record?", 
            "Confirm!!", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes){

            // override the record by a function call,then continue the loop again.
        }

   }
  }


This small snippet should get you started on what you are after.

DialogResult dr = MessageBox.Show("Are you sure you want to exit?", "Exit Application", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == System.Windows.Forms.DialogResult.Yes)
{
    this.Close();
}


System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "confirm('Do You want to override the record');", true);


这篇关于如何获取确认对话框(“您是否要覆盖记录?”)在Side My For Loop C#代码中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆