public ResponseMessage getStudentsList(student_details slist)
 {
     if (slist.section_id.Equals(0) || slist.class_id.Equals(0) || slist.school_id.Equals(0))
     {
         rs.code    = 100;
         rs.message = "Enter proper details";
         return(rs);
     }
     else
     {
         var entryPoint = (from ep in entt.student_details
                           join e in entt.school_details on slist.school_id equals e.school_id
                           where ep.school_id == slist.school_id
                           where ep.class_id == slist.class_id
                           where ep.section_id == slist.section_id
                           select new
         {
             ep.student_image,
             ep.student_id,
             studentName = ep.student_first_name + ep.student_last_name,
             student_grade
         });
         rs.Data    = entryPoint;
         rs.code    = 200;
         rs.message = "Data success";
         return(rs);
     }
 }
        public ResponseMessage perticularStudent(student_details sdata)
        {
            var entryPoint = (from ep in entt.student_details
                              where ep.school_id == sdata.school_id
                              where ep.student_id == sdata.student_id
                              where ep.class_id == sdata.class_id
                              where ep.section_id == sdata.section_id
                              select new
            {
                ep.school_id,
                ep.student_admission_date,
                ep.student_area,
                ep.student_buliding_name,
                ep.student_chiled_no,
                ep.student_city,
                ep.student_dob,
                ep.student_father_mobile_no,
                ep.student_father_name,
                ep.student_father_occupation,
                ep.student_first_name,
                ep.student_flat_no,
                ep.student_gender,
                ep.student_image,
                ep.student_last_name,
                ep.student_mother_mobile_no,
                ep.student_mother_name,
                ep.student_mother_occupation,
                ep.student_no_of_siblings,
                ep.student_pincode,
                ep.student_roll_no,
                ep.student_admission_id,
                ep.student_class,
                ep.student_section,
                ep.student_state,
                ep.Student_status,
                ep.student_street,
                ep.student_street1,
                ep.student_id,
                ep.class_id,
                ep.section_id
            });

            rs.Data    = entryPoint;
            rs.code    = 200;
            rs.message = "Data success";
            return(rs);
        }
        public IHttpActionResult updateStudents(student_details sdetails)
        {
            Boolean pp = new StudentDetailsRelated().updateStudentsList(sdetails);

            if (pp)
            {
                rs.code    = 200;
                rs.message = "succesfully data has been updated";
                return(Content(HttpStatusCode.OK, rs));
            }
            else
            {
                rs.code    = 100;
                rs.message = "failed to update";
                return(Content(HttpStatusCode.OK, rs));
            }
        }
        public IHttpActionResult deleteStudent(student_details sdelete)
        {
            Boolean t = new StudentDetailsRelated().deleteStudent(sdelete);

            if (t)
            {
                rs.code    = 200;
                rs.message = "succesfully data has been deleted";
                return(Content(HttpStatusCode.OK, rs));
            }
            else
            {
                rs.code    = 100;
                rs.message = "failure to delete";
                return(Content(HttpStatusCode.OK, rs));
            }
        }
        public IHttpActionResult addingStudentDetails(student_details sdetails)
        {
            Boolean a = new StudentDetailsRelated().addingStudentDetails(sdetails);

            if (a)
            {
                sdetails.insert_date = DateTime.Now;
                entt.student_details.Add(sdetails);
                entt.SaveChanges();

                rs.code    = 200;
                rs.message = "succesfully data has been inserted";
                return(Content(HttpStatusCode.OK, rs));
            }
            else
            {
                rs.code    = 100;
                rs.message = "failed to insert data";
                return(Content(HttpStatusCode.OK, rs));
            }
        }
    protected void login_Click(object sender, EventArgs e)
    {
        if (txt_emailid.Text.Length > 0 && txt_password.Text.Length > 0)
        {
            if (dd_login.Text == "Faculty")
            {
                st = "select * from Faculty where email='" + txt_emailid.Text + "' and Password='******'";
                dt = get_datatable(st);

                if (dt.Rows.Count > 0)
                {
                    int session_faculty = dt.Rows[0]["faculty_id"].GetHashCode();
                    Session["session_faculty"] = session_faculty;
                    Session["faculty"]         = dt.Rows[0][0].ToString();
                    Faculty_details obj = new Faculty_details();
                    obj.EmailID = dt.Rows[0]["email"].ToString();
                    obj.name    = dt.Rows[0]["name"].ToString();

                    Session["faculty_details"] = obj;
                    Response.Redirect("Faculty/dashboard.aspx");
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "showalert('error','Login failed');", true);
                }
            }

            else if (dd_login.Text == "Student")
            {
                st              = "select * from student where email='" + txt_emailid.Text + "' and Password='******'";
                dt              = get_datatable(st);
                Session["std"]  = txt_emailid.Text;
                Session["std1"] = txt_password.Text;
                if (dt.Rows.Count > 0)
                {
                    int session_std = dt.Rows[0]["Reg_number"].GetHashCode();
                    int sem         = dt.Rows[0]["sem"].GetHashCode();
                    Session["sem"]         = sem;
                    Session["dept"]        = dt.Rows[0]["dept"].ToString();
                    Session["session_std"] = session_std;
                    Session["student"]     = dt.Rows[0][0].ToString();
                    student_details obj = new student_details();

                    obj.EmailID = dt.Rows[0]["email"].ToString();
                    obj.name    = dt.Rows[0]["fullname"].ToString();

                    Session["student_details"] = obj;
                    Response.Redirect("student/dashboard.aspx");
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "showalert('error','Login failed');", true);
                }
            }
            else if (dd_login.Text == "Admin")
            {
                st = "select * from admin where email='" + txt_emailid.Text + "' and Password='******'";
                dt = get_datatable(st);

                if (dt.Rows.Count > 0)
                {
                    int session_admin = dt.Rows[0]["admin_id"].GetHashCode();
                    Session["session_admin"] = session_admin;
                    Session["admin"]         = dt.Rows[0][0].ToString();
                    Adminlogin_details objAdminlogin_details = new Adminlogin_details();

                    objAdminlogin_details.fullname = dt.Rows[0]["Name"].ToString();
                    Session["Adminlogin_details"]  = objAdminlogin_details;
                    Response.Redirect("Admin/dashboard.aspx");
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "showalert('error','Login failed');", true);
                }
            }
        }
    }