コード例 #1
0
ファイル: setfeeController.cs プロジェクト: ramakathare/FMS
        public ActionResult Create(setfee setfee)
        {
            if (setFeeExists(setfee))
            {
                ModelState.AddModelError(string.Empty, "Record already exists");
            }

            short thisAcaYear = db.acayears.Find(setfee.acaYearid).year;
            short batch       = db.students.Find(setfee.studentid).batch.name;

            if (thisAcaYear < batch)
            {
                ModelState.AddModelError(string.Empty, "Fee can't be set to student where acayear < batch");
            }
            if (ModelState.IsValid)
            {
                db.setfees.Add(setfee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.feeTypeid = new SelectList(db.feetypes, "id", "type", setfee.feeTypeid);
            ViewBag.studentid = new SelectList(db.students, "id", "htno", setfee.studentid);
            ViewBag.acaYearid = new SelectList(db.acayears, "id", "year", setfee.acaYearid);
            return(View(setfee));
        }
コード例 #2
0
        public ActionResult Create(role role)
        {
            if (ModelState.IsValid)
            {
                db.roles.Add(role);
                var rolemodules = db.rolemodules.ToList();
                foreach (rolemodule rm in rolemodules)
                {
                    rolemodulepermission rolemodulepermission = new rolemodulepermission();
                    rolemodulepermission.roleid       = role.id;
                    rolemodulepermission.rolemoduleid = rm.id;
                    rolemodulepermission.permission   = false;
                    db.rolemodulepermissions.Add(rolemodulepermission);
                }
                var roleModuleActions = db.rolemoduleactions.ToList();
                foreach (rolemoduleaction ra in roleModuleActions)
                {
                    rolemoduleactionpermission rolemoduleactionpermission = new rolemoduleactionpermission();
                    rolemoduleactionpermission.roleid             = role.id;
                    rolemoduleactionpermission.rolemoduleactionid = ra.id;
                    rolemoduleactionpermission.permission         = false;
                    db.rolemoduleactionpermissions.Add(rolemoduleactionpermission);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
コード例 #3
0
ファイル: userController.cs プロジェクト: ramakathare/FMS
        public ActionResult Create(user user)
        {
            if (user.username != null && user.username.Length > 10)
            {
                ModelState.AddModelError("username", "Username should be between 4 to 10 characters");
            }
            if (user.password != null && user.password.Length > 10)
            {
                ModelState.AddModelError("password", "Password should be between 5 to 10 characters");
            }

            if (ModelState.IsValid)
            {
                user.username = base64Encryption.Encrypt(user.username);
                user.password = base64Encryption.Encrypt(user.password);
                db.users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
                //catch (DbEntityValidationException dbEx)
                //{
                //    foreach (var validationErrors in dbEx.EntityValidationErrors)
                //    {
                //        foreach (var validationError in validationErrors.ValidationErrors)
                //        {
                //            ModelState.AddModelError("",string.Format("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage));
                //        }
                //    }
                //}
            }

            ViewBag.roleid = new SelectList(db.roles, "id", "roleName", user.roleid);
            return(View(user));
        }
コード例 #4
0
ファイル: payfeeController.cs プロジェクト: ramakathare/FMS
        public ActionResult gridAddOrUpdate(payfee payfee)
        {
            payFeeRequiredResponse pffr = payFeeRequired(payfee);

            if (pffr.amount <= 0)
            {
                return(Json(new { success = false, message = pffr.message }, JsonRequestBehavior.AllowGet));
            }

            int lastid = 1;

            if (db.payfees.Count() > 0)
            {
                lastid = db.payfees.Max(item => item.id) + 1;
            }
            payfee.time = DateTime.Now;

            var college = db.students.Where(s => s.id.Equals(payfee.studentid)).Select(s => s.dept.name).FirstOrDefault().Substring(0, 3);

            payfee.recieptNo = college + lastid.ToString();//dt.Year.ToString().Substring(2, 2) + dt.Month.ToString() + dt.Day.ToString() + 1;

            // payfee.recieptNo = payfee.student.htno.Substring(0, 4) + lastid;
            payfee.paymentTypeid = 1;

            db.payfees.Add(payfee);
            db.SaveChanges();
            return(Json(new { success = true, message = "Payment made successfully" }, JsonRequestBehavior.AllowGet));
            //return Json(new { success = false, message = payfee.id + " " + payfee.amount + " " + payfee.studentid + " " + payfee.acaYearid + " " + payfee.feeTypeid }, JsonRequestBehavior.AllowGet);
        }
コード例 #5
0
        public ActionResult Create(quota quota)
        {
            if (ModelState.IsValid)
            {
                db.quotas.Add(quota);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(quota));
        }
コード例 #6
0
        public ActionResult Create(paymenttype paymenttype)
        {
            if (ModelState.IsValid)
            {
                db.paymenttypes.Add(paymenttype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(paymenttype));
        }
コード例 #7
0
ファイル: chequeController.cs プロジェクト: ramakathare/FMS
        public ActionResult Create(cheque cheque)
        {
            if (ModelState.IsValid)
            {
                db.cheques.Add(cheque);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.payFeeid = new SelectList(db.payfees, "id", "id", cheque.payFeeid);
            return(View(cheque));
        }
コード例 #8
0
ファイル: semController.cs プロジェクト: ramakathare/FMS
 public ActionResult gridAddOrUpdate(sem sem)
 {
     try
     {
         db.Entry(sem).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         return(Json(new { success = false, message = "Record not updated" }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { success = true, message = "Record updated" }, JsonRequestBehavior.AllowGet));
 }
コード例 #9
0
 public ActionResult Create(batch batch)
 {
     if (!isUniqueBatchName(batch.name))
     {
         ModelState.AddModelError(String.Empty, "Batch already exists");
     }
     if (ModelState.IsValid)
     {
         db.batches.Add(batch);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(batch));
 }
コード例 #10
0
ファイル: deptController.cs プロジェクト: ramakathare/FMS
 public ActionResult Create(dept dept)
 {
     if (deptExits(dept))
     {
         ModelState.AddModelError("", "Department Already Exists");
     }
     if (ModelState.IsValid)
     {
         db.depts.Add(dept);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.collegeid = new SelectList(db.colleges, "collegeid", "collegeName", dept.collegeid);
     return(View(dept));
 }
コード例 #11
0
ファイル: acayearController.cs プロジェクト: ramakathare/FMS
        public ActionResult Create(acayear acayear)
        {
            if (!isUniqueAcaYear(acayear.year))
            {
                ModelState.AddModelError(String.Empty, "Academic Year already exists");
            }
            if (ModelState.IsValid)
            {
                db.acayears.Add(acayear);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(acayear));
        }
コード例 #12
0
        public ActionResult Create(caste caste)
        {
            if (!isUniqueCasteName(caste.name))
            {
                ModelState.AddModelError(String.Empty, "Caste already exists");
            }
            if (ModelState.IsValid)
            {
                db.castes.Add(caste);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(caste));
        }
コード例 #13
0
        public ActionResult Create(feetype feetype)
        {
            if (feetype.allowedInstallments == 0)
            {
                ModelState.AddModelError("", "0 is not valid for Allowed Installments");
            }
            if (ModelState.IsValid)
            {
                db.feetypes.Add(feetype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(feetype));
        }
コード例 #14
0
ファイル: studentController.cs プロジェクト: ramakathare/FMS
        public ActionResult Create(student student)
        {
            if (ModelState.IsValid)
            {
                db.students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.batchid = new SelectList(db.batches, "id", "name", student.batchid);
            ViewBag.casteid = new SelectList(db.castes, "id", "name", student.casteid);
            ViewBag.deptid  = new SelectList(db.depts, "id", "name", student.deptid);
            ViewBag.quotaid = new SelectList(db.quotas, "id", "name", student.quotaid);
            ViewBag.semid   = new SelectList(db.sems, "id", "name", student.semid);
            return(View(student));
        }
コード例 #15
0
 public ActionResult gridAddOrUpdate(rolemodulepermission rolemodulepermission)
 {
     try
     {
         if (rolemodulepermission.id.CompareTo(0) > 0)
         {
             db.Entry(rolemodulepermission).State = EntityState.Modified;
         }
         else
         {
             db.rolemodulepermissions.Add(rolemodulepermission);
         }
         db.SaveChanges();
     }
     catch (Exception e)
     {
         return(Json(new { success = false, message = "Record not added" }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { success = true, message = "Record Added" }, JsonRequestBehavior.AllowGet));
 }
コード例 #16
0
        public ActionResult Create(concession concession)
        {
            concessionRequiredResponse crr = concessionRequired(concession);

            if (crr.amount <= 0)
            {
                ModelState.AddModelError(string.Empty, crr.message);
            }
            if (ModelState.IsValid)
            {
                concession.time = DateTime.Now;
                db.concessions.Add(concession);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.feeTypeid = new SelectList(db.feetypes, "id", "type", concession.feeTypeid);
            ViewBag.studentid = new SelectList(db.students, "id", "htno", concession.studentid);
            ViewBag.acaYearid = new SelectList(db.acayears, "id", "year", concession.acaYearid);
            return(View(concession));
        }
コード例 #17
0
 public ActionResult gridAddOrUpdate(reimbursement rb)
 {
     if (db.reimbursements.Any(s => s.acaYearid == rb.acaYearid && s.studentid == rb.studentid))
     {
         if (db.reimbursements.Where(s => s.acaYearid == rb.acaYearid && s.studentid == rb.studentid).Select(s => s.id).ToList().AsQueryable().FirstOrDefault() != rb.id)
         {
             return(Json(new { success = false, message = "Record Already Exists" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(rb).State = EntityState.Modified;
         }
     }
     else
     {
         rb.date = DateTime.Now;
         db.reimbursements.Add(rb);
     }
     db.SaveChanges();
     return(Json(new { success = true, message = "Record saved successfully" }, JsonRequestBehavior.AllowGet));
 }
コード例 #18
0
ファイル: AccountController.cs プロジェクト: ramakathare/FMS
 public ActionResult ChangePassword(ChangePasswordModel model)
 {
     if (model.ConfirmPassword != null && model.ConfirmPassword.Length > 10)
     {
         ModelState.AddModelError("", "ConfirmPassword Password should be between 5 to 10 characters");
     }
     if (model.NewPassword != null && model.NewPassword.Length > 10)
     {
         ModelState.AddModelError("", "NewPassword Password should be between 5 to 10 characters");
     }
     if (model.OldPassword != null && model.OldPassword.Length > 10)
     {
         ModelState.AddModelError("", "OldPassword Password should be between 5 to 10 characters");
     }
     if (model.ConfirmPassword != null && model.ConfirmPassword != null)
     {
         if (!model.NewPassword.Equals(model.ConfirmPassword))
         {
             ModelState.AddModelError("", "Confirmation of New Password failed");
         }
     }
     if (ModelState.IsValid)
     {
         try
         {
             int    userid = Permissions.getuserid();
             user   user   = db.users.Find(userid);
             string originalEncryptedOldPassword = user.password;
             string providedEncryptedOldPassword = base64Encryption.Encrypt(model.OldPassword);
             if (originalEncryptedOldPassword.Equals(providedEncryptedOldPassword))
             {
                 user.password        = base64Encryption.Encrypt(model.NewPassword);
                 db.Entry(user).State = EntityState.Modified;
                 db.SaveChanges();
                 return(View("ChangePasswordSuccess"));
             }
             ModelState.AddModelError("OldPassword", "Password provided is wrong");
             return(View(model));
         }
         catch (Exception)
         {
             ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
             return(View(model));
         }
     }
     // If we got this far, something failed, redisplay form
     return(View(model));
 }