public ActionResult create() { try { ViewBag.Employee_Profile = dbcontext.Employee_Profile.Where(a => a.Active == true).ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID }); ViewBag.ManualPaymentTypes_Header = dbcontext.ManualPaymentTypes_Header.ToList().Select(m => new { Code = m.PaymentTypeCode + "-[" + m.PaymentTypeDesc + ']', ID = m.ID }); var Statis = DateTime.Now; var new_record = new ManualPaymentTransactionEntry { EffectiveDate = Statis, TransactionDate = Statis, FromDate = Statis, ToDate = Statis, PaidDate = Statis }; var stru = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Payroll).Structure_Code; var model_ = dbcontext.ManualPaymentTransactionEntry.ToList(); if (model_.Count() == 0) { new_record.TransactionNumber = stru + "1"; } else { new_record.TransactionNumber = stru + (model_.LastOrDefault().ID + 1).ToString(); } var model = new HeaderManual { ManualPaymentTransactionEntry = new_record, Payment_Type_Source_Document = Payment_Type_Source_Document.Manual, check_status = check_status.Created }; return(View(model)); } catch (Exception) { return(RedirectToAction("index")); } }
public ActionResult PaymentSettlementMassTransaction(HeaderManual model, FormCollection form, string Command) { try { List <SelectListItem> items = new List <SelectListItem>(); items.Insert(0, (new SelectListItem { Text = "All employee", Value = "1", })); items.Insert(1, (new SelectListItem { Text = "unit", Value = "2", })); items.Insert(2, (new SelectListItem { Text = "nationality", Value = "3", })); items.Insert(3, (new SelectListItem { Text = "Work location", Value = "4", })); items.Insert(4, (new SelectListItem { Text = "Cost center", Value = "5", })); items.Insert(5, (new SelectListItem { Text = "Cadre level", Value = "6", })); ViewBag.Object = new SelectList(items, "Value", "Text"); ViewBag.Employee_Profile = dbcontext.Employee_Profile.Where(a => a.Active == true).ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID }); ViewBag.ManualPaymentTypes_Header = dbcontext.ManualPaymentTypes_Header.ToList().Select(m => new { Code = m.PaymentTypeCode + "-[" + m.PaymentTypeDesc + ']', ID = m.ID }); var list_emp = new List <Employee_Profile>(); var ID_emp = form["ID_emp"].Split(','); foreach (var item in ID_emp) { if (item != "") { var ID = int.Parse(item); var emp = dbcontext.Employee_Profile.FirstOrDefault(a => a.ID == ID); list_emp.Add(emp); } } foreach (var item2 in list_emp) { ManualPaymentTransactionEntry new_Record = new ManualPaymentTransactionEntry(); var model_ = dbcontext.ManualPaymentTransactionEntry.ToList(); var stru = dbcontext.StructureModels.FirstOrDefault(a => a.All_Models == ChModels.Payroll).Structure_Code; if (model_.Count() == 0) { new_Record.TransactionNumber = stru + "1"; } else { new_Record.TransactionNumber = stru + (model_.LastOrDefault().ID + 1).ToString(); } new_Record.Employee_Code = item2.ID.ToString(); new_Record.ManualPaymentType = model.ManualPaymentTransactionEntry.ManualPaymentType; new_Record.TransactionDate = model.ManualPaymentTransactionEntry.TransactionDate; new_Record.EffectiveDate = model.ManualPaymentTransactionEntry.EffectiveDate; new_Record.CurrentYear = model.ManualPaymentTransactionEntry.CurrentYear; new_Record.PreviousYear = model.ManualPaymentTransactionEntry.PreviousYear; new_Record.FromDate = model.ManualPaymentTransactionEntry.FromDate; new_Record.ToDate = model.ManualPaymentTransactionEntry.ToDate; new_Record.TransactionNote = model.ManualPaymentTransactionEntry.TransactionNote; new_Record.TransactionStatus = check_status.Created.GetHashCode(); new_Record.DocumentType = model.Payment_Type_Source_Document.GetHashCode(); new_Record.Created_By = User.Identity.Name; new_Record.Created_Date = DateTime.Now.Date; new_Record.check_status = HR.Models.Infra.check_status.created; new_Record.name_state = nameof(check_status.Created); var username = User.Identity.GetUserName(); var Date = Convert.ToDateTime("1/1/1900"); var s = new status { statu = HR.Models.Infra.check_status.created, created_by = username, Type = Models.Infra.Type.ManualPaymentTransactionEntry, approved_bydate = Date, cancaled_bydate = Date, created_bydate = DateTime.Now.Date, Rejected_bydate = Date, return_to_reviewdate = Date }; var st = dbcontext.status.Add(s); dbcontext.SaveChanges(); new_Record.statID = s.ID; var Header = dbcontext.ManualPaymentTransactionEntry.Add(new_Record); dbcontext.SaveChanges(); } //////////////// return(RedirectToAction("index")); } catch (Exception e) { return(View(model)); } }
public ActionResult PaymentSettlementMassTransaction() { try { List <SelectListItem> items = new List <SelectListItem>(); items.Insert(0, (new SelectListItem { Text = "All employee", Value = "1", })); items.Insert(1, (new SelectListItem { Text = "unit", Value = "2", })); items.Insert(2, (new SelectListItem { Text = "nationality", Value = "3", })); items.Insert(3, (new SelectListItem { Text = "Work location", Value = "4", })); items.Insert(4, (new SelectListItem { Text = "Cost center", Value = "5", })); items.Insert(5, (new SelectListItem { Text = "Cadre level", Value = "6", })); ViewBag.Object = new SelectList(items, "Value", "Text"); ViewBag.Employee_Profile = dbcontext.Employee_Profile.Where(a => a.Active == true).ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID }); ViewBag.ManualPaymentTypes_Header = dbcontext.ManualPaymentTypes_Header.ToList().Select(m => new { Code = m.PaymentTypeCode + "-[" + m.PaymentTypeDesc + ']', ID = m.ID }); var Statis = DateTime.Now; var new_record = new ManualPaymentTransactionEntry { EffectiveDate = Statis, TransactionDate = Statis, FromDate = Statis, ToDate = Statis, PaidDate = Statis }; var stru = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Payroll).Structure_Code; var model_ = dbcontext.ManualPaymentTransactionEntry.ToList(); if (model_.Count() == 0) { new_record.TransactionNumber = stru + "1"; } else { new_record.TransactionNumber = stru + (model_.LastOrDefault().ID + 1).ToString(); } var model = new HeaderManual { ManualPaymentTransactionEntry = new_record, Payment_Type_Source_Document = new Payment_Type_Source_Document(), check_status = check_status.Created }; return(View(model)); } catch (Exception) { return(RedirectToAction("index")); } }