コード例 #1
0
        public string Add(StudentModelView student)
        {
            if(ModelState.IsValid)
            {
                int session_id = SessionHandler.GetSchoolSessionID();

                if(session_id < 0)
                {
                    return Utils.Response(false, "Please select a default session before adding session");
                }

                int user_id = SessionHandler.GetUserID();

                int school_id = SessionHandler.GetSchoolID();

                var std = new Student()
                {
                    first_name = student.FirstName,
                    last_name = student.LastName,
                    gender = student.Gender,
                    parent_id = student.Parent,
                    class_id = student.Class,
                    school_id= school_id,
                    roll = student.RollNo,
                    monthly_fee = student.MonthlyFee,
                    admission_fee = student.AdmissionFee,
                    examination_fee = student.ExaminationFee,
                    other_charges = student.OtherCharges,
                    discount = student.Discount,
                    email = student.EmailAddress,
                    password = student.Password,
                    address = student.Address,
                    birthday = student.DateofBirth
                };
                std.school_id = school_id;
                std.created_by = user_id;

                int student_id = _sd.Insert(std);

                if (student_id != -1)
                {
                    var session = new SessionDetails().FindSingle(session_id ,school_id);

                    var months = Utils.GetMonths(session.start_date, session.end_date);

                    SchoolFeeStructure feestr = Utils.GetFeeStructure(school_id);
                    insertStudentFeeDetail(FeeType.ADMISSION_FEE, student_id, std.class_id,session_id);
                    insertStudentFeeDetail(FeeType.EXAMINATION_FEE, student_id, std.class_id, session_id);
                    insertStudentFeeDetail(FeeType.OTHER_CHARGES, student_id, std.class_id, session_id);

                    foreach(var month in  months)
                    {
                        insertStudentFeeDetail(FeeType.MONTHLY_FEE, student_id, std.class_id, session_id, month);
                    }

                    return student_id.ToJSON();
                }

                return true.ToJSON();
            }
            return false.ToJSON();
        }
コード例 #2
0
        public string Edit(StudentModelView student)
        {
            if (ModelState.IsValid)
            {
                int user_id = SessionHandler.GetUserID();

                int school_id = SessionHandler.GetSchoolID();

                var std = new Student()
                {
                    first_name = student.FirstName,
                    last_name = student.LastName,
                    gender = student.Gender,
                    parent_id = student.Parent,
                    class_id = student.Class,
                    school_id = school_id,
                    roll = student.RollNo,
                    monthly_fee = student.MonthlyFee,
                    admission_fee = student.AdmissionFee,
                    examination_fee = student.ExaminationFee,
                    other_charges = student.OtherCharges,
                    discount = student.Discount,
                    email = student.EmailAddress,
                    password = student.Password,
                    address = student.Address,
                    birthday = student.DateofBirth
                };
                std.school_id = school_id;
                std.created_by = user_id;

                int student_id = _sd.Insert(std);

                if (student_id != -1)
                {
                    return student_id.ToJSON();
                }

                return true.ToJSON();
            }

            return false.ToJSON();
        }