public ActionResult BonafideCertificate(FormCollection frm) { LeavingCertificateVM leavingCertificateVM = new LeavingCertificateVM(); if (frm["RegisterId"] != null && !string.IsNullOrEmpty(frm["RegisterId"])) { leavingCertificateVM.RegisterId = Convert.ToInt32(frm["RegisterId"]); } if (frm["ClassId"] != null && !string.IsNullOrEmpty(frm["ClassId"])) { leavingCertificateVM.ClassId = Convert.ToInt32(frm["ClassId"]); } if (frm["DivisionId"] != null && !string.IsNullOrEmpty(frm["DivisionId"])) { leavingCertificateVM.DivisionId = Convert.ToInt32(frm["DivisionId"]); } if (frm["StudentId"] != null && !string.IsNullOrEmpty(frm["StudentId"])) { leavingCertificateVM.StudentId = Convert.ToInt32(frm["StudentId"]); } if (ModelState.IsValid) { PresentationLayer.Helpers.SessionHelper.ReportIndex = 1; PresentationLayer.Helpers.SessionHelper.StudentId = leavingCertificateVM.StudentId; return(Redirect(@"~\Report.aspx")); } else { ClassBAL classBAL = new ClassBAL(); leavingCertificateVM.Classes = from obj in classBAL.GetAll() where obj.Status == true select new SelectListItem() { Text = obj.ClassName, Value = obj.ClassId.ToString() }; return(View(leavingCertificateVM)); } }
public ActionResult Index(FormCollection formCollection, StudentClassChangeVM viewModel) { if (formCollection["PreviousClassId"] != null && formCollection["PreviousClassId"] != "") { viewModel.PreviousClassId = Convert.ToInt32(formCollection["PreviousClassId"]); } if (formCollection["PreviousDivisionId"] != null && formCollection["PreviousDivisionId"] != "") { viewModel.PreviousDivisionId = Convert.ToInt32(formCollection["PreviousDivisionId"]); } if (viewModel.PreviousClassId > 0 && viewModel.PreviousDivisionId > 0) { ClassDivisionBAL classDivisionBAL = new ClassDivisionBAL(); IQueryable <Entities.ClassDivision> classDivistions = classDivisionBAL.FindBy(cd => cd.ClassId == viewModel.PreviousClassId && cd.DivisionId == viewModel.PreviousDivisionId); if (classDivistions != null && classDivistions.Count() > 0) { viewModel.PreviousClassDivisionId = classDivistions.FirstOrDefault().ClassDivisionId; } } if (formCollection["CurrentClassId"] != null && formCollection["CurrentClassId"] != "") { viewModel.CurrentClassId = Convert.ToInt32(formCollection["CurrentClassId"]); } if (formCollection["CurrentDivisionId"] != null && formCollection["CurrentDivisionId"] != "") { viewModel.CurrentDivisionId = Convert.ToInt32(formCollection["CurrentDivisionId"]); } if (viewModel.CurrentClassId > 0 && viewModel.CurrentDivisionId > 0) { ClassDivisionBAL classDivisionBAL = new ClassDivisionBAL(); IQueryable <Entities.ClassDivision> classDivistions = classDivisionBAL.FindBy(cd => cd.ClassId == viewModel.CurrentClassId && cd.DivisionId == viewModel.CurrentDivisionId); if (classDivistions != null && classDivistions.Count() > 0) { viewModel.CurrentClassDivisionId = classDivistions.FirstOrDefault().ClassDivisionId; } } string assignChkBx = string.Empty; if (formCollection["assignChkBx"] != null && formCollection["assignChkBx"] != "") { assignChkBx = Convert.ToString(formCollection["assignChkBx"]); } if (!string.IsNullOrEmpty(assignChkBx)) { viewModel.StudentClassChangeSubList = new List <StudentClassChangeSubVM>(); string[] strArrFeeId = assignChkBx.Split(','); if (strArrFeeId.Length > 0) { for (int i = 0; i < strArrFeeId.Length; i++) { StudentClassChangeSubVM studentClassChangeSubVM = new StudentClassChangeSubVM(); studentClassChangeSubVM.StudentId = Convert.ToInt32(strArrFeeId[i]); viewModel.StudentClassChangeSubList.Add(studentClassChangeSubVM); } } } //if (viewModel.StudentClassChangeSubList != null) //{ // viewModel.NoOfSelectedRecords = viewModel.StudentClassChangeSubList.Count; //} TryUpdateModel <StudentClassChangeVM>(viewModel); if (ModelState.IsValid) { Entities.StudentClassChange entity = new Entities.StudentClassChange(); entity.PreviousClassDivisionId = viewModel.PreviousClassDivisionId; entity.CurrentClassDivisionId = viewModel.CurrentClassDivisionId; entity.Remark = myRes.Studenttransferfrompreviousclass; entity.SelectedStudent = new int[viewModel.StudentClassChangeSubList.Count()]; int i = 0; foreach (var item in viewModel.StudentClassChangeSubList) { entity.SelectedStudent[i] = item.StudentId; i++; } StudentBAL balObject = new StudentBAL(); balObject.StudentChangeClassDivision(entity, SessionHelper.SchoolId); } ClassBAL classBAL = new ClassBAL(); viewModel.Classes = from obj in classBAL.GetAll() select new SelectListItem() { Text = obj.ClassName, Value = obj.ClassId.ToString() }; return(View(viewModel)); }
public ActionResult Create(FormCollection formCollection) { StudentTransactionVM viewModel = new StudentTransactionVM(); try { if (formCollection["ReceiptNo"] != null) { viewModel.ReceiptNo = Convert.ToInt32(formCollection["ReceiptNo"]); } if (formCollection["StudentTransactionId"] != null && formCollection["StudentTransactionId"] != "") { viewModel.StudentTransactionId = Convert.ToInt32(formCollection["StudentTransactionId"]); } if (formCollection["ClassId"] != null && formCollection["ClassId"] != "") { viewModel.ClassId = Convert.ToInt32(formCollection["ClassId"]); } if (formCollection["DivisionId"] != null && formCollection["DivisionId"] != "") { viewModel.DivisionId = Convert.ToInt32(formCollection["DivisionId"]); } if (formCollection["StudentId"] != null && formCollection["StudentId"] != "") { viewModel.StudentId = Convert.ToInt32(formCollection["StudentId"]); } if (formCollection["TransactionDate"] != null) { viewModel.TransactionDate = Convert.ToDateTime(formCollection["TransactionDate"]); } viewModel.Remark = Convert.ToString(formCollection["Remark"]); if (formCollection["ReceiptTotal"] != null && formCollection["ReceiptTotal"] != "") { viewModel.ReceiptTotal = Convert.ToDecimal(formCollection["ReceiptTotal"]); } viewModel.BankName = Convert.ToString(formCollection["BankName"]); viewModel.ChequeNumber = Convert.ToString(formCollection["ChequeNumber"]); TryUpdateModel <StudentTransactionVM>(viewModel); // TODO: Add insert logic here if (ModelState.IsValid) { Entities.StudentTransaction entity = new Entities.StudentTransaction(); if (formCollection["ReceiptNo"] != null) { entity.ReceiptNo = Convert.ToInt32(formCollection["ReceiptNo"]); } if (formCollection["StudentTransactionId"] != null && formCollection["StudentTransactionId"] != "") { entity.StudentTransactionId = Convert.ToInt32(formCollection["StudentTransactionId"]); } if (formCollection["ClassId"] != null && formCollection["ClassId"] != "" && formCollection["DivisionId"] != null && formCollection["DivisionId"] != "") { ClassDivisionBAL classDivisionBAL = new ClassDivisionBAL(); entity.ClassDivisionId = classDivisionBAL.FindBy(cd => cd.ClassId == Convert.ToInt32(formCollection["ClassId"]) && cd.DivisionId == Convert.ToInt32(formCollection["DivisionId"])).FirstOrDefault().ClassDivisionId; } if (formCollection["StudentId"] != null && formCollection["StudentId"] != "") { entity.StudentId = Convert.ToInt32(formCollection["StudentId"]); } if (formCollection["TransactionDate"] != null) { entity.TransactionDate = Convert.ToDateTime(formCollection["TransactionDate"]); } entity.Status = true; entity.Remark = Convert.ToString(formCollection["Remark"]); if (formCollection["ReceiptTotal"] != null && formCollection["ReceiptTotal"] != "") { entity.ReceiptTotal = Convert.ToDecimal(formCollection["ReceiptTotal"]); } entity.BankName = Convert.ToString(formCollection["BankName"]); entity.ChequeNumber = Convert.ToString(formCollection["ChequeNumber"]); entity.StudentTransactionSubList = new List <Entities.StudentTransactionSub>(); //item.StudentTransactionId string itemFeeId = Convert.ToString(formCollection["item.FeeHeadId"]); string itemCr = Convert.ToString(formCollection["item.Cr"]); string itemDr = Convert.ToString(formCollection["item.Dr"]); string itemBalance = Convert.ToString(formCollection["item.Balance"]); if (!string.IsNullOrEmpty(itemFeeId)) { string[] strArrFeeId = itemFeeId.Split(','); string[] strArrCr = itemCr.Split(','); string[] strArrDr = itemDr.Split(','); string[] strArrBalance = itemBalance.Split(','); if (itemFeeId.Length > 0) { for (int i = 0; i < strArrFeeId.Length; i++) { Entities.StudentTransactionSub entitySub = new Entities.StudentTransactionSub(); entitySub.FeeHeadId = Convert.ToInt32(strArrFeeId[i]); entitySub.Cr = Convert.ToDecimal(strArrCr[i]); entitySub.Dr = Convert.ToDecimal(strArrDr[i]); entitySub.Balance = Convert.ToDecimal(strArrBalance[i]); entity.StudentTransactionSubList.Add(entitySub); } } } StudentTransactionBAL balObject = new StudentTransactionBAL(); balObject.Add(entity, SessionHelper.SchoolId); PresentationLayer.Helpers.SessionHelper.ReportIndex = 2; return(Redirect(@"~\Report.aspx")); //return RedirectToAction("Index"); } else { ClassBAL classBAL = new ClassBAL(); viewModel.Classes = from obj in classBAL.GetAll() where obj.Status == true select new SelectListItem() { Text = obj.ClassName, Value = obj.ClassId.ToString() }; return(View(viewModel)); } } catch { ClassBAL classBAL = new ClassBAL(); viewModel.Classes = from obj in classBAL.GetAll() where obj.Status == true select new SelectListItem() { Text = obj.ClassName, Value = obj.ClassId.ToString() }; return(View(viewModel)); } }