Guest User

Guest User

  • Tech Writer
  • 254
  • 12.8k

check mobile is incorrect or pin is not generated

Aug 4 2022 9:37 AM

i want if mobile number is incorrect it display "mobile is incorrect" or pin is not generated

i want changes in stored procedure.below is Stored procedure

ALTER PROCEDURE [dbo].[usp_Downloadreportgetpin]    
 @CaseID varchar(50),    
 @Pin varchar(6),    
 @MobileNo varchar(12)   
AS    
BEGIN    
  Select T1.*,T2.Mobileno from [reportdownloadpin] as T1 inner join comm_SenderType as T2 on T1.CaseId=T2.Fsl_CaseID 
  where Pin=@Pin and  CaseId=@CaseID 
end 

 

        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            SqlDataAdapter adp = new SqlDataAdapter();
            try
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["my connection string"].ConnectionString);
                SqlCommand cmd = new SqlCommand("usp_Downloadreportgetpin", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@CaseID", txtcaseid.Text.Trim());
                cmd.Parameters.AddWithValue("@MobileNo", txtmobileno.Text.Trim());
                cmd.Parameters.AddWithValue("@Pin", txtpin.Text.Trim());
                adp.SelectCommand = cmd;
                adp.Fill(dt);
                
                if (dt.Rows.Count == 0)
                {
                    lblmob.Text = "Case examination is under process-PIN not generated";
                }

                else
                {
                    lblmob.Text = "sucess";

                }

                cmd.Dispose();
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Oops!! following error occured : " + ex.Message.ToString() + "');", true);
            }
            finally
            {
                dt.Clear();
                dt.Dispose();
                adp.Dispose();
            }
        }
 


Answers (6)