Beispiel #1
0
        public JsonResult Select_studentdocument()
        {
            StudentRepository       objRepository = new StudentRepository();
            DataSet                 ds            = objRepository.select_studentdocument(Session["studentid"].ToString());
            List <student_document> _list         = new List <student_document>();

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        student_document objdoc = new student_document();
                        objdoc.document_name = row["document_name"].ToString();
                        objdoc.document_path = row["document_path"].ToString();
                        objdoc.studentid     = row["studentid"].ToString();
                        _list.Add(objdoc);
                    }
                }
            }
            return(Json(new
            {
                List = _list
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }
        public JsonResult Savestudentdocument(student_document _obj)
        {
            string path     = "";
            string filename = "";
            string fname    = "";

            _obj.created_by = TempData.Peek("Studentid").ToString();
            _obj.studentid  = TempData.Peek("Studentid").ToString();
            TempData.Keep("Studentid");
            // _obj.CREATED_IP = Session["localIP"].ToString();
            if (Request.Files.Count > 0)
            {
                if (Request.Files[0].ContentLength > 0)
                {
                    HttpFileCollectionBase files = Request.Files;
                    path     = AppDomain.CurrentDomain.BaseDirectory + "Uploads/studentDocument/" + TempData.Peek("Studentid").ToString();
                    filename = Path.GetFileName(Request.Files[0].FileName);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    else
                    {
                        string[] curentfiles = Directory.GetFiles(path);
                    }
                    HttpPostedFileBase file = files[0];
                    filename = _obj.document_name + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(file.FileName);
                    fname    = Path.Combine(Server.MapPath("~/Uploads/studentDocument/" + TempData.Peek("Studentid").ToString()), filename);
                    file.SaveAs(fname);
                    _obj.document_path = "/Uploads/studentDocument/" + TempData.Peek("Studentid").ToString() + "/" + filename;
                }
                else
                {
                    _obj.document_path = "";
                }
            }
            else
            {
                _obj.document_path = "";
            }
            StudentRepository objRepository = new StudentRepository();
            DataSet           ds            = objRepository.insert_studentdocument(_obj);
            bool flag = false;

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    flag = true;
                }
            }
            return(Json(new
            {
                flag = flag
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }
        public JsonResult Select_studentdocument()
        {
            StudentRepository objRepository = new StudentRepository();
            DataSet           ds            = objRepository.select_studentdocument(TempData.Peek("Studentid").ToString());

            TempData.Keep("Studentid");
            List <student_document> _list = new List <student_document>();
            string student_path           = "";

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        student_document objdoc = new student_document();

                        objdoc.document_id   = row["document_id"].ToString();
                        objdoc.document_name = row["document_name"].ToString();
                        objdoc.document_path = row["document_path"].ToString();
                        objdoc.studentid     = row["studentid"].ToString();
                        _list.Add(objdoc);
                    }
                }
                if (ds.Tables[1].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[1].Rows)
                    {
                        //student_document objdoc = new student_document();
                        student_path = row["student_path"].ToString();
                        Session["StudentProfilePic"] = row["student_path"].ToString();
                        //_list.Add(objdoc);
                    }
                }
            }
            return(Json(new
            {
                List = _list,
                student_path = student_path
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }