اين كد رو بزار تو برنامت
exeption كه رخ داد اين تابع رو با exeption رخ داده صدا بزن
public static bool Message_Exeption(Exception ex)
{
try
{
SqlException ar = (SqlException)ex;
if (((ar.Number == 17) | (ar.Number == 17142)) | (ar.Number == 11))
{
MessageBox.Show("ارتباط با بانک اطلاعاتی قطع شده است", "", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return true;
}
if (ar.Number == 547)
{
MessageBox.Show("این اطلاعات به علت به کار رفتن در قسمتی دیگر از سیستم قابل حذف نیستند", "", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return true;
}
if (ar.Number.Equals(2627))
{
MessageBox.Show("اين کد قبلا ثبت شده است", "", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return true;
}
}
catch { }
return false;
}