Esempio n. 1
0
        public System.Data.DataTable GetStudents(string schoolid)
        {
            lstStudentDetails = new ObservableCollection <StudentDetailsViewModelEntity>();
            DataTable dt = Common.GetStudents();

            foreach (DataRow dr in dt.Rows)
            {
                StudentDetailsViewModelEntity obj = new StudentDetailsViewModelEntity();
                obj.FirstName    = dr[0].ToString();
                obj.StudentID    = dr[1].ToString();
                obj.EnrollmentNo = dr[2].ToString();
                lstStudentDetails.Add(obj);
            }
            return(dt);
        }
        public void AdvanceSearch()
        {
            ImageConvertor objImageConvertor = new ImageConvertor();
            string         sql = "exec [SMS].[GetStudentDetails] '" + 0 + "','" + EnrollmentNo + "','" + FirstName + "','" + MiddleName + "','" + LastName + "','" + DateOfBirth1.ToString("yyyyMMdd") + "','" + LeavingDate1.ToString("yyyyMMdd") + "','" + FatherName + "','" + MotherName + "'," + this.Schoolid;

            SearchResult = DAL.Select(sql);
            if (SearchResult == null || SearchResult.Rows.Count == 0)
            {
                return;
            }
            StudentDetailCollection = new ObservableCollection <StudentDetailsViewModelEntity>();

            foreach (DataRow dr in SearchResult.Rows)
            {
                StudentDetailsViewModelEntity obj = new StudentDetailsViewModelEntity();
                obj.IUDFlag         = "U";
                obj.StudentID       = dr["StudentID"].ToString();
                obj.EnrollmentNo    = dr["EnrollmentNo"].ToString();
                obj.FirstName       = dr["FirstName"].ToString();
                obj.MiddleName      = dr["MiddleName"].ToString();
                obj.LastName        = dr["LastName"].ToString();
                obj.DateofBirthStr  = dr["DateOfBirth"].ToString();
                obj.DateOfAdmission = Convert.ToDateTime(dr["DateOfAdmission"]);
                obj.Gender          = dr["Gender"].ToString();
                SetGender();
                obj.Address             = dr["FullAddress"].ToString();
                obj.MobileNumber        = dr["MobileNumber"].ToString();
                obj.EmergencyContactNo1 = dr["EmergencyContactNo1"].ToString();
                obj.EmergencyContactNo2 = dr["EmergencyContactNo2"].ToString();
                obj.MotherName          = dr["MotherName"].ToString();
                obj.FatherName          = dr["FatherName"].ToString();
                int result = 0;
                int.TryParse(dr["MotherOccupation"].ToString(), out result);
                obj.SelectedOccupationMother = lstMothersOccupation.First(x => x.StaticID == result);
                int.TryParse(dr["FatherOccupation"].ToString(), out result);
                obj.SelectedOccupationFather = lstFathersOccupation.First(x => x.StaticID == result);
                obj.EmailAddress             = dr["EmailAddress"].ToString();
                obj.Nationality = dr["Nationality"].ToString();
                int.TryParse(dr["Caste"].ToString(), out result);
                obj.SelectedReligion = lstReligion.First(x => x.StaticID == result); //new StaticDataModel() { StaticID = result, StaticName = "Islam" }; //result;// int.Parse(dr["Caste"].ToString());
                obj.Caste            = dr["SubCaste"].ToString();
                obj.DateofLeavingStr = dr["LeavingDate"].ToString();
                obj.Picture          = dr["Picture"].ToString();
                obj.PhotoID          = dr["PhotoID"].ToString();
                obj.PreviousSchool   = dr["PreviousSchool"].ToString();
                if (!string.IsNullOrEmpty(obj.PhotoID))
                {
                    if (File.Exists(obj.PhotoID))
                    {
                        StreamReader sr          = new StreamReader(obj.PhotoID);
                        string       photostring = sr.ReadToEnd();
                        sr.Close();
                        byte[] bytearr = Convert.FromBase64String(photostring);
                        objImageConvertor.ConvertByteArrayToPhot(bytearr);
                    }
                }
                obj.ImageSource = objImageConvertor.ImageSource;
                obj.Age         = dr["Age"].ToString();
                int.TryParse(dr["ClassRoom"].ToString(), out result);
                obj.SelectedClass = lstClassRoom.First(x => x.StaticID == result);// int.Parse(dr["ClassRoom"].ToString());
                StudentDetailCollection.Add(obj);
            }
        }