Example #1
0
        public int SaveYear(YearEntities yearEntities)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolDBConnectionString"].ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("stpSaveYear", con);

            cmd.CommandType = CommandType.StoredProcedure;

            //if (!String.IsNullOrEmpty(yearEntities.Year))
            //{
            //    cmd.Parameters.AddWithValue("@Year", yearEntities.Year);
            //}
            //else
            //{
            //    cmd.Parameters.AddWithValue("@Year", DBNull.Value);
            //}
            cmd.Parameters.AddWithValue("@Year", yearEntities.Year);

            //if (!String.IsNullOrEmpty(yearEntities.YearDesc))
            //{
            //    cmd.Parameters.AddWithValue("@YearDesc", yearEntities.YearDesc);
            //}
            //else
            //{
            //    cmd.Parameters.AddWithValue("@YearDesc", DBNull.Value);
            //}
            cmd.Parameters.AddWithValue("@YearDesc", yearEntities.YearDesc);

            if (yearEntities.ID > 0)
            {
                cmd.Parameters.AddWithValue("@ID", yearEntities.ID);
            }
            else
            {
                cmd.Parameters.AddWithValue("@ID", DBNull.Value);
            }

            int recordsAffected = cmd.ExecuteNonQuery();

            con.Close();
            return(recordsAffected);
        }
Example #2
0
        public int SaveYear(YearEntities yearEntities)
        {
            YearDAL yearDAL = new YearDAL();

            return(yearDAL.SaveYear(yearEntities));
        }
Example #3
0
        public JsonResult Add(YearEntities yearEntities)
        {
            YearBL yearBL = new YearBL();

            return(Json(yearBL.SaveYear(yearEntities), JsonRequestBehavior.AllowGet));
        }