Exemplo n.º 1
0
        public int SaveSubject(SubjectEntities subjectEntities)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolDBConnectionString"].ConnectionString);

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

            cmd.CommandType = CommandType.StoredProcedure;

            if (String.IsNullOrEmpty(subjectEntities.ID.ToString()) || (subjectEntities.ID == 0))
            {
                cmd.Parameters.AddWithValue("@Id", DBNull.Value);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Id", subjectEntities.ID);
            }

            cmd.Parameters.AddWithValue("@SubjectName", subjectEntities.SubjectName);

            //cmd.Parameters.AddWithValue("@GradeID", subjectEntities.GradeID);

            int recordsAffected = cmd.ExecuteNonQuery();

            con.Close();
            return(recordsAffected);
        }
Exemplo n.º 2
0
        public JsonResult Add(SubjectEntities subjectEntities)
        {
            //SubjectEntities x = new SubjectEntities();

            //x = JsonConvert.DeserializeObject<SubjectEntities>(subjectEntities);

            Subject2BL subjectBL = new Subject2BL();

            return(Json(subjectBL.SaveSubject(subjectEntities), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Database.SetInitializer(new DataInitializer());

            SubjectEntities context = new SubjectEntities();

            foreach (var human in context.Humans)
            {
                Console.WriteLine(human.ToString());
            }

            Console.ReadLine();
        }
Exemplo n.º 4
0
        public SubjectEntities GetSubjectByID(int ID)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolDBConnectionString"].ConnectionString);

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

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Id", ID);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            con.Close();
            SubjectEntities subjectEntities = new SubjectEntities();

            subjectEntities.ID          = Convert.ToInt32(ds.Tables[0].Rows[0]["ID"].ToString());
            subjectEntities.SubjectName = Convert.ToString(ds.Tables[0].Rows[0]["SubjectName"]);
            //subjectEntities.GradeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GradeID"]);
            return(subjectEntities);
        }
Exemplo n.º 5
0
        public int SaveSubject(SubjectEntities subjectEntities)
        {
            Subject2DAL subjectDAL = new Subject2DAL();

            return(subjectDAL.SaveSubject(subjectEntities));
        }
Exemplo n.º 6
0
        public JsonResult Add(SubjectEntities subjectEntities)
        {
            SubjectBL subjectBL = new SubjectBL();

            return(Json(subjectBL.SaveSubject(subjectEntities), JsonRequestBehavior.AllowGet));
        }