Exemplo n.º 1
0
        public void GetSubjects()
        {
            List <addstudent> listStdInfo = new List <addstudent>();

            listStdInfo.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("SELECT * FROM subjects", con);
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    addstudent StdInfo = new addstudent();
                    StdInfo.std_id    = Convert.ToInt32(rdr["subjects_id"]);
                    StdInfo.std_name  = rdr["subjects_name"].ToString();
                    StdInfo.std_class = rdr["total_marks"].ToString();
                    listStdInfo.Add(StdInfo);
                }
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listStdInfo).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listStdInfo));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
Exemplo n.º 2
0
        public async Task <ActionResult> EditStudent(string id, addstudent updatestudent)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://www.edujinni.in/");
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Accept.Clear();
                updatestudent.school_id              = 1;
                updatestudent.student_section        = "chess";
                updatestudent.student_class          = "1";
                updatestudent.section_id             = 3;
                updatestudent.class_id               = 6;
                updatestudent.student_admission_id   = "123";
                updatestudent.insert_by              = "";
                updatestudent.update_by              = "sai";
                updatestudent.student_admission_date = DateTime.Now;
                updatestudent.Student_status         = "sai";
                HttpResponseMessage response = await client.PostAsJsonAsync("updateStudentDetails", updatestudent);

                if (response.IsSuccessStatusCode)
                {
                    Response.Write("<script>alert('Student Details Updated')</script>");
                    return(RedirectToAction("StudentsOverView"));
                }
                else
                {
                    Response.Write("<script>alert('Error Updating the Student')</script>");
                }
            }
            return(View(updatestudent));
        }
        public void EditTecherInfo(addstudent ObjEditStdInfo)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(cs))
            {
                connection.Open();
                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;
                string varPassword = GetMD5HashData(ObjEditStdInfo.std_password);
                command.CommandText = "UPDATE addteacher SET t_name ='" + ObjEditStdInfo.std_name + "',t_lastname ='" + ObjEditStdInfo.std_lastname + "', t_father ='" + ObjEditStdInfo.std_father + "',t_gender ='" + ObjEditStdInfo.std_gender + "', t_phone_no ='" + ObjEditStdInfo.std_phone_no + "' WHERE t_id= '" + ObjEditStdInfo.std_id + "'";
                command.ExecuteNonQuery();
                command.CommandText = "UPDATE login SET login_name ='" + ObjEditStdInfo.std_name + "',login_email ='" + ObjEditStdInfo.std_email + "',login_password ='******' WHERE member_id= '" + ObjEditStdInfo.std_id + "'";
                command.ExecuteNonQuery();
                transaction.Commit();
            }

            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        public void GetTecherInfo()
        {
            List <addstudent> listStdInfo = new List <addstudent>();

            listStdInfo.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("SELECT * FROM addteacher ,login where login.member_id=addteacher.t_id  ", con);
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    addstudent StdInfo = new addstudent();
                    StdInfo.std_id       = Convert.ToInt32(rdr["t_id"]);
                    StdInfo.std_name     = rdr["t_name"].ToString();
                    StdInfo.std_father   = rdr["t_father"].ToString();
                    StdInfo.std_phone_no = rdr["t_phone_no"].ToString();
                    StdInfo.std_gender   = rdr["t_gender"].ToString();
                    StdInfo.std_lastname = rdr["t_lastname"].ToString();
                    StdInfo.std_email    = rdr["login_email"].ToString();
                    StdInfo.std_password = rdr["login_password"].ToString();
                    listStdInfo.Add(StdInfo);
                }
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listStdInfo).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listStdInfo));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
Exemplo n.º 5
0
 public ActionResult EditStudent(string id, string name, addstudent studedetails)
 {
     using (var client = new HttpClient())
     {
         client.BaseAddress      = new Uri("http://www.edujinni.in/");
         studedetails.school_id  = 1;
         studedetails.student_id = id;
         studedetails.class_id   = 6;
         studedetails.section_id = 3;
         var upd = client.PostAsJsonAsync <addstudent>("perticularStudent", studedetails);
         upd.Wait();
         var result = upd.Result;
         if (result.IsSuccessStatusCode)
         {
             var                resultt = result.Content.ReadAsStringAsync().Result;
             JObject            o       = JObject.Parse(resultt);
             JArray             a       = (JArray)o["Data"];
             IList <addstudent> stu     = a.ToObject <IList <addstudent> >();
             foreach (var item in stu)
             {
                 if (id == item.student_id)
                 {
                     at.student_first_name       = item.student_first_name;
                     at.student_last_name        = item.student_last_name;
                     at.student_section          = item.student_section;
                     at.student_admission_date   = item.student_admission_date;
                     at.student_gender           = item.student_gender;
                     at.student_father_mobile_no = item.student_father_mobile_no;
                     at.student_dob               = item.student_dob;
                     at.student_father_name       = item.student_father_name;
                     at.student_father_occupation = item.student_father_occupation;
                     at.student_mother_name       = item.student_mother_name;
                     at.student_mother_mobile_no  = item.student_mother_mobile_no;
                     at.student_mother_occupation = item.student_mother_occupation;
                     at.student_chiled_no         = item.student_chiled_no;
                     at.student_no_of_siblings    = item.student_no_of_siblings;
                     at.student_flat_no           = item.student_flat_no;
                     at.student_buliding_name     = item.student_buliding_name;
                     at.student_street            = item.student_street;
                     at.student_area              = item.student_area;
                     at.student_city              = item.student_city;
                     at.student_state             = item.student_state;
                     at.student_pincode           = item.student_pincode;
                     at.student_roll_no           = item.student_roll_no;
                     at.student_id = item.student_id;
                 }
             }
         }
         else
         {
             Response.Write("<script>alert('Error Retreiving Details');</script>");
         }
     }
     ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
     return(View(at));
 }
        public void DelClasses(addstudent ObjDelStdInfo)
        {
            string connectionCS = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection objconn = new SqlConnection(connectionCS))
            {
                objconn.Open();
                SqlCommand cmd3 = new SqlCommand("DELETE FROM classes WHERE classes_id = '" + ObjDelStdInfo.std_id + "'", objconn);
                cmd3.ExecuteNonQuery();
                objconn.Close();
            }
        }
Exemplo n.º 7
0
        public void fnAddSubject(addstudent ObjAddStd)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(cs))
            {
                connection.Open();
                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;
                string exist = "";
                command.CommandText = "SELECT * FROM subjects WHERE subjects_name ='" + ObjAddStd.std_name + "'";
                SqlDataAdapter objadp = new SqlDataAdapter(command.CommandText, connection);
                objadp.SelectCommand.Transaction = transaction;
                DataTable dtr = new DataTable();
                objadp.Fill(dtr);
                foreach (DataRow dtrow in dtr.Rows)
                {
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "found";
                    listrecexist.Add(Objrecexist);
                    exist = "found";
                }
                if (exist == "")
                {
                    command.CommandText = "INSERT INTO subjects (subjects_name, total_marks) VALUES ('" + ObjAddStd.std_name + "', '" + ObjAddStd.std_lastname + "')" + "SELECT SCOPE_IDENTITY()";
                    string insertedID = command.ExecuteScalar().ToString();



                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "Not Found";
                    listrecexist.Add(Objrecexist);
                }
                transaction.Commit();
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        public void DelTecherInfo(addstudent ObjDelStdInfo)
        {
            string connectionCS = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection objconn = new SqlConnection(connectionCS))
            {
                objconn.Open();
                SqlCommand cmd3 = new SqlCommand("DELETE FROM addteacher WHERE t_id = '" + ObjDelStdInfo.std_id + "'", objconn);
                cmd3.ExecuteNonQuery();
                objconn.Close();
                objconn.Open();
                SqlCommand cmd4 = new SqlCommand("DELETE FROM login WHERE member_id = '" + ObjDelStdInfo.std_id + "'", objconn);
                cmd4.ExecuteNonQuery();
                objconn.Close();
            }
        }
Exemplo n.º 9
0
        public void UpdateSubject(addstudent ObjEditStdInfo)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string ConnectionString = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection objcon = new SqlConnection(ConnectionString))
            {
                //objcon.Open();
                //SqlCommand cmd3 = new SqlCommand("SELECT subjects_name FROM subjects WHERE subjects_name ='" + ObjEditStdInfo.std_name + "'", objcon);
                //SqlDataReader re = null;
                //re = cmd3.ExecuteReader();
                //if (re.HasRows)
                //{
                //    recexist Objrecexist = new recexist();
                //    Objrecexist.Dataexist = "found";
                //    listrecexist.Add(Objrecexist);
                //}
                //else
                //{
                objcon.Close();
                objcon.Open();
                SqlCommand cmnd2 = new SqlCommand("UPDATE subjects SET subjects_name ='" + ObjEditStdInfo.std_name + "',total_marks ='" + ObjEditStdInfo.std_lastname + "' WHERE subjects_id= '" + ObjEditStdInfo.std_id + "'", objcon);
                cmnd2.ExecuteNonQuery();
                objcon.Close();
                recexist Objrecexist = new recexist();
                Objrecexist.Dataexist = "Not Found";
                listrecexist.Add(Objrecexist);
                //}
                //objcon.Close();
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        public void Addclasses(addstudent ObjAddStd)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string ConnectionString = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection objcon = new SqlConnection(ConnectionString))
            {
                objcon.Open();
                SqlCommand    cmd3 = new SqlCommand("SELECT classes_name FROM classes WHERE classes_name ='" + ObjAddStd.std_name + "'", objcon);
                SqlDataReader re   = null;
                re = cmd3.ExecuteReader();
                if (re.HasRows)
                {
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "found";
                    listrecexist.Add(Objrecexist);
                }
                else
                {
                    objcon.Close();
                    objcon.Open();
                    SqlCommand cmnd2 = new SqlCommand("INSERT INTO classes (classes_name) VALUES ('" + ObjAddStd.std_name + "')", objcon);
                    cmnd2.ExecuteNonQuery();
                    objcon.Close();
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "Not Found";
                    listrecexist.Add(Objrecexist);
                }
                objcon.Close();
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
Exemplo n.º 11
0
        public async Task <ActionResult> AddStudent(addstudent model)
        {
            List <SelectListItem> li = new List <SelectListItem>();

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://www.edujinni.in/");
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Accept.Clear();
                model.school_id              = 1;
                model.class_id               = 5;
                model.section_id             = 4;
                model.student_section        = "c";
                model.student_chiled_no      = 1;
                model.insert_by              = "ss";
                model.insert_date            = DateTime.Now;
                model.update_by              = "";
                model.update_date            = DateTime.Now;
                model.student_section        = "c";
                model.student_admission_date = DateTime.Now;
                model.Student_status         = "sai";
                model.student_class          = "1st class";
                model.student_admission_id   = "1234";
                model.student_password       = "******";
                model.parent_password        = "******";
                HttpResponseMessage response = await client.PostAsJsonAsync("addingStudentDetails", model);

                HttpResponseMessage classes = await client.PostAsJsonAsync("classNames/classDetailsList", model);

                HttpResponseMessage sections = await client.PostAsJsonAsync("sectionList", model);

                if (classes.IsSuccessStatusCode == true)
                {
                    var                classnames   = classes.Content.ReadAsStringAsync().Result;
                    JObject            cl           = JObject.Parse(classnames);
                    JArray             cll          = (JArray)cl["Data"];
                    IList <addstudent> classdetails = cll.ToObject <IList <addstudent> >();
                    ViewBag.clsname = classdetails;
                    List <Edujinni.Models.addstudent> p = (List <Edujinni.Models.addstudent>)classdetails;
                    foreach (var item in p)
                    {
                        li.Add(new SelectListItem()
                        {
                            Text = item.student_class, Value = item.class_id.ToString()
                        });
                    }
                }
                if (response.IsSuccessStatusCode == true)
                {
                    Response.Write("<script>alert('Student Added successfully')</script>");
                    return(RedirectToAction("StudentsOverView"));
                }
                else
                {
                    Response.Write("<script>alert('Error adding Student')</script>");
                    ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
                }
            }

            return(View(model));
        }
        public void fnAddStd(addstudent ObjAddStd)
        {
            List <recexist> listrecexist = new List <recexist>();

            listrecexist.Clear();
            string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(cs))
            {
                connection.Open();
                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;
                transaction         = connection.BeginTransaction("SampleTransaction");
                command.Connection  = connection;
                command.Transaction = transaction;
                string varPassword = GetMD5HashData(ObjAddStd.std_password);
                string exist       = "";
                command.CommandText = "SELECT std_name FROM add_std_info WHERE std_name ='" + ObjAddStd.std_name + "' AND std_father ='" + ObjAddStd.std_father + "' AND classes_id ='" + ObjAddStd.std_class + "' AND std_gender ='" + ObjAddStd.std_gender + "' AND std_phone_no ='" + ObjAddStd.std_phone_no + "'";
                objadp = new SqlDataAdapter(command.CommandText, connection);
                objadp.SelectCommand.Transaction = transaction;
                dtr = new DataTable();
                objadp.Fill(dtr);
                foreach (DataRow dtrow in dtr.Rows)
                {
                    recexist Objrecexist = new recexist();
                    Objrecexist.Dataexist = "found";
                    listrecexist.Add(Objrecexist);
                    exist = "found";
                }
                if (exist == "")
                {
                    command.CommandText = "INSERT INTO add_std_info (std_name, std_lastname,std_father,std_gender, classes_id, std_phone_no) VALUES ('" + ObjAddStd.std_name + "', '" + ObjAddStd.std_lastname + "','" + ObjAddStd.std_father + "', '" + ObjAddStd.std_gender + "', '" + ObjAddStd.std_class + "', '" + ObjAddStd.std_phone_no + "')" + "SELECT SCOPE_IDENTITY()";
                    string insertedID = command.ExecuteScalar().ToString();

                    command.CommandText = "SELECT login_email FROM login WHERE login_email ='" + ObjAddStd.std_email + "' ";
                    objadp = new SqlDataAdapter(command.CommandText, connection);
                    objadp.SelectCommand.Transaction = transaction;
                    dtr = new DataTable();
                    objadp.Fill(dtr);
                    foreach (DataRow dtrow in dtr.Rows)
                    {
                        recexist Objrecexist = new recexist();
                        Objrecexist.Dataexist = "found_email";
                        listrecexist.Add(Objrecexist);
                        exist = "found_email";
                    }


                    if (exist == "")
                    {
                        command.CommandText = "INSERT INTO login (login_email, login_password,login_name,login_type,member_id) VALUES ( '" + ObjAddStd.std_email + "', '" + varPassword + "','" + ObjAddStd.std_name + "','student','" + insertedID + "')";
                        command.ExecuteNonQuery();

                        recexist Objrecexist = new recexist();
                        Objrecexist.Dataexist = "Not Found";
                        listrecexist.Add(Objrecexist);
                        transaction.Commit();
                    }
                }
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            Context.Response.AddHeader("content-length", js.Serialize(listrecexist).Length.ToString());
            Context.Response.Flush();
            Context.Response.Write(js.Serialize(listrecexist));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }