public ActionResult Edit(StudentTransactionVM viewModel) { try { // TODO: Add update logic here if (ModelState.IsValid) { Entities.StudentTransaction entity = new Entities.StudentTransaction(); entity.StudentTransactionId = viewModel.StudentTransactionId; entity.ClassDivisionId = viewModel.ClassDivisionId; ClassDivisionBAL classDivisionBAL = new ClassDivisionBAL(); entity.ClassDivisionId = classDivisionBAL.FindBy(cd => cd.ClassId == viewModel.ClassId && cd.DivisionId == viewModel.DivisionId).FirstOrDefault().ClassDivisionId; entity.StudentId = viewModel.StudentId; entity.TransactionDate = viewModel.TransactionDate; entity.Status = viewModel.Status; entity.Remark = viewModel.Remark; StudentTransactionBAL balObject = new StudentTransactionBAL(); balObject.Edit(entity); return(RedirectToAction("Index")); } else { return(View(viewModel)); } } catch { return(View()); } }
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)); } }
private DataSet FeeReceipt() { DataSet ds = new DataSet("dsFeeReceipt"); DataTable dt = new DataTable("Receipt"); dt.TableName = "Receipt"; dt.Columns.Add(new DataColumn("StudentTransactionId", typeof(long))); dt.Columns.Add(new DataColumn("AcademicYear", typeof(string))); dt.Columns.Add(new DataColumn("Class", typeof(string))); dt.Columns.Add(new DataColumn("Division", typeof(string))); dt.Columns.Add(new DataColumn("StudentFullName", typeof(string))); dt.Columns.Add(new DataColumn("TransactionDate", typeof(DateTime))); dt.Columns.Add(new DataColumn("Remark", typeof(string))); dt.Columns.Add(new DataColumn("ReceiptNo", typeof(int))); dt.Columns.Add(new DataColumn("BankName", typeof(string))); dt.Columns.Add(new DataColumn("ChequeNumber", typeof(string))); dt.Columns.Add(new DataColumn("ReceiptTotal", typeof(decimal))); StudentTransactionBAL studentTransactionBAL = new StudentTransactionBAL(); Entities.StudentTransaction entity = studentTransactionBAL.GetAll().LastOrDefault(); long studentTransactionId = 0; if (entity != null) { studentTransactionId = (long)entity.StudentTransactionId; DataRow dr = dt.NewRow(); dr["StudentTransactionId"] = entity.StudentTransactionId; dr["Class"] = entity.ClassName; dr["Division"] = entity.DivisionName; dr["StudentFullName"] = entity.StudentFullNameWithTitle; dr["TransactionDate"] = entity.TransactionDate;//Date dr["Remark"] = entity.Remark; dr["ReceiptNo"] = entity.ReceiptNo; dr["BankName"] = entity.BankName; dr["ChequeNumber"] = entity.ChequeNumber; dr["ReceiptTotal"] = entity.ReceiptTotal; dt.Rows.Add(dr); reportName = entity.ReceiptNo + "_" + entity.StudentFullNameWithTitle; } ds.Tables.Add(dt); if (studentTransactionId > 0) { dt = new DataTable("FeeDetails"); dt.TableName = "FeeDetails"; dt.Columns.Add(new DataColumn("StudentTransactionId", typeof(long))); dt.Columns.Add(new DataColumn("StudentTransactionSubId", typeof(long))); dt.Columns.Add(new DataColumn("FeeHeadName", typeof(string))); dt.Columns.Add(new DataColumn("Cr", typeof(decimal))); dt.Columns.Add(new DataColumn("Dr", typeof(decimal))); dt.Columns.Add(new DataColumn("Balance", typeof(decimal))); studentTransactionBAL = new StudentTransactionBAL(); IQueryable <Entities.StudentTransactionSub> subEntities = studentTransactionBAL.GetAllStudentTransactionSubByTransactionId(studentTransactionId); if (subEntities != null && subEntities.Count() > 0) { foreach (Entities.StudentTransactionSub subEntity in subEntities) { DataRow dr = dt.NewRow(); dr["StudentTransactionId"] = subEntity.StudentTransactionId; dr["StudentTransactionSubId"] = subEntity.StudentTransactionSubId; dr["FeeHeadName"] = subEntity.FeeHeadName; dr["Cr"] = subEntity.Cr; dr["Dr"] = subEntity.Dr; dr["Balance"] = subEntity.Balance; dt.Rows.Add(dr); } } ds.Tables.Add(getSchoolDetails()); ds.Tables.Add(dt); } return(ds); }