if (isnew_record) { var _bll = new businesslogiclayer(); if (_bll.CheckExistingRecord(txtReferenceNo.Text.ToString().Trim()) > 0) { lblError.Text = "Reference Number already exists."; return; } }
Business Logic Layer
public int CheckExistingRecord(string refnumber) { var _dal = new dataacceslayer(); return _dal.CheckExistingRecord(refnumber); }
Data Access Layer
internal int CheckExistingRecord(string refnumber) { base.com.CommandText = "select count(refnumber) from tablename where refnumber = @refnumber"; base.com.Parameters.AddWithValue("@refnumber", refnumber); return Convert.ToInt32(base.com.ExecuteScalar()); }