how to.check Pan No is Already Exit Or Not In C#






  1.  checking PAN No is already present or not


            if (!string.IsNullOrEmpty(Convert.ToString(ViewState["UserpanID"])))
            {
                if (CheckPannoExistOrNot(txtpanno.Text.Trim()))
                {
                    sb.Append("Pan No Is Already Exists");
                    lblpanError.Text = sb.ToString();
                    sb.Clear();
                    txtpanno.Text = string.Empty;
                    return;
                }
            }

  Private bool CheckPannoExistOrNot(string PanNo)
        {
            bool ReturnVal = false;
            try
            {
                if (ConObj.State != ConnectionState.Open)
                    ConObj.Open();
                using (SqlCommand cmd = new SqlCommand("Sp_Name", ConObj))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@PanNo", PanNo);
                 
                    object Obj = cmd.ExecuteScalar();
                    if (Obj != null)
                    {
                        if (Convert.ToInt32(Obj) > 0)
                            ReturnVal = true;
                    }
                }
            }
            catch (Exception ex)
            {
                lblerror.Text = emd.SendExcepToDB(pageName, MethodBase.GetCurrentMethod().Name.ToString(), HttpContext.Current.Request.Url.ToString(), ex);
            }
            finally
            {
                if (ConObj.State != ConnectionState.Closed)
                    ConObj.Close();
            }
            return ReturnVal;
        }

Comments

Popular posts from this blog

String Program in C#

CSV using XmlNode

Controller_Model. cs