コード例 #1
0
        public ActionResult Edit([Bind(Include = "Id,StudentId,Months,Status,InstalmentAmount,IssueDate,Date")] StudentFeeMonth studentFeeMonth)
        {
            if (studentFeeMonth.Status == "Clear")
            {
                var             dbTransaction = db.Database.BeginTransaction();
                StudentFeeMonth data          = db.StudentFeeMonths.Where(x => x.StudentId == studentFeeMonth.StudentId && x.Months == studentFeeMonth.Months).FirstOrDefault();
                data.Status = "Clear";
                db.SaveChanges();

                try
                {
                    Ledger ledger_Assets = db.Ledgers.Where(x => x.Name == "Student Receivables").FirstOrDefault();
                    ledger_Assets.CurrentBalance -= Convert.ToDecimal(studentFeeMonth.InstalmentAmount);
                    db.SaveChanges();

                    Ledger ledger_bank = db.Ledgers.Where(x => x.Name == "Meezan Bank" && x.LedgerGroup.Name == "Bank").FirstOrDefault();
                    ledger_bank.CurrentBalance += Convert.ToDecimal(studentFeeMonth.InstalmentAmount);
                    db.SaveChanges();
                }
                catch
                {
                    TempData["ErrorMessage"] = "No Cash in Student Receivables Account.";
                    return(RedirectToAction("Edit", studentFeeMonth));
                    //   return RedirectToAction("Edit?="+studentFeeMonth.StudentId);
                }

                dbTransaction.Commit();
            }

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult SaveMultiplierDetails(int id)
        {
            var feedata           = db.StudentFeeMonths.Where(x => x.StudentId == id).FirstOrDefault();
            var installmentamount = feedata.InstalmentAmount * 2;
            var list = db.StudentFeeMonths.Where(x => x.StudentId == id).ToList();
            int i    = 2;

            foreach (var items in list)
            {
                StudentFeeMonth data = db.StudentFeeMonths.Where(x => x.Id == items.Id).FirstOrDefault();
                if (i % 2 == 0)
                {
                    data.FeePayable = installmentamount;
                    data.Multiplier = 2;
                }

                else
                {
                    data.FeePayable = 0;
                    data.Multiplier = 0;
                }
                db.SaveChanges();
                i++;
            }
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "Id,StudentId,Months,Status,InstalmentAmount,Date")] StudentFeeMonth studentFeeMonth)
        {
            try
            {
                var           checkbox = Request.Form["ingredients"];
                List <string> names    = new List <string>(checkbox.Split(','));
                if (ModelState.IsValid)
                {
                    foreach (var item in names)
                    {
                        studentFeeMonth.Months = item;
                        db.StudentFeeMonths.Add(studentFeeMonth);
                        db.SaveChanges();
                    }

                    return(RedirectToAction("Index"));
                }

                ViewBag.StudentId = new SelectList(db.AspNetStudents, "Id", "Name", studentFeeMonth.StudentId);
                return(View(studentFeeMonth));
            }
            catch
            {
                return(RedirectToAction("Create"));
            }
        }
コード例 #4
0
        public JsonResult SaveStudentFee(int cid, string uid)
        {
            string status    = "error";
            var    student   = db.AspNetStudents.Where(x => x.StudentID == uid).FirstOrDefault();
            var    isstudent = db.StudentFeeMonths.Where(x => x.StudentId == student.Id).FirstOrDefault();

            if (isstudent == null)
            {
                var      totalfee    = db.StudentRecurringFees.Where(x => x.ClassId == cid).FirstOrDefault();
                var      installment = totalfee.TotalFee / 12;
                string[] Months      = { "September", "October", "November", "December", "January", "February", "March", "April", "May", "June", "July", "August" };
                for (int i = 0; i < Months.Count(); i++)
                {
                    StudentFeeMonth stdfeemonth = new StudentFeeMonth();
                    stdfeemonth.StudentId        = student.Id;
                    stdfeemonth.SessionId        = totalfee.SessionId;
                    stdfeemonth.Status           = "Pending";
                    stdfeemonth.InstalmentAmount = installment;
                    stdfeemonth.FeePayable       = installment;
                    var dddd = DateTime.Now;
                    var d    = dddd.ToString("yyyy-MM-dd");
                    stdfeemonth.IssueDate = d;
                    stdfeemonth.Months    = Months[i];
                    db.StudentFeeMonths.Add(stdfeemonth);
                }
                status = "Success";
                db.SaveChanges();
                return(Json(status, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(status, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            StudentFeeMonth studentFeeMonth = db.StudentFeeMonths.Find(id);

            db.StudentFeeMonths.Remove(studentFeeMonth);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        //else
        //{
        //    var checkbox1 = Request.Form["counter"];
        //    bool Flag = true;
        //    double? installmentamount = studentFeeMonth.InstalmentAmount;
        //    float multiplier;
        //    try
        //    {
        //        multiplier = float.Parse(Request.Form["multiplier"]);
        //    }
        //    catch (Exception ex)
        //    {
        //        multiplier = 1;
        //    }
        //    studentFeeMonth.Multiplier = Math.Round(multiplier, 2, MidpointRounding.AwayFromZero);

        //    double decimalvalues = multiplier - Math.Truncate(multiplier);
        //    double roundvalues = Math.Round(decimalvalues, 2, MidpointRounding.AwayFromZero);
        //    var total = float.Parse(Request.Form["total"]);
        //    studentFeeMonth.FeePayable = total;
        //    var round = Math.Ceiling(multiplier);
        //    var checkbox = Request.Form["counter"];
        //    if (checkbox == null)
        //    {
        //        ViewBag.Error = "Please Select Months.";
        //        ViewBag.StudentId = new SelectList(db.AspNetStudents, "Id", "Name", studentFeeMonth.StudentId);
        //        return View(studentFeeMonth);
        //    }
        //    List<string> names = new List<string>(checkbox.Split(','));
        //    int months = names.Count();

        //    if (!names.Contains(studentFeeMonth.Months))
        //    {
        //        if (round == months + 1)
        //        {
        //            if (roundvalues == 0)  // for int multiplier
        //            {
        //                double? value = (total - installmentamount) / months;

        //                for (var i = 0; i < names.Count; i++)
        //                {
        //                    string monthname = names[i];
        //                    StudentFeeMonth student = db.StudentFeeMonths.Where(x => x.Months == monthname && x.StudentId == studentFeeMonth.StudentId).FirstOrDefault();
        //                    student.FeePayable = student.FeePayable - value;
        //                    if (student.FeePayable >= 0)
        //                    {
        //                        db.SaveChanges();
        //                    }
        //                    else
        //                    {
        //                        ViewBag.Error = "Invalid Transaction.";
        //                        ViewBag.StudentId = new SelectList(db.AspNetStudents, "Id", "Name", studentFeeMonth.StudentId);
        //                        return View(studentFeeMonth);
        //                    }
        //                }
        //            }
        //            else
        //            {   //for float multiplier

        //                var round2 = Math.Floor(multiplier);
        //                var evenprice = installmentamount * round2;
        //                double? value2 = (evenprice) / months;
        //                string Lastmonth = names.Last();

        //                for (var i = 0; i < names.Count - 1; i++)
        //                {
        //                    string monthname = names[i];
        //                    StudentFeeMonth student = db.StudentFeeMonths.Where(x => x.Months == monthname && x.StudentId == studentFeeMonth.StudentId).FirstOrDefault();
        //                    student.FeePayable = student.FeePayable - value2;
        //                    if (student.FeePayable >= 0)
        //                    {
        //                        db.SaveChanges();
        //                    }

        //                    else
        //                    {
        //                        ViewBag.Error = "Invalid Transaction.";
        //                        ViewBag.StudentId = new SelectList(db.AspNetStudents, "Id", "Name", studentFeeMonth.StudentId);
        //                        return View(studentFeeMonth);
        //                    }
        //                }
        //                //last month
        //                if (Lastmonth != null)
        //                {
        //                    var oddprice = total - evenprice;
        //                    StudentFeeMonth studentdata = db.StudentFeeMonths.Where(x => x.Months == Lastmonth && x.StudentId == studentFeeMonth.StudentId).FirstOrDefault();
        //                    studentdata.FeePayable = studentdata.FeePayable - oddprice;
        //                    if (studentdata.FeePayable >= 0)
        //                    {
        //                        db.SaveChanges();
        //                    }
        //                    else
        //                    {
        //                        ViewBag.Error = "Invalid Transaction.";
        //                        ViewBag.StudentId = new SelectList(db.AspNetStudents, "Id", "Name", studentFeeMonth.StudentId);
        //                        return View(studentFeeMonth);
        //                    }
        //                }

        //            }

        //        }
        //        else
        //        {
        //            Flag = false;
        //            // months extends or decends
        //            ViewBag.Error = "Months Exceeds.";
        //            // ViewBag.StudentId = new SelectList(db.AspNetStudents, "Id", "Name", studentFeeMonth.StudentId);
        //            ViewBag.StudentId = new SelectList(db.AspNetStudents.Where(x => x.AspNetUser.Status != "False").Select(x => new { x.Id, x.AspNetUser.Name }), "Id", "Name", studentFeeMonth.StudentId);
        //            return View(studentFeeMonth);

        //        }
        //    }
        //    else
        //    {
        //        Flag = false;
        //        //invalid month selected
        //        ViewBag.Error = "Invalid Month Selected.";
        //        // ViewBag.StudentId = new SelectList(db.AspNetStudents, "Id", "Name", studentFeeMonth.StudentId);
        //        ViewBag.StudentId = new SelectList(db.AspNetStudents.Where(x => x.AspNetUser.Status != "False").Select(x => new { x.Id, x.AspNetUser.Name }), "Id", "Name", studentFeeMonth.StudentId);

        //        return View(studentFeeMonth);
        //    }

        //    //if (checkbox == null)
        //    //{
        //    //    ViewBag.ErrorMessage = "No Month Selected, Please Select Month";
        //    //}
        //    if (ModelState.IsValid && Flag == true)
        //    {
        //        studentFeeMonth.Status = studentFeeMonth.Status;
        //        studentFeeMonth.DueDate = studentFeeMonth.DueDate;
        //        studentFeeMonth.IssueDate = studentFeeMonth.IssueDate;
        //        db.Entry(studentFeeMonth).State = EntityState.Modified;
        //        db.SaveChanges();


        //        Month_Multiplier Multi = new Month_Multiplier();

        //        for (var i = 0; i < names.Count; i++)
        //        {

        //            string monthname = names[i];

        //            Multi.PaymentMonth = studentFeeMonth.Months;
        //            Multi.StudentId = studentFeeMonth.StudentId;
        //            Multi.AdjustedMonth = monthname;
        //            db.Month_Multiplier.Add(Multi);
        //            db.SaveChanges();

        //        }

        //        //if(studentFeeMonth.Status=="Clear")
        //        //{
        //        //    StudentFeeMultiplier stdfee = db.StudentFeeMultipliers.Where(x => x.StudentId == studentFeeMonth.StudentId).Select(x => x).FirstOrDefault();
        //        //    stdfee.PaidInstalments += 1;
        //        //    stdfee.PaidAmount += studentFeeMonth.InstalmentAmount;
        //        //    stdfee.RemainingInstalments -= 1;
        //        //    stdfee.RemainingAmount -= studentFeeMonth.InstalmentAmount;
        //        //    db.SaveChanges();

        //        //    Ledger ledger = db.Ledgers.Where(x => x.Name == "Student Receivables").FirstOrDefault();
        //        //    ledger.CurrentBalance -= Convert.ToDecimal(studentFeeMonth.InstalmentAmount);
        //        //    db.SaveChanges();
        //        //}


        //        return RedirectToAction("Index");
        //    }
        //}
        //ViewBag.StudentId = new SelectList(db.AspNetStudents, "Id", "Name", studentFeeMonth.StudentId);
        //return View(studentFeeMonth);
        //}

        // GET: StudentFeeMonths/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentFeeMonth studentFeeMonth = db.StudentFeeMonths.Find(id);

            if (studentFeeMonth == null)
            {
                return(HttpNotFound());
            }
            return(View(studentFeeMonth));
        }
コード例 #7
0
        public ActionResult UpdateStudentFeeMonth_Dates(int StudentID, string Month, DateTime validitydate, DateTime duedate)
        {
            string          status   = "error";
            StudentFeeMonth settings = db.StudentFeeMonths.Where(x => x.StudentId == StudentID && x.Months == Month).FirstOrDefault();

            settings.ValildityDate = validitydate;
            settings.DueDate       = duedate;
            settings.IsPrinted     = true;
            if (db.SaveChanges() > 0)
            {
                status = "success";
            }

            return(Content(status));
        }
コード例 #8
0
        public ActionResult Edit([Bind(Include = "Id,ClassId,ComputerLabCharges,SecurityServices,LabCharges,Transportation,SportsShirt,ChineseClassFee,AdvanceTax,Other,TutionFee,TotalFee")] StudentRecurringFee studentRecurringFee)
        {
            if (ModelState.IsValid)
            {
                db.Entry(studentRecurringFee).State = EntityState.Modified;
                if (db.SaveChanges() > 0)
                {
                    List <AspNetStudent> list = db.AspNetStudents.Where(x => x.ClassID == studentRecurringFee.ClassId && x.AspNetUser.Status != "False").ToList();
                    foreach (var std in list)
                    {
                        var tdfee = db.StudentFeeMonths.Where(x => x.StudentId == std.Id && x.Status == "Pending").ToList();
                        foreach (var item in tdfee)
                        {
                            StudentFeeMonth student = db.StudentFeeMonths.Where(x => x.Id == item.Id).FirstOrDefault();
                            db.StudentFeeMonths.Remove(student);
                            db.SaveChanges();
                        }

                        var      classid     = db.AspNetStudents.Where(x => x.Id == std.Id).Select(x => x.ClassID).FirstOrDefault();
                        var      totalfee    = db.StudentRecurringFees.Where(x => x.ClassId == std.ClassID).FirstOrDefault();
                        var      installment = totalfee.TotalFee / 12;
                        string[] Months      = { "September", "October", "November", "December", "January", "February", "March", "April", "May", "June", "July", "August" };
                        for (int i = 0; i < Months.Count(); i++)
                        {
                            StudentFeeMonth stdfeemonth = new StudentFeeMonth();
                            stdfeemonth.StudentId        = std.Id;
                            stdfeemonth.Status           = "Pending";
                            stdfeemonth.InstalmentAmount = installment;
                            stdfeemonth.SessionId        = studentRecurringFee.SessionId;
                            stdfeemonth.FeePayable       = installment;
                            var dddd = DateTime.Now;
                            var d    = dddd.ToString("yyyy-MM-dd");
                            stdfeemonth.IssueDate = d;
                            stdfeemonth.Months    = Months[i];
                            db.StudentFeeMonths.Add(stdfeemonth);
                        }
                        db.SaveChanges();
                    }
                }



                return(RedirectToAction("Index"));
            }
            ViewBag.ClassId = new SelectList(db.AspNetClasses, "Id", "Name", studentRecurringFee.ClassId);
            return(View(studentRecurringFee));
        }
コード例 #9
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentFeeMonth studentFeeMonth = db.StudentFeeMonths.Find(id);

            if (studentFeeMonth == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Error     = TempData["ErrorMessage"] as string;
            ViewBag.StudentId = new SelectList(db.AspNetStudents.Where(x => x.AspNetUser.Status != "False").Select(x => new { x.Id, x.AspNetUser.Name }), "Id", "Name", studentFeeMonth.StudentId);

            //  ViewBag.StudentId = new SelectList(db.AspNetUsers, "Id", "Name", studentFeeMonth.StudentId);
            return(View(studentFeeMonth));
        }
コード例 #10
0
        public ActionResult StudentFeeUpdate(int id, int ClassId, double RemainingFee = 0, double Discount = 0, double CashReceived = 0, string DueDate = null, string IssueDate = null)
        {
            var FeePayable = RemainingFee + Discount + CashReceived;
            int?sessionId  = db.AspNetClasses.Where(x => x.Id == ClassId).FirstOrDefault().SessionID;

            // db.AspNetSessions.Where(x=>x.Id==)
            var SessionName = db.AspNetSessions.Where(x => x.Id == sessionId).FirstOrDefault().SessionName;

            var studenfee = db.StudentFeeMonths.Where(x => x.Id == id).FirstOrDefault();

            StudentFeeMonth stdFeeMonth = new StudentFeeMonth();

            stdFeeMonth.StudentId = studenfee.StudentId;

            //    stdFeeMonth.IssueDate = DateTime.Now;


            stdFeeMonth.TotalFee    = studenfee.TotalFee;
            stdFeeMonth.FeePayable  = RemainingFee;
            stdFeeMonth.Discount    = Discount;
            stdFeeMonth.FeeType     = studenfee.FeeType;
            stdFeeMonth.SessionId   = sessionId;
            stdFeeMonth.FeeReceived = CashReceived;

            DateTime Date = Convert.ToDateTime(DueDate);

            stdFeeMonth.DueDate = Date;

            DateTime ConvertedIssueDate = Convert.ToDateTime(IssueDate);

            stdFeeMonth.IssueDate = ConvertedIssueDate;



            if (RemainingFee == 0)
            {
                stdFeeMonth.Status = "Paid";
            }
            else
            {
                stdFeeMonth.Status = "Pending";
            }

            //var Month = DateTime.Now.ToString("MMMM");

            var Month = ConvertedIssueDate.ToString("MMMM");

            stdFeeMonth.Months = Month;

            db.StudentFeeMonths.Add(stdFeeMonth);
            db.SaveChanges();

            var     idd      = User.Identity.GetUserId();
            var     username = db.AspNetUsers.Where(x => x.Id == idd).Select(x => x.Name).FirstOrDefault();
            Voucher voucher  = new Voucher();

            var UsrId = db.AspNetStudents.Where(x => x.Id == studenfee.StudentId).FirstOrDefault().StudentID;

            var StudentName = db.AspNetUsers.Where(x => x.Id == UsrId).FirstOrDefault().Name;

            voucher.Name      = "Fee Received by Admin of Student " + StudentName + " Session Name " + SessionName;
            voucher.Notes     = "Fee Received by Admin " + StudentName + " Session Name " + SessionName;
            voucher.StudentId = studenfee.StudentId;
            voucher.Date      = GetLocalDateTime.GetLocalDateTimeFunction();
            voucher.CreatedBy = username;
            voucher.SessionID = SessionID;
            int?VoucherObj = db.Vouchers.Max(x => x.VoucherNo);

            voucher.VoucherNo = Convert.ToInt32(VoucherObj) + 1;
            db.Vouchers.Add(voucher);

            db.SaveChanges();


            var           Leadger = db.Ledgers.Where(x => x.Name == "Account Receiveable").FirstOrDefault();
            int           AccountReceiveableId = Leadger.Id;
            decimal?      CurrentBalance       = Leadger.CurrentBalance;
            decimal?      AfterBalance         = 0;
            VoucherRecord voucherRecord        = new VoucherRecord();

            if (Discount != 0)
            {
                AfterBalance = CurrentBalance - Convert.ToDecimal(CashReceived) - Math.Round(Convert.ToDecimal(Discount));
            }
            else
            {
                AfterBalance = CurrentBalance - Convert.ToDecimal(CashReceived);
            }
            voucherRecord.LedgerId       = AccountReceiveableId;
            voucherRecord.Type           = "Cr";
            voucherRecord.Amount         = Convert.ToDecimal(CashReceived) + Math.Round(Convert.ToDecimal(Discount));
            voucherRecord.CurrentBalance = CurrentBalance;

            voucherRecord.AfterBalance = AfterBalance;
            voucherRecord.VoucherId    = voucher.Id;
            voucherRecord.Description  = "Fee received of Student (" + StudentName + ") (" + SessionName + ") ";

            Leadger.CurrentBalance = AfterBalance;
            try
            {
                db.VoucherRecords.Add(voucherRecord);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                var a = ex.Message;
            }

            var     LeadgerAD        = db.Ledgers.Where(x => x.Name == "Admin Drawer").FirstOrDefault();
            int     AdminDrawerId    = LeadgerAD.Id;
            decimal?CurrentBalanceAD = LeadgerAD.CurrentBalance;

            VoucherRecord voucherRecord1 = new VoucherRecord();
            decimal?      AfterBalanceAD = CurrentBalanceAD + Convert.ToDecimal(CashReceived);

            voucherRecord1.LedgerId       = AdminDrawerId;
            voucherRecord1.Type           = "Dr";
            voucherRecord1.Amount         = Convert.ToDecimal(CashReceived);
            voucherRecord1.CurrentBalance = CurrentBalanceAD;

            voucherRecord1.AfterBalance = AfterBalanceAD;
            voucherRecord1.VoucherId    = voucher.Id;
            voucherRecord1.Description  = "Fee Collected by student  (" + StudentName + ") (" + SessionName + ") ";

            LeadgerAD.CurrentBalance = AfterBalanceAD;
            db.VoucherRecords.Add(voucherRecord1);
            db.SaveChanges();


            if (Discount != 0)
            {
                VoucherRecord voucherRecord3 = new VoucherRecord();

                var LeadgerDiscount = db.Ledgers.Where(x => x.Name == "Discount").FirstOrDefault();

                decimal?CurrentBalanceOfDiscount = LeadgerDiscount.CurrentBalance;
                decimal?AfterBalanceOfDiscount   = CurrentBalanceOfDiscount + Math.Round(Convert.ToDecimal(Discount));
                voucherRecord3.LedgerId        = LeadgerDiscount.Id;
                voucherRecord3.Type            = "Dr";
                voucherRecord3.Amount          = Math.Round(Convert.ToDecimal(Discount));
                voucherRecord3.CurrentBalance  = CurrentBalanceOfDiscount;
                voucherRecord3.AfterBalance    = AfterBalanceOfDiscount;
                voucherRecord3.VoucherId       = voucher.Id;
                voucherRecord3.Description     = "Discount given to student (" + StudentName + ") (" + SessionName + ")  on payable fee " + FeePayable;
                LeadgerDiscount.CurrentBalance = AfterBalanceOfDiscount;

                db.VoucherRecords.Add(voucherRecord3);
                db.SaveChanges();
            }


            return(Json("", JsonRequestBehavior.AllowGet));
        }
コード例 #11
0
        //public ActionResult GetStudentInstalment(int stdid)
        //{
        //   var amount= db.StudentFeeMultipliers.Where(x => x.StudentId == stdid).Select(x => x.SharePerInstalment).FirstOrDefault();
        //    return Json(amount,JsonRequestBehavior.AllowGet);
        //}
        // GET: StudentFeeMonths/Edit/5
        public ActionResult GetStatusRecord(string StatusRecord)
        {
            var    dbTransaction = db.Database.BeginTransaction();
            string status        = "error";

            if (StatusRecord != "")
            {
                var RecordId = StatusRecord.Split(',');
                for (int i = 0; i < RecordId.Count(); i++)
                {
                    double?         Arrear = 0;
                    var             sfmid  = Int32.Parse(RecordId[i]);
                    StudentFeeMonth data   = db.StudentFeeMonths.Where(x => x.Id == sfmid).FirstOrDefault();
                    if (data.Status == "Printed")
                    {
                        data.Status = "Clear";

                        ///////////////arrears////////////
                        var  _SessionId = data.SessionId;
                        int  _Id        = data.Id - 1;
                        bool Flag       = true;

                        while (Flag)
                        {
                            try
                            {
                                double?payableamount = db.StudentFeeMonths.Where(x => x.StudentId == data.StudentId && x.SessionId == _SessionId && x.Status == "Pending" && x.Id == _Id).FirstOrDefault().FeePayable;

                                Arrear += payableamount;
                                _Id--;
                            }
                            catch (Exception ex)
                            {
                                Flag = false;
                            }
                        }
                        var totalreceivable = Arrear + data.FeePayable;
                        /////////End/////////
                        try
                        {
                            Ledger ledger_Assets = db.Ledgers.Where(x => x.Name == "Student Receivables").FirstOrDefault();
                            ledger_Assets.CurrentBalance -= Convert.ToDecimal(totalreceivable);
                            db.SaveChanges();

                            Ledger ledger_bank = db.Ledgers.Where(x => x.Name == "Meezan Bank" && x.LedgerGroup.Name == "Bank").FirstOrDefault();
                            ledger_bank.CurrentBalance += Convert.ToDecimal(totalreceivable);
                            db.SaveChanges();
                            status = "success";
                        }
                        catch
                        {
                            TempData["ErrorMessage"] = "No Cash in Student Receivables Account.";
                            return(RedirectToAction("Edit", data));
                            //   return RedirectToAction("Edit?="+studentFeeMonth.StudentId);
                        }
                    }
                    else if (data.Status == "Clear")
                    {
                        data.Status = "Printed";
                        var totalreceivable = Arrear + data.FeePayable;

                        try
                        {
                            Ledger ledger_Assets = db.Ledgers.Where(x => x.Name == "Student Receivables").FirstOrDefault();
                            ledger_Assets.CurrentBalance += Convert.ToDecimal(totalreceivable);
                            db.SaveChanges();

                            Ledger ledger_bank = db.Ledgers.Where(x => x.Name == "Meezan Bank" && x.LedgerGroup.Name == "Bank").FirstOrDefault();
                            ledger_bank.CurrentBalance -= Convert.ToDecimal(totalreceivable);
                            db.SaveChanges();
                            status = "success";
                        }
                        catch
                        {
                            TempData["ErrorMessage"] = "No Cash in Meezan Bank Account.";
                            return(RedirectToAction("Edit", data));
                            //   return RedirectToAction("Edit?="+studentFeeMonth.StudentId);
                        }
                    }

                    if (db.SaveChanges() > 0)
                    {
                        status = "success";
                    }
                }
            }
            dbTransaction.Commit();
            return(Content(status));
        }
コード例 #12
0
        public ActionResult Create([Bind(Include = "Id,ClassId,ComputerLabCharges,SecurityServices,LabCharges,Transportation,SportsShirt,ChineseClassFee,AdvanceTax,Other,TutionFee,TotalFee,SessionId")] StudentRecurringFee studentRecurringFee)
        {
            //  var dbTransaction = db.Database.BeginTransaction();
            try
            {
                if (ModelState.IsValid)
                {
                    db.StudentRecurringFees.Add(studentRecurringFee);
                    db.SaveChanges();
                    //var stdList = db.AspNetStudents.Where(x => x.ClassID == studentRecurringFee.ClassId && x.AspNetUser.Status != "False").ToList().Count();
                    //for (int i = 0; i < stdList; i++)
                    //{
                    //    Ledger ledger = db.Ledgers.Where(x => x.Name == "Student Receivables").FirstOrDefault();
                    //    ledger.StartingBalance += Convert.ToDecimal(studentRecurringFee.TotalFee);
                    //    ledger.CurrentBalance += Convert.ToDecimal(studentRecurringFee.TotalFee);
                    //    db.SaveChanges();

                    //}

                    //for (int i = 0; i < stdList; i++)
                    //{
                    //    Ledger ledger = db.Ledgers.Where(x => x.Name == "Student Fee").FirstOrDefault();
                    //    ledger.StartingBalance += Convert.ToDecimal(studentRecurringFee.TotalFee);
                    //    ledger.CurrentBalance += Convert.ToDecimal(studentRecurringFee.TotalFee);
                    //    db.SaveChanges();

                    //}



                    //multiplier
                    List <AspNetStudent> list = db.AspNetStudents.Where(x => x.ClassID == studentRecurringFee.ClassId && x.AspNetUser.Status != "False").ToList();
                    foreach (var std in list)
                    {
                        var      classid     = db.AspNetStudents.Where(x => x.Id == std.Id).Select(x => x.ClassID).FirstOrDefault();
                        var      totalfee    = db.StudentRecurringFees.Where(x => x.ClassId == std.ClassID).FirstOrDefault();
                        var      installment = totalfee.TotalFee / 12;
                        string[] Months      = { "September", "October", "November", "December", "January", "February", "March", "April", "May", "June", "July", "August" };
                        for (int i = 0; i < Months.Count(); i++)
                        {
                            StudentFeeMonth stdfeemonth = new StudentFeeMonth();
                            stdfeemonth.StudentId        = std.Id;
                            stdfeemonth.Multiplier       = 1;
                            stdfeemonth.SessionId        = studentRecurringFee.SessionId;
                            stdfeemonth.Status           = "Pending";
                            stdfeemonth.InstalmentAmount = installment;
                            stdfeemonth.FeePayable       = installment;
                            var dddd = DateTime.Now;
                            var d    = dddd.ToString("yyyy-MM-dd");
                            stdfeemonth.IssueDate = d;
                            stdfeemonth.Months    = Months[i];
                            db.StudentFeeMonths.Add(stdfeemonth);
                            //  db.SaveChanges();
                        }
                        //      dbTransaction.Commit();
                    }

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                //    dbTransaction.Dispose();
                ViewBag.ErrorMessage = e.Message;
            }

            ViewBag.ClassId = new SelectList(db.AspNetClasses, "Id", "Name", studentRecurringFee.ClassId);
            return(View(studentRecurringFee));
        }
コード例 #13
0
        // POST: StudentRecurringFees/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.

        public ActionResult AddData(FeesData data)
        {
            int?sessionId = db.AspNetClasses.Where(x => x.Id == data.ClassId).FirstOrDefault().SessionID;

            if (ModelState.IsValid)
            {
                var TotalFee = db.AspNetSessions.Where(x => x.Id == SessionID).FirstOrDefault().Total_Fee;

                decimal?TotalFeeOfAllStudents = 0;


                var feetype = Request.Form["feeType"];
                IEnumerable <string> selectedstudents = Request.Form["students"].Split(',');
                int count = selectedstudents.Count();

                for (int i = 1; i <= count; i++)
                {
                    TotalFeeOfAllStudents = TotalFee + TotalFeeOfAllStudents;
                }
                StudentRecurringFee studentRecurringFees = new StudentRecurringFee();
                studentRecurringFees.ClassId   = data.ClassId;
                studentRecurringFees.SessionId = sessionId;
                studentRecurringFees.TutionFee = TotalFee;
                studentRecurringFees.TotalFee  = TotalFee;
                db.StudentRecurringFees.Add(studentRecurringFees);
                db.SaveChanges();

                var Total_Fees = studentRecurringFees.TotalFee;

                if (feetype == "Installment")
                {
                    var CalculatedFee = Total_Fees / 2;
                    foreach (var std in selectedstudents)
                    {
                        AspNetStudent student = db.AspNetStudents.Where(x => x.StudentID == std).FirstOrDefault();

                        var classid = db.AspNetStudents.Where(x => x.Id == student.Id).Select(x => x.ClassID).FirstOrDefault();
                        var Month   = DateTime.Now.ToString("MMMM");

                        for (int i = 0; i <= 3; i++)
                        {
                            var             FirstMonth  = DateTime.Now.ToString("MMMM");
                            StudentFeeMonth stdfeemonth = new StudentFeeMonth();
                            stdfeemonth.StudentId  = student.Id;
                            stdfeemonth.Multiplier = 2;
                            stdfeemonth.SessionId  = sessionId;
                            stdfeemonth.Status     = "Pending";

                            var dddd = DateTime.Now;
                            var d    = dddd.ToString("yyyy-MM-dd");
                            //shahzad   stdfeemonth.IssueDate = d;

                            if (i == 0)
                            {
                                stdfeemonth.Months           = DateTime.Now.ToString("MMMM");
                                stdfeemonth.InstalmentAmount = CalculatedFee;
                                stdfeemonth.FeePayable       = CalculatedFee;
                            }
                            else if (i == 1)
                            {
                                stdfeemonth.InstalmentAmount = 0;
                                stdfeemonth.FeePayable       = 0;
                                stdfeemonth.Months           = DateTime.Now.Date.AddMonths(1).ToString("MMMM");
                            }
                            else if (i == 2)
                            {
                                stdfeemonth.Months           = DateTime.Now.Date.AddMonths(2).ToString("MMMM");
                                stdfeemonth.InstalmentAmount = CalculatedFee;
                                stdfeemonth.FeePayable       = CalculatedFee;
                            }
                            else if (i == 3)
                            {
                                stdfeemonth.InstalmentAmount = 0;
                                stdfeemonth.FeePayable       = 0;
                                stdfeemonth.Months           = DateTime.Now.Date.AddMonths(3).ToString("MMMM");
                            }
                            else
                            {
                                //do nothing
                            }

                            stdfeemonth.FeeType = "Installment";
                            db.StudentFeeMonths.Add(stdfeemonth);
                            db.SaveChanges();
                        }
                    }
                }


                else if (feetype == "PerMonth")
                {
                    foreach (var std in selectedstudents)
                    {
                        var           CalculatedFee = Total_Fees / 4;
                        AspNetStudent student       = db.AspNetStudents.Where(x => x.StudentID == std).FirstOrDefault();

                        var classid = db.AspNetStudents.Where(x => x.Id == student.Id).Select(x => x.ClassID).FirstOrDefault();
                        var Month   = DateTime.Now.ToString("MMMM");

                        for (int i = 0; i <= 3; i++)
                        {
                            var             FirstMonth  = DateTime.Now.ToString("MMMM");
                            StudentFeeMonth stdfeemonth = new StudentFeeMonth();
                            stdfeemonth.StudentId  = student.Id;
                            stdfeemonth.Multiplier = 1;
                            stdfeemonth.SessionId  = sessionId;
                            stdfeemonth.Status     = "Pending";

                            var dddd = DateTime.Now;
                            var d    = dddd.ToString("yyyy-MM-dd");
                            //shahzad  stdfeemonth.IssueDate = d;

                            if (i == 0)
                            {
                                stdfeemonth.Months           = DateTime.Now.ToString("MMMM");
                                stdfeemonth.InstalmentAmount = CalculatedFee;
                                stdfeemonth.FeePayable       = CalculatedFee;
                            }
                            else
                            {
                                stdfeemonth.InstalmentAmount = CalculatedFee;
                                stdfeemonth.FeePayable       = CalculatedFee;
                                stdfeemonth.Months           = DateTime.Now.Date.AddMonths(i).ToString("MMMM");
                            }

                            stdfeemonth.FeeType = "PerMonth";
                            db.StudentFeeMonths.Add(stdfeemonth);
                            db.SaveChanges();
                        }
                    }
                }
                else
                {
                    foreach (var std in selectedstudents)
                    {
                        AspNetStudent student = db.AspNetStudents.Where(x => x.StudentID == std).FirstOrDefault();

                        var classid = db.AspNetStudents.Where(x => x.Id == student.Id).Select(x => x.ClassID).FirstOrDefault();
                        var Month   = DateTime.Now.ToString("MMMM");

                        for (int i = 0; i <= 3; i++)
                        {
                            var             FirstMonth  = DateTime.Now.ToString("MMMM");
                            StudentFeeMonth stdfeemonth = new StudentFeeMonth();
                            stdfeemonth.StudentId  = student.Id;
                            stdfeemonth.Multiplier = 4;
                            stdfeemonth.SessionId  = sessionId; //could be change To SessionID
                            stdfeemonth.Status     = "Pending";

                            var dddd = DateTime.Now;
                            var d    = dddd.ToString("yyyy-MM-dd");
                            //shahzad  stdfeemonth.IssueDate = d;

                            if (i == 0)
                            {
                                stdfeemonth.Months           = DateTime.Now.ToString("MMMM");
                                stdfeemonth.InstalmentAmount = Total_Fees;
                                stdfeemonth.FeePayable       = Total_Fees;
                            }
                            else
                            {
                                stdfeemonth.InstalmentAmount = 0;
                                stdfeemonth.FeePayable       = 0;
                                stdfeemonth.Months           = DateTime.Now.Date.AddMonths(i).ToString("MMMM");
                            }

                            stdfeemonth.FeeType = "Lumsum";
                            db.StudentFeeMonths.Add(stdfeemonth);
                            db.SaveChanges();
                        }
                    }
                }

                var id       = User.Identity.GetUserId();
                var username = db.AspNetUsers.Where(x => x.Id == id).Select(x => x.Name).FirstOrDefault();

                Voucher voucher = new Voucher();
                voucher.Name      = "Student Fee Created";
                voucher.Notes     = "Student Fee Created";
                voucher.Date      = DateTime.Now;
                voucher.Name      = username;
                voucher.CreatedBy = username;
                voucher.SessionID = sessionId;
                int?VoucherObj = db.Vouchers.Max(x => x.VoucherNo);

                voucher.VoucherNo = Convert.ToInt32(VoucherObj) + 1;
                db.Vouchers.Add(voucher);
                db.SaveChanges();

                var Leadger = db.Ledgers.Where(x => x.Name == "Account Receiveable").FirstOrDefault();

                int           AccountRecId   = Leadger.Id;
                decimal?      CurrentBalance = Leadger.CurrentBalance;
                VoucherRecord voucherRecord  = new VoucherRecord();
                decimal?      AfterBalance   = CurrentBalance + TotalFeeOfAllStudents;
                voucherRecord.LedgerId       = AccountRecId;
                voucherRecord.Type           = "Dr";
                voucherRecord.Amount         = TotalFeeOfAllStudents;
                voucherRecord.CurrentBalance = CurrentBalance;
                voucherRecord.AfterBalance   = AfterBalance;
                voucherRecord.VoucherId      = voucher.Id;
                voucherRecord.Description    = "Student Fee debited in Account Receiveable";
                Leadger.CurrentBalance       = AfterBalance;
                db.VoucherRecords.Add(voucherRecord);
                db.SaveChanges();

                //Second;

                VoucherRecord voucherRecord1 = new VoucherRecord();

                var LeadgerStudentFee = db.Ledgers.Where(x => x.Name == "Student Fee").FirstOrDefault();

                decimal?CurrentBalanceOfStudentFee = LeadgerStudentFee.CurrentBalance;
                decimal?AfterBalanceOfStudentFee   = CurrentBalanceOfStudentFee + TotalFeeOfAllStudents;
                voucherRecord1.LedgerId          = LeadgerStudentFee.Id;
                voucherRecord1.Type              = "Cr";
                voucherRecord1.Amount            = TotalFeeOfAllStudents;
                voucherRecord1.CurrentBalance    = CurrentBalanceOfStudentFee;
                voucherRecord1.AfterBalance      = AfterBalanceOfStudentFee;
                voucherRecord1.VoucherId         = voucher.Id;
                voucherRecord1.Description       = "Student Fee Credit in Income";
                LeadgerStudentFee.CurrentBalance = AfterBalanceOfStudentFee;

                db.VoucherRecords.Add(voucherRecord1);
                db.SaveChanges();


                // db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
コード例 #14
0
        public JsonResult GetChallanForm(string month, string idlist)
        {
            var userid    = idlist.Split(',');
            var Nextmonth = "";
            var dates     = db.FeeDateSettings.FirstOrDefault();
            List <challanform> ChallanList = new List <challanform>();

            try
            {
                foreach (var item in userid)
                {
                    var             student          = db.AspNetStudents.Where(x => x.StudentID == item).FirstOrDefault();
                    StudentFeeMonth Student_FeeMonth = db.StudentFeeMonths.Where(x => x.StudentId == student.Id && x.Months == month).FirstOrDefault();
                    Student_FeeMonth.ValildityDate = dates.ValidityDate;
                    Student_FeeMonth.DueDate       = dates.DueDate;
                    Student_FeeMonth.Status        = "Printed";
                    db.SaveChanges();

                    int recordid = Student_FeeMonth.Id;
                    recordid++;
                    var Studentdata = db.StudentFeeMonths.Where(x => x.Id == recordid).FirstOrDefault();
                    if (Studentdata.Multiplier == 0)
                    {
                        Nextmonth = month + '-' + Studentdata.Months;
                    }
                    double?trip = 0;
                    NonRecurringFeeMultiplier nonrecurringfee = db.NonRecurringFeeMultipliers.Where(x => x.StudentId == student.Id && x.Month == Student_FeeMonth.Months).FirstOrDefault();
                    if (nonrecurringfee != null)
                    {
                        trip = nonrecurringfee.TutionFee;
                    }



                    AspNetSession Session         = db.AspNetSessions.OrderByDescending(x => x.Id).Select(x => x).FirstOrDefault();
                    decimal?      No              = 0;
                    var           Student_Penalty = db.StudentPenalties.Where(x => x.StudentId == student.Id && x.Status == "Pending").Select(x => x.PenaltyFee.Amount).FirstOrDefault();

                    if (Student_Penalty == null)
                    {
                        Student_Penalty = 0;
                    }
                    var Student_discount = db.StudentDiscounts.Where(x => x.StudentId == student.Id).Select(x => x.FeeDiscount.Amount).FirstOrDefault();

                    if (Student_discount == null)
                    {
                        Student_discount = 0;
                    }

                    ///////////////arrears////////////
                    var    _SessionId = Student_FeeMonth.SessionId;
                    int    _Id        = Student_FeeMonth.Id - 1;
                    bool   Flag       = true;
                    double?Arrear     = 0;
                    while (Flag)
                    {
                        try
                        {
                            double?payableamount = db.StudentFeeMonths.Where(x => x.StudentId == student.Id && x.SessionId == _SessionId && x.Status == "Pending" && x.Id == _Id).FirstOrDefault().FeePayable;

                            Arrear += payableamount;
                            _Id--;
                        }
                        catch (Exception ex)
                        {
                            Flag = false;
                        }
                    }
                    /////////End/////////

                    challanform Challan = new challanform();
                    Challan.AcademicSessionStart = Session.SessionStartDate;
                    Challan.AcademicSessionEnd   = Session.SessionEndDate;
                    Challan.StudentName          = student.AspNetUser.Name;
                    Challan.StudentUserName      = student.AspNetUser.UserName;
                    Challan.StudentClass         = student.AspNetClass.ClassName;
                    Challan.SchoolName           = "IPC Aziz Avenue Campus";
                    Challan.BranchName           = "Canal Branch";
                    Challan.ChallanCopy          = new List <string>();
                    Challan.ChallanCopy.Add("Parent Copy");
                    Challan.ChallanCopy.Add("Bank Copy");
                    Challan.ChallanCopy.Add("School Copy");


                    if (Nextmonth == "")
                    {
                        Challan.FeeMonth = Student_FeeMonth.Months;
                    }
                    else
                    {
                        Challan.FeeMonth = Nextmonth;
                    }
                    var duedate = Student_FeeMonth.DueDate.ToString().Split(' ');
                    Challan.DueDate = duedate[0];
                    var validdate = Student_FeeMonth.ValildityDate.ToString().Split(' ');
                    Challan.ValidDate = validdate[0];

                    Challan.PayableFee = Student_FeeMonth.FeePayable - Convert.ToDouble(Student_discount);
                    Challan.Arrears    = Arrear;
                    var totalpayable = Arrear + Convert.ToDouble(Student_Penalty) + Student_FeeMonth.FeePayable;
                    Challan.TripCharges = trip;
                    Challan.TotalAmount = totalpayable + trip;

                    /////////////Challan No/////////////
                    var challan = db.StudentChallanForms.Where(x => x.StudentId == student.Id && x.StudentFeeMonthId == Student_FeeMonth.Id).FirstOrDefault();
                    if (challan == null)
                    {
                        try
                        {
                            No = (int)db.StudentChallanForms.Select(x => x.ChallanNo).Max();
                            No++;
                            StudentChallanForm stdchallan = new StudentChallanForm();
                            stdchallan.StudentId         = student.Id;
                            stdchallan.ChallanNo         = No;
                            stdchallan.StudentFeeMonthId = Student_FeeMonth.Id;
                            stdchallan.Status            = "Created";
                            db.StudentChallanForms.Add(stdchallan);
                            db.SaveChanges();
                            ////////////// Accounting System///////////////
                            Ledger ledger_Assets = db.Ledgers.Where(x => x.Name == "Student Receivables").FirstOrDefault();
                            ledger_Assets.CurrentBalance += Convert.ToDecimal(Challan.TotalAmount);
                            db.SaveChanges();

                            Ledger ledger_Income = db.Ledgers.Where(x => x.Name == "Student Fee").FirstOrDefault();
                            ledger_Income.CurrentBalance += Convert.ToDecimal(Challan.TotalAmount);
                            db.SaveChanges();
                            ///////////////Send Text Message//////////////////

                            //AspNetParent_Child parentChild = db.AspNetParent_Child.Where(x => x.ChildID == student.AspNetUser.Id).FirstOrDefault();
                            //var number = db.AspNetUsers.Where(x => x.Id == parentChild.ParentID).Select(x => x.PhoneNumber).FirstOrDefault();
                            //var message = "Fee Challan of " + student.AspNetUser.Name + "is generated. Its due date is :" + Challan.DueDate + "and validity date:" + Challan.ValidDate;
                            //var url = "http://www.outreach.pk/api/sendsms.php/sendsms/url";
                            //String result = "";
                            //var newnum = "";
                            //if (number != null)
                            //{
                            //    var num = number.Substring(1);
                            //    newnum = "92" + num;
                            //}

                            //String messageer = HttpUtility.UrlEncode(message);

                            //String strPost = "id=ipcngsch&pass=ipc_ngs123&msg=" + messageer + "&to=" + newnum + "&mask=IPC-NGS&type=xml&lang=English";
                            //StreamWriter myWriter = null;
                            //HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
                            //objRequest.Method = "POST";
                            //objRequest.ContentLength = Encoding.UTF8.GetByteCount(strPost);
                            //objRequest.ContentType = "application/x-www-form-urlencoded";
                            //try
                            //{
                            //    myWriter = new StreamWriter(objRequest.GetRequestStream());
                            //    myWriter.Write(strPost);
                            //}
                            //catch (Exception e)
                            //{

                            //}
                            //finally
                            //{
                            //    myWriter.Close();
                            //}
                            //HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
                            //using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
                            //{
                            //    result = sr.ReadToEnd();
                            //    // Close and clean up the StreamReader
                            //    sr.Close();
                            //}
                            //var messge = result;

                            //////////////end text message///////////
                        }
                        catch
                        {
                            No = 5050100;
                            StudentChallanForm stdchallan = new StudentChallanForm();
                            stdchallan.StudentId         = student.Id;
                            stdchallan.ChallanNo         = No;
                            stdchallan.StudentFeeMonthId = Student_FeeMonth.Id;
                            stdchallan.Status            = "Created";
                            db.StudentChallanForms.Add(stdchallan);
                            db.SaveChanges();
                            /////////// Accounting System///////////
                            Ledger ledger_Assets = db.Ledgers.Where(x => x.Name == "Student Receivables").FirstOrDefault();
                            ledger_Assets.CurrentBalance += Convert.ToDecimal(Challan.TotalAmount);
                            db.SaveChanges();

                            Ledger ledger_Income = db.Ledgers.Where(x => x.Name == "Student Fee").FirstOrDefault();
                            ledger_Income.CurrentBalance += Convert.ToDecimal(Challan.TotalAmount);
                            db.SaveChanges();
                            ////////////////End///////////////
                        }
                    }
                    else
                    {
                        No = challan.ChallanNo;
                    }
                    Challan.ChallanID = No;


                    ChallanList.Add(Challan);
                }


                return(Json(ChallanList, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                var Error = "Error";
                return(Json(Error, JsonRequestBehavior.AllowGet));
            }
        }