Beispiel #1
0
        //
        // GET: /SysAdmin/Student/Edit/5
        public ActionResult Edit(int id)
        {
            StudentParentVM viewModel  = new StudentParentVM();
            CountryBAL      countryBAL = new CountryBAL();

            viewModel.Countries = from obj in countryBAL.GetAll().Where(c => c.Status == true) select new SelectListItem()
            {
                Text = obj.CountryName, Value = obj.CountryId.ToString()
            };

            //Get Student Id
            StudentBAL balStudentObject = new StudentBAL();
            IQueryable <Entities.Student> studentEntities = balStudentObject.FindBy(s => s.SrNo == id);

            if (studentEntities != null && studentEntities.Count() > 0)
            {
                Entities.Student studentEnity = studentEntities.FirstOrDefault();
                viewModel.StudentId = studentEnity.StudentId;
                viewModel.StudentFullNameWithTitle = string.Concat(studentEnity.Title.Trim(), " ", studentEnity.FirstName.Trim(), " ", studentEnity.MiddleName.Trim(), " ", studentEnity.LastName).Trim();
                viewModel.Status = true;
            }

            StudentParentBAL balObject = new StudentParentBAL();
            IQueryable <Entities.StudentParent> entites = balObject.FindBy(a => a.StudentId == viewModel.StudentId);

            if (entites != null && entites.Count() > 0)
            {
                Entities.StudentParent entity = entites.FirstOrDefault();
                viewModel.Title             = entity.Title.Trim();
                viewModel.FirstName         = entity.FirstName.Trim();
                viewModel.MiddleName        = entity.MiddleName.Trim();
                viewModel.LastName          = entity.LastName.Trim();
                viewModel.Gender            = entity.Gender.Trim();
                viewModel.CurrentAddress    = entity.Address.Trim();
                viewModel.CurrentCountryId  = entity.CountryId;
                viewModel.CurrentStateId    = entity.StateId;
                viewModel.CurrentDistrictId = entity.DistrictId;
                viewModel.CurrentCityId     = entity.CityId;
                viewModel.CurrentPinCode    = entity.PinCode;
                viewModel.MobileNo          = entity.MobileNumber;
                viewModel.ContactNumber     = entity.ContactNo;
                viewModel.Occupation        = entity.Occupation.Trim();
                viewModel.CompanyName       = entity.CompanyName.Trim();
                viewModel.CompanyAddress    = entity.CompanyAddress.Trim();
                viewModel.CompanyContactNo  = entity.CompanyContactNo.Trim();
                viewModel.BankName          = entity.BankName.Trim();
                viewModel.AccountNo         = entity.AccountNo.Trim();
                viewModel.Branch            = entity.Branch.Trim();
                viewModel.IFSCCode          = entity.IFSCCode.Trim();
                // viewModel.StudentFullNameWithTitle = entity.StudentFullName.Trim();
                viewModel.Status = entity.Status;
                viewModel.Remark = entity.Remark;
            }
            //else
            //{

            //    viewModel.StudentFullNameWithTitle = PresentationLayer.Other.CommanMethods.GetStudentName(id);
            //    viewModel.Status = true;
            //}
            return(View(viewModel));
        }
Beispiel #2
0
        public ActionResult Edit(StudentParentVM viewModel)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    Entities.StudentParent entity = new Entities.StudentParent();
                    entity.StudentId        = viewModel.StudentId;
                    entity.Title            = viewModel.Title;
                    entity.FirstName        = viewModel.FirstName;
                    entity.MiddleName       = viewModel.MiddleName;
                    entity.LastName         = viewModel.LastName;
                    entity.Gender           = viewModel.Gender;
                    entity.Address          = viewModel.CurrentAddress;
                    entity.CountryId        = viewModel.CurrentCountryId;
                    entity.StateId          = viewModel.CurrentStateId;
                    entity.DistrictId       = viewModel.CurrentDistrictId;
                    entity.CityId           = viewModel.CurrentCityId;
                    entity.PinCode          = viewModel.CurrentPinCode.HasValue ? Convert.ToInt32(viewModel.CurrentPinCode) : 0;
                    entity.MobileNumber     = viewModel.MobileNo;
                    entity.ContactNo        = viewModel.ContactNumber;
                    entity.Occupation       = viewModel.Occupation;
                    entity.CompanyName      = viewModel.CompanyName;
                    entity.CompanyAddress   = viewModel.CompanyAddress;
                    entity.CompanyContactNo = viewModel.CompanyContactNo;
                    entity.BankName         = string.IsNullOrEmpty(viewModel.BankName) ? string.Empty : viewModel.BankName.Trim();
                    entity.AccountNo        = string.IsNullOrEmpty(viewModel.AccountNo) ? string.Empty : viewModel.AccountNo.Trim();
                    entity.Branch           = string.IsNullOrEmpty(viewModel.Branch) ? string.Empty : viewModel.Branch.Trim();
                    entity.IFSCCode         = string.IsNullOrEmpty(viewModel.IFSCCode) ? string.Empty : viewModel.IFSCCode.Trim();
                    entity.Status           = viewModel.Status;
                    entity.Remark           = viewModel.Remark;

                    StudentParentBAL balObject = new StudentParentBAL();
                    IQueryable <Entities.StudentParent> StudentParents = balObject.FindBy(s => s.StudentId == viewModel.StudentId);
                    if (StudentParents != null && StudentParents.Count() > 0)
                    {
                        balObject.Edit(entity);
                    }
                    else
                    {
                        balObject.Add(entity);
                    }
                    return(RedirectToAction("Index", "Student"));
                }
                else
                {
                    CountryBAL countryBAL = new CountryBAL();
                    viewModel.Countries = from obj in countryBAL.GetAll().Where(c => c.Status == true) select new SelectListItem()
                    {
                        Text = obj.CountryName, Value = obj.CountryId.ToString()
                    };

                    return(View(viewModel));
                }
            }
            catch
            {
                CountryBAL countryBAL = new CountryBAL();
                viewModel.Countries = from obj in countryBAL.GetAll().Where(c => c.Status == true) select new SelectListItem()
                {
                    Text = obj.CountryName, Value = obj.CountryId.ToString()
                };

                return(View());
            }
        }
Beispiel #3
0
        private DataSet LeavingCertificate(int StudentId)
        {
            DataSet ds = new DataSet();

            ds.DataSetName = "DataSourceForReport";

            DataTable dt = new DataTable("LeavingCertificate");

            dt.TableName = "LeavingCertificate";
            dt.Columns.Add(new DataColumn("StudentId", typeof(string)));
            dt.Columns.Add(new DataColumn("FirstName", typeof(string)));
            dt.Columns.Add(new DataColumn("MiddleName", typeof(string)));
            dt.Columns.Add(new DataColumn("LastName", typeof(string)));
            dt.Columns.Add(new DataColumn("MotherName", typeof(string)));
            dt.Columns.Add(new DataColumn("MotherTounge", typeof(string)));
            dt.Columns.Add(new DataColumn("ReligionName", typeof(string)));
            dt.Columns.Add(new DataColumn("CastName", typeof(string)));
            dt.Columns.Add(new DataColumn("SubCast", typeof(string)));
            dt.Columns.Add(new DataColumn("Nationality", typeof(string)));
            dt.Columns.Add(new DataColumn("PlaceOfBirth", typeof(string)));
            dt.Columns.Add(new DataColumn("DateOfBirth", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("DateOfBirthInWord", typeof(string)));
            dt.Columns.Add(new DataColumn("LastSchool", typeof(string)));
            dt.Columns.Add(new DataColumn("DateOfAdmission", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("Progress", typeof(string)));
            dt.Columns.Add(new DataColumn("Conduct", typeof(string)));
            dt.Columns.Add(new DataColumn("DateOfLeaveingSchool", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("ClassInWhichStudingAndSinceWhen", typeof(string)));
            dt.Columns.Add(new DataColumn("Reason", typeof(string)));
            dt.Columns.Add(new DataColumn("Remark", typeof(string)));
            dt.Columns.Add(new DataColumn("RegisterNo", typeof(int)));
            dt.Columns.Add(new DataColumn("TCNo", typeof(string)));
            dt.Columns.Add(new DataColumn("TCPrinted", typeof(bool)));
            dt.Columns.Add(new DataColumn("AdharcardNo", typeof(string)));
            dt.Columns.Add(new DataColumn("DateOfLeaveingSchoolInWords", typeof(string)));
            dt.Columns.Add(new DataColumn("Taluka", typeof(string)));
            dt.Columns.Add(new DataColumn("District", typeof(string)));
            dt.Columns.Add(new DataColumn("state", typeof(string)));
            dt.Columns.Add(new DataColumn("Country", typeof(string)));

            int studentId = (int)PresentationLayer.Helpers.SessionHelper.StudentId;

            // Fetch the District, State, Country from database ***********

            string strDistrict, strState, strCountry, strCity;

            strDistrict = strState = strCountry = strCity = "";

            //balObject.FindBy(s => s.StudentId == studentId );

            StudentParentBAL balObjectAddr = new StudentParentBAL();
            IQueryable <Entities.StudentParent> entites1 = balObjectAddr.FindBy(s => s.StudentId == studentId);

            if (entites1 != null && entites1.Count() > 0)
            {
                Entities.StudentParent entity1 = entites1.FirstOrDefault();

                CountryBAL countryBAL = new CountryBAL();
                IQueryable <Entities.Country> countries = countryBAL.GetAll();

                StateBAL stateBAL = new StateBAL();
                IQueryable <Entities.State> states = stateBAL.GetAll();

                DistrictBAL DistrictObject = new DistrictBAL();
                IQueryable <Entities.District> District = DistrictObject.GetAll();

                CityBAL CityObject = new CityBAL();
                IQueryable <Entities.City> Cities = CityObject.GetAll();


                strCountry  = countries.Where(c => c.CountryId == entity1.CountryId).FirstOrDefault().CountryName;
                strState    = states.Where(s => s.StateId == entity1.StateId).FirstOrDefault().StateName;
                strDistrict = District.Where(c => c.DistrictId == entity1.DistrictId).FirstOrDefault().DistrictName;
                strCity     = Cities.Where(c => c.CityId == entity1.CityId).FirstOrDefault().CityName;
            }


            // *********

            StudentBAL balObject = new StudentBAL();
            //IQueryable<Entities.Student> entites = balObject.FindBy(s => s.StudentId == studentId );
            IQueryable <Entities.Student> entites = balObject.GetAll(SessionHelper.SchoolId).Where(c => c.StudentId == studentId);

            if (entites != null && entites.Count() > 0)
            {
                Entities.Student entity = entites.FirstOrDefault();
                DataRow          dr     = dt.NewRow();

                dr["StudentId"]    = entity.UStudentId;
                dr["FirstName"]    = entity.FirstName.Trim();
                dr["MiddleName"]   = entity.MiddleName.Trim();;
                dr["LastName"]     = entity.LastName.Trim();;
                dr["MotherName"]   = entity.MotherName.Trim();;
                dr["ReligionName"] = entity.ReligionName.Trim();;
                dr["CastName"]     = entity.CastName.Trim();
                dr["SubCast"]      = "";                 //TODO
                dr["Nationality"]  = entity.Nationality.Trim();
                dr["DateOfBirth"]  = entity.DateOfBirth; //Date
                dr["PlaceOfBirth"] = entity.PlaceOfBirth;

                if (entity.DateOfBirth != null)
                {
                    dr["DateOfBirthInWord"] = DateToText(entity.DateOfBirth);
                }
                else
                {
                    dr["DateOfBirthInWord"] = "";
                }

                dr["LastSchool"]      = entity.LastSchoolAttended;
                dr["DateOfAdmission"] = entity.DateOfAdmission; //Date
                if (entity.DateOfAdmission != null)
                {
                    dr["DateOfAdmission"] = entity.DateOfAdmission;//Date
                }
                dr["Progress"] = entity.Progress;
                dr["Conduct"]  = entity.Conduct;
                if (entity.DateOfLeavingSchool != null)
                {
                    dr["DateOfLeaveingSchool"]        = entity.DateOfLeavingSchool;//Date
                    dr["DateOfLeaveingSchoolInWords"] = DateToText((System.DateTime)entity.DateOfLeavingSchool);
                }
                else
                {
                    dr["DateOfLeaveingSchoolInWords"] = "";
                }


                dr["ClassInWhichStudingAndSinceWhen"] = entity.ClassInWhichStudingAndSinceWhen;
                dr["Reason"]     = entity.ReasonForLeavingSchool;
                dr["Remark"]     = entity.RemarkOnTC;
                dr["RegisterNo"] = entity.RegisterId;

                dr["TCPrinted"] = entity.TCPrinted;
                if (!entity.TCPrinted)
                {
                    long maxTCNo = balObject.GetMaxTCNo();
                    dr["TCNo"] = FormatedTCNo(Convert.ToString(maxTCNo + 1));

                    //if (isPrintExport)
                    //  UpdateTCDetails(studentId);
                }
                else
                {
                    dr["TCNo"] = FormatedTCNo(Convert.ToString(entity.TCNo));
                }

                if (isPrintExport)
                {
                    UpdateTCDetails(studentId);
                }

                dr["AdharcardNo"]  = entity.AdharcardNo;
                dr["MotherTounge"] = entity.MotherTounge;

                // ****
                dr["Taluka"]   = strCity;
                dr["District"] = strDistrict;
                dr["state"]    = strState;
                dr["Country"]  = strCountry;

                dt.Rows.Add(dr);
                reportName = entity.RegisterId + "_" + entity.LastName.Trim() + "_" + entity.FirstName.Trim();
            }

            ds.Tables.Add(getSchoolDetails());
            ds.Tables.Add(dt);
            return(ds);
        }