public ActionResult Payment(Guid?Id) { Permissions p = new Permissions(); bool auth = p.isGranted(User.Identity.Name, this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + this.ControllerContext.RouteData.Values["action"].ToString()); if (!auth) { return(new ViewResult() { ViewName = "Unauthorized" }); } else { HRWebApplication.Common.Master m = new Common.Master(); PaymentViewModels result = (from pRoll in db.Payroll where pRoll.Id == Id select new PaymentViewModels { No = pRoll.No, Amount = pRoll.Amount, IdUser = pRoll.Employee_UserAccounts_Id, hasPayment = pRoll.hasPayment }).Single(); result.Amount -= m.GetTotalPayment(Id.Value); ViewBag.listTarget = new SelectList(db.BankAccount.Where(x => x.Active == true && x.Owner_RefId.Value == result.IdUser).OrderBy(x => x.Name).ToList(), "Id", "Name"); ViewBag.listSource = new SelectList(db.BankAccount.Where(x => x.Active == true && x.Internal == true).OrderBy(x => x.Name).ToList(), "Id", "Name"); return(View(result)); } }
public ActionResult Payment([Bind(Include = "Id,No,Source_BankAccounts_Id,Target_BankAccounts_Id,Amount,ConfirmationNumber,Notes,IdUser,HasPayment")] PaymentViewModels paymentVM) { Common.Master m = new Common.Master(); decimal remaining = db.Payroll.Where(x => x.Id == paymentVM.Id).Select(x => x.Amount).Single() - m.GetTotalPayment(paymentVM.Id); if (paymentVM.Amount > remaining) { ModelState.AddModelError("Over", "The field Amount can't greater than " + remaining.ToString("#,##0")); } if (ModelState.IsValid) { PaymentModels pay = new PaymentModels(); pay.Id = Guid.NewGuid(); pay.No = m.GetLastHexNo("payment").ToString("00000"); pay.Timestamp = DateTime.Now; pay.Source_BankAccounts_Id = paymentVM.Source_BankAccounts_Id; pay.Target_BankAccounts_Id = paymentVM.Target_BankAccounts_Id; pay.Amount = paymentVM.Amount; pay.ConfirmationNumber = paymentVM.ConfirmationNumber; pay.Notes = paymentVM.Notes; db.Payment.Add(pay); PaymentItemModels pi = new PaymentItemModels(); pi.Id = Guid.NewGuid(); pi.Payments_Id = pay.Id; pi.Transaction_RefId = paymentVM.Id; pi.Amount = paymentVM.Amount; pi.Notes = paymentVM.Notes; db.PaymentItem.Add(pi); db.SaveChanges(); if (!paymentVM.hasPayment) { using (var ctx = new HrContext()) { int result = ctx.Database.ExecuteSqlCommand("UPDATE Payrolls SET hasPayment='True' WHERE Id='" + paymentVM.Id + "'"); } } return(RedirectToAction("Payroll")); } ViewBag.listTarget = new SelectList(db.BankAccount.Where(x => x.Active == true && x.Owner_RefId.Value == paymentVM.IdUser).OrderBy(x => x.Name).ToList(), "Id", "Name"); ViewBag.listSource = new SelectList(db.BankAccount.Where(x => x.Active == true && x.Internal == true).OrderBy(x => x.Name).ToList(), "Id", "Name"); return(View(paymentVM)); }
public ActionResult GenerateReport(ITABUWiseReportModel objITABUWiseModel) { // ITABUWiseReportModel objITABUWise = new ITABUWiseReportModel(); try { #region Declarations string encoding; string mimeType; string extension; string fileNamePath1 = ""; string historyID = null; Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.Warning[] warnings = null; string[] streamIDs = null; string reportPath = ""; string reportName = "ITABusinessVerticalWise"; string strGetCurrentDate = DateTime.Now.ToString("MMMM") + " " + DateTime.Now.ToString("dd") + " " + DateTime.Now.Year.ToString(); string strPath = ConfigurationManager.AppSettings["ReportsPath"].ToString() + strGetCurrentDate; byte[] result = null; string format = "EXCEL"; ExecutionInfo execInfo = new ExecutionInfo(); ExecutionHeader execHeader = new ExecutionHeader(); ReportExecutionService rs = new ReportExecutionService(); #endregion if (!Directory.Exists(strPath)) { //Create Reports Folder with Current Date Directory.CreateDirectory(strPath); } //strPath = string.Format("{0}\\{1}_{2}", strPath, objITABUWiseModel.YearId, objITABUWiseModel.Quarter); rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.Url = ConfigurationManager.AppSettings["ReportExecutionService2012"].ToString(); reportPath = "/TrainingModuleReports/" + reportName; RMS.Common.Master objMaster = new Common.Master(); System.Data.DataTable dt = objMaster.FillDropDownList("105"); rs.ExecutionHeaderValue = execHeader; execInfo = rs.LoadReport(reportPath, historyID); ParameterValue[] parametersBusinessverticals = null; foreach (DataRow dr in dt.Rows) { fileNamePath1 = strPath + "\\" + reportName + "_" + Convert.ToString(dr["MasterName"]).Trim() + ".xlsx"; if (!System.IO.File.Exists(fileNamePath1)) { parametersBusinessverticals = new ParameterValue[3]; parametersBusinessverticals[0] = new ParameterValue(); parametersBusinessverticals[0].Name = "StartYear"; parametersBusinessverticals[0].Value = objITABUWiseModel.YearId; parametersBusinessverticals[1] = new ParameterValue(); parametersBusinessverticals[1].Name = "Quarter"; parametersBusinessverticals[1].Value = objITABUWiseModel.Quarter; parametersBusinessverticals[2] = new ParameterValue(); parametersBusinessverticals[2].Name = "BusinessVertical"; parametersBusinessverticals[2].Value = Convert.ToString(dr["MasterId"]); rs.SetExecutionParameters(parametersBusinessverticals, "en-us"); rs.Timeout = 3600000; //60 mins result = rs.Render(format, null, out extension, out encoding, out mimeType, out warnings, out streamIDs); execInfo = rs.GetExecutionInfo(); using (FileStream stream = System.IO.File.Create(fileNamePath1, result.Length)) { stream.Write(result, 0, result.Length); stream.Close(); } } } objITABUWiseModel.Message = string.Format("Reports Generated Sucessfully at Location {0}", strPath); return(View(objITABUWiseModel)); } catch (Exception ex) { throw new RaveHRException(ex.Message, ex, Sources.BusinessLayer, "ReportController", "GenerateReport", EventIDConstants.TRAINING_PRESENTATION_LAYER); } }
public JsonResult GeneratePayroll(string ids) { if (string.IsNullOrEmpty(ids)) { return(Json(new { status = "404" }, JsonRequestBehavior.AllowGet)); } else { string[] arrID = ids.Split(','); if (arrID.Length > 0) { bool isValid = false; string empID = null; for (int a = 0; a < arrID.Length; a++) { Guid attID = new Guid(arrID[a]); //Approved Checked bool isValidAtt = db.Attendance.Where(x => x.Id == attID).Select(x => x.Approved.HasValue).Single(); //return false jika Approved = NULL if (!isValidAtt) { isValid = false; break; } else { isValid = db.Attendance.Where(x => x.Id == attID).Select(x => x.Approved.Value).Single(); if (!isValid) { break; } } //Same Employee Checked string userID = db.Attendance.Where(x => x.Id == attID).Select(x => x.UserAccounts_Id).Single().ToString(); if (a == 0) { empID = userID; } else { isValid = (empID == userID) ? true : false; } } if (!isValid) { return(Json(new { status = "405" }, JsonRequestBehavior.AllowGet)); } else { Guid _attID = new Guid(arrID[0]); Guid employeeID = db.Attendance.Where(x => x.Id == _attID).Select(x => x.UserAccounts_Id).Single(); PayrollModels pRoll = new PayrollModels(); pRoll.Id = Guid.NewGuid(); pRoll.Timestamp = DateTime.Now; pRoll.Employee_UserAccounts_Id = employeeID; pRoll.Amount = 0; Common.Master m = new Common.Master(); pRoll.No = m.GetLastHexNo("payroll").ToString("00000"); pRoll.hasPayment = false; db.Payroll.Add(pRoll); db.SaveChanges(); for (int i = 0; i < arrID.Length; i++) { Guid attID = new Guid(arrID[i]); PayrollItemModels pi = new PayrollItemModels(); pi.Id = Guid.NewGuid(); pi.Payrolls_Id = pRoll.Id; pi.RefId = attID; pi.Description = string.Empty; int hours = db.Attendance.Where(x => x.Id == attID).Select(x => x.Workshifts_DurationMinutes.Value).Single() / 60; decimal payRate = db.Attendance.Where(x => x.Id == attID).Select(x => x.AttendancePayRates_Amount.Value).FirstOrDefault(); pi.Amount = hours * payRate; pi.Notes = string.Empty; db.PayrollItem.Add(pi); db.SaveChanges(); using (var ctx = new HrContext()) { int result = ctx.Database.ExecuteSqlCommand("UPDATE Attendances SET PayrollItems_Id='" + pi.Id + "' WHERE Id='" + attID + "'"); } } decimal total_amount = db.PayrollItem.Where(x => x.Payrolls_Id == pRoll.Id).Select(x => x.Amount).Sum(); int update_amount = db.Database.ExecuteSqlCommand("UPDATE Payrolls SET Amount=" + total_amount + " WHERE Id='" + pRoll.Id + "'"); return(Json(new { status = "200" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { status = "404" }, JsonRequestBehavior.AllowGet)); } } //end ids is not null/empty } //end generate payroll
public void SaveError(string message, string source, string className, string methodName, string eventID, string stack) { Common.Master obj = new Common.Master(); obj.SaveError(message, source, className, methodName, eventID, stack); }