コード例 #1
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     objStudent_BEL.FIRST_NAME = Convert.ToString(txtFirstName.Text);
     try
     {
         Int32 resVal = objStudent_BAL.SaveStudentsDetails(objStudent_BEL);
         if (resVal == 1)
         {
             lblStatus.Text      = "Student details saved Successfully";
             lblStatus.ForeColor = System.Drawing.Color.LawnGreen;
             imgstatus.ImageUrl  = "~/Resources/ico/tick.png";
             imgstatus.Visible   = true;
         }
         else
         {
             lblStatus.Text      = "Student details couldn't be saved";
             lblStatus.ForeColor = System.Drawing.Color.Red;
             imgstatus.ImageUrl  = "~/Resources/ico/cross.png";
             imgstatus.Visible   = true;
         }
     }
     catch (Exception ex)
     {
         Response.Write("Oops! error occured:" + ex.Message.ToString());
     }
     finally
     {
         objStudent_BEL = null;
         objStudent_BAL = null;
     }
 }
コード例 #2
0
        public Int32 SaveStudentsDetails(STUDENT_BEL objBEL)
        {
            SqlDataReader dr      = null;
            dbConnector   objConn = new dbConnector();
            SqlConnection Conn    = objConn.GetConnection;

            Conn.Open();

            SqlCommand cmd = new SqlCommand("ENTER_STUDENT_SP", Conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@FIRST_NAME", objBEL.FIRST_NAME);
            cmd.Parameters.AddWithValue("@MIDDLE_NAME", objBEL.MIDDLE_NAME);
            cmd.Parameters.AddWithValue("@LAST_NAME", objBEL.LAST_NAME);

            cmd.Parameters.AddWithValue("@DATE_OF_ADMISSION", DateTime.Now);
            try
            {
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    if (dr[0].ToString() == "1")
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }

            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        dr.Close();
                        cmd.Dispose();
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
        }
コード例 #3
0
        public Int32 SaveStudentsDetails(STUDENT_BEL objBel)
        {
            STUDENT_DAL objDal = new STUDENT_DAL();

            try
            {
                return(objDal.SaveStudentsDetails(objBel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objDal = null;
            }
        }