public async Task <IActionResult> ChangePassword(ChangePasswordViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("ChangePassword", "Users")); } // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); var users = DB.User.FromSql("SELECT userid AS Username FROM tb_master_user AS u WITH(NOLOCK) WHERE userid = '" + UserData.Username + "' AND pwd = '" + model.OldPassword + "'"); if (await users.CountAsync() > 0) { string strSQL = $"UPDATE tb_master_user SET pwd = '{model.Password}' WHERE userid = '{UserData.Username}' AND pwd = '{model.OldPassword}'"; var password = DB.Database.ExecuteSqlCommand(strSQL); _logger.LogWarning("Change password success."); ModelState.AddModelError("succeed", "Change password success."); } else { _logger.LogWarning("Invalid old password."); ModelState.AddModelError("failed", "Invalid old password."); } return(RedirectToAction("ChangePassword", "Users")); }
public async Task <ActionResult> Get(DailyRevenueConfirmFCViewModel Filter) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Parameter string filetype = HttpContext.Request.Query["FileType"].ToString().ToLower(); Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS); DateTime dateTo = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS); StringBuilder sqlStringBuilder = new StringBuilder(); sqlStringBuilder.Append("EXEC sp_PDC_Report_DailyRevenueConfirmFC_Get '"); sqlStringBuilder.Append(Filter.ConfirmBy); sqlStringBuilder.Append("','"); sqlStringBuilder.Append(UserData.Username); sqlStringBuilder.Append("','"); sqlStringBuilder.Append(Filter.BranchList); sqlStringBuilder.Append("','"); sqlStringBuilder.Append(dateFrom.ToString("yyyyMMdd", enUS)); sqlStringBuilder.Append("','"); sqlStringBuilder.Append(dateTo.ToString("yyyyMMdd", enUS)); sqlStringBuilder.Append("'"); string strSQL = sqlStringBuilder.ToString(); List <DailyRevenueConfirmFC> DailyRevenues = await DB.DailyRevenueConfirmFC.FromSql(strSQL).ToListAsync(); if (filetype.Equals("excel")) { return(ExportExcelDailyRevenueConfirmFC(DailyRevenues)); } int totalCount = DailyRevenues.Count(); DailyRevenues = DailyRevenues.Skip(pagination.From()).Take(pagination.To()).ToList(); Response.Success = true; Response.Result = DailyRevenues; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = DailyRevenues.Count(), totalCount }; DB.Dispose(); return(Json(Response.Render())); }
public async Task <JsonResult> Verify(MonthlyExpenseVerifyViewModel MonthlyExpenseVerify) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime monthYear = DateTime.ParseExact(MonthlyExpenseVerify.MonthYear, "MM/yyyy", enUS); StringBuilder SQLStringBuilder = new StringBuilder(); string[] branchLists = MonthlyExpenseVerify.BranchID.Split(','); foreach (var branch in branchLists) { if (MonthlyExpenseVerify.Type.Equals("acc")) { SQLStringBuilder.AppendLine($"EXEC sp_RPT310_SaveMonthlyExpenseAccountVerify '{UserData.Username}', '{branch}', {monthYear.Month.ToString()}, {monthYear.Year.ToString()}"); } else if (MonthlyExpenseVerify.Type.Equals("ops")) { SQLStringBuilder.AppendLine($"EXEC sp_RPT310_SaveMonthlyExpenseOpsAdminVerify '{UserData.Username}', '{branch}', {monthYear.Month.ToString()}, {monthYear.Year.ToString()}"); } else if (MonthlyExpenseVerify.Type.Equals("rt")) { SQLStringBuilder.AppendLine($"EXEC sp_RPT310_SaveMonthlyExpenseRetailVerify '{UserData.Username}', '{branch}', {monthYear.Month.ToString()}, {monthYear.Year.ToString()}"); } else if (MonthlyExpenseVerify.Type.Equals("rtsupply")) { SQLStringBuilder.AppendLine($"EXEC sp_RPT310_SaveMonthlyExpenseRetailSupplyVerify '{UserData.Username}', '{branch}', {monthYear.Month.ToString()}, {monthYear.Year.ToString()}"); } } string strSQL = SQLStringBuilder.ToString(); #region Product if (_hostingEnvironment.IsProduction()) { SaveDBResponse save = await DB.SaveDBResponse.FromSql(strSQL).FirstAsync(); Response.Success = save.code.Equals("000"); Response.Messages.Add(save.desc); } #endregion #region Tester else { Response.Success = true; Response.Messages.Add("Test"); } #endregion DB.Dispose(); return(Json(Response.Render())); }
public async Task <ActionResult> Get(ShopDailyViewModel Filter) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Parameter string type = HttpContext.Request.Query["Type"].ToString().ToLower(); string filetype = HttpContext.Request.Query["FileType"].ToString().ToLower(); Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime date = DateTime.ParseExact(Filter.Date, "dd/MM/yyyy", new CultureInfo("en-US")); List <DashboardShopDaily> DashboardShopDaily = await DB.DashboardShopDaily .FromSql($"EXEC sp_RPT316_ShopDaily '{UserData.Username}', '{Filter.BranchList}', '{date.ToString("yyyyMMdd", new CultureInfo("en-US"))}'") .ToListAsync(); Response.Success = true; Response.Result = DashboardShopDaily; DB.Dispose(); return(Json(Response.Render())); }
public async Task <ActionResult> Export(CloseShopViewModel Filter) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US")); DateTime dateTo = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US")); string exec = $"sp_PDC_Dashboard_CloseShopCoverPage_Get '{dateFrom.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '{dateTo.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '{UserData.Username}', '{Filter.BranchList}'"; _logger.LogInformation(exec); List <EOD> edo = await DB.EOD.FromSql(exec).ToListAsync(); if (edo.Count() <= 0) { Response.Success = false; Response.Errors.Add(new { Key = "BranchId", Message = "No data found for " + Filter.BranchList }); HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; return(Json(Response.Render())); } return(Filter.FileType.Equals("excel") ? this.ExportExcel(edo, dateFrom) : this.ExportPDF(edo)); }
public async Task <ActionResult> Get(BranchMonthlyViewModel Filter) { Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); string FileType = Request.Query["FileType"]; string Type = Request.Query["Type"]; if (Type == null) { Type = ""; } DateTime monthYear = DateTime.ParseExact(Filter.MonthYear, "MM/yyyy", enUS); StringBuilder SQLStringBuilder = new StringBuilder(); SQLStringBuilder.Append("EXEC sp_RPT313_DHLVerifyReport '"); SQLStringBuilder.Append(UserData.Username); SQLStringBuilder.Append("', '"); SQLStringBuilder.Append(Filter.BranchList); SQLStringBuilder.Append("', '"); SQLStringBuilder.Append(monthYear.Month.ToString()); SQLStringBuilder.Append("', '"); SQLStringBuilder.Append(monthYear.Year.ToString()); SQLStringBuilder.Append("'"); string sql = SQLStringBuilder.ToString(); List <DHLVerify> DHLVerify = await DB.DHLVerify.FromSql(sql).ToListAsync(); if (FileType != null) { if (FileType.Equals("excel")) { //return ExportExcelLINEPayRemittance(Type, LINEPayRemittance); } } int totalCount = DHLVerify.Count; DHLVerify = DHLVerify.Skip(pagination.From()).Take(pagination.To()).ToList(); Response.Success = true; Response.Result = DHLVerify; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = DHLVerify.Count, totalCount = totalCount }; DB.Dispose(); return(Json(Response.Render())); }
public async Task <object> Detail(string id, DateTime ReportDate) { try { var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); var date = ReportDate.ToString("yyyyMMdd", enUS); //DateTime dateStr = DateTime.ParseExact(ReportDate, "dd/MM/yyyy", enUS); string exec = $"EXEC sp_PDC_Report_DailyRevenueVerifyMatchCash_Get '{UserData.Username}', '{id}', '{ReportDate.ToString("yyyyMMdd", enUS)}'"; //string exec1 = $"EXEC sp_PDC_Report_DailyRevenueVerifyMatchCash_Get '{id}', '{ReportDate.ToString("yyyyMMdd", enUS)}'"; _logger.LogInformation(exec); DailyRevenueDetailCash Detail = await DB.DailyRevenueDetailCash.FromSql(exec).FirstOrDefaultAsync(); if (Detail == null) { return(ResponseNotFound(id)); } Response.Success = true; Response.Result = Detail; DB.Dispose(); return(Response.Render()); } catch (Exception ex) { string mss = ex.Message.ToString(); return(null); } // Auth Data }
public async Task <JsonResult> Detail(string id, string MonthYear) { // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime monthYear = DateTime.ParseExact(MonthYear, "MM/yyyy", enUS); string exec = $"EXEC sp_PDC_Report_MonthlyCommissionSummary_Get '{UserData.Username}', '{id}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}', 0, ''"; _logger.LogInformation(exec); List <MonthlySummaryCommission> MonthlyCommissionFC = await DB.MonthlySummaryCommission.FromSql(exec).ToListAsync(); if (MonthlyCommissionFC.Count() > 0) { exec = $"EXEC sp_RPT310_GetMonthlyExpenseDetail '{UserData.Username}', '{ id }', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}'"; _logger.LogInformation(exec); MonthlyCommissionFC.FirstOrDefault().MonthlyExpenseDetail = await DB.MonthlyExpenseDetail .FromSql(exec) .ToListAsync(); } //if (Details.Count() == 0) //{ // return ResponseNotFound(id); //} Response.Success = true; Response.Result = MonthlyCommissionFC; DB.Dispose(); return(Json(Response.Render())); }
public async Task <JsonResult> Post(DHLVerifyRTUpdateViewModel Item) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime monthYear = DateTime.ParseExact(Item.MonthYear, "MM/yyyy", enUS); decimal dhlAdjustment = 0; if (decimal.TryParse(Item.DHLAdjustment, out dhlAdjustment)) { } StringBuilder sqlStrBuilder = new StringBuilder(); sqlStrBuilder.Append("EXEC sp_RPT313_DHLVerifyUpdate '"); sqlStrBuilder.Append(UserData.Username); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(Item.BranchID); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(monthYear.Month.ToString()); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(monthYear.Year.ToString()); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(dhlAdjustment); sqlStrBuilder.Append("'"); string strSQL = sqlStrBuilder.ToString(); #region Product if (_hostingEnvironment.IsProduction()) { SaveDBResponse save = await DB.SaveDBResponse.FromSql(strSQL).FirstAsync(); Response.Success = save.code.Equals("000"); Response.Messages.Add(save.desc); } #endregion #region Tester else { Response.Success = true; Response.Messages.Add("Test"); } #endregion DB.Dispose(); return(Json(Response.Render())); }
public async Task <ActionResult> Get(BranchMonthlyViewModel Filter, String FileType) { Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); // Ref Page string type = Request.Query["Type"]; string VerifyID = ""; switch (type) { case "acc": VerifyID = "EXPENSE_VERIFY_FOR_ACC"; break; } DateTime monthYear = DateTime.ParseExact(Filter.MonthYear, "MM/yyyy", enUS); string exec = $"sp_RPT300_FN_MonthlyExpenseSync '{UserData.Username}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}'"; _logger.LogInformation(exec); await DB.Database.ExecuteSqlCommandAsync(exec); exec = $"EXEC sp_RPT310_GetMonthlyExpense '{UserData.Username}', '{Filter.BranchList}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}', '{VerifyID}'"; _logger.LogInformation(exec); List <MonthlyExpense> MonthlyExpense = await DB.MonthlyExpense.FromSql(exec).ToListAsync(); if (FileType != null) { if (FileType.Equals("excel")) { return(ExportExcelMonthlyExpense(MonthlyExpense)); } } int totalCount = MonthlyExpense.Count(); MonthlyExpense = MonthlyExpense.Skip(pagination.From()).Take(pagination.To()).ToList(); Response.Success = true; Response.Result = MonthlyExpense; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = MonthlyExpense.Count(), totalCount = totalCount }; DB.Dispose(); return(Json(Response.Render())); }
private async Task <IActionResult> Report(int id, ViewResult viewResult, string with) { // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); switch (with) { case "BranchList": ViewData["BranchList"] = await DB.BranchList.FromSql("EXEC sp_RPT309_GetUserShopListByProfileId '" + UserData.Username + "', '" + null + "', 0").ToListAsync(); break; case "BranchListWithERP": ViewData["BranchList"] = await DB.BranchList.FromSql("EXEC sp_RPT309_GetUserShopListByProfileId '" + UserData.Username + "', '" + null + "', 1").ToListAsync(); break; case "UserProfile": ViewData["UserProfile"] = await DB.UserProfile.ToListAsync(); break; case "MonthlyExpenseUpdateRT": ViewData["UserProfile"] = await DB.UserProfile.ToListAsync(); break; case "DC-SHOP": ViewData["BranchList"] = await DB.BranchList.FromSql("EXEC sp_RPT301_GetBranchList '" + UserData.Username + "', 'DC-SHOP'").ToListAsync(); break; } List <Package> PackageAll = await DB.Package.OrderBy(p => p.UnitPrice).ToListAsync(); ViewData["PackageAll"] = PackageAll; var searchPackage = new List <string> { "PKG03", "PKG04", "PKG05", /*"PKG06",*/ "PKG07", "PKG08", "PKG18" }; ViewData["PackageList"] = PackageAll .Where(p => searchPackage.Contains(p.PackageID)) .ToList(); ViewData["SupplyList"] = PackageAll .Where(p => (new[] { 4, 5 }).Contains(p.PackageType.Value)) .OrderBy(p => p.UnitPrice) .ToList(); DB.Dispose(); return(viewResult); }
public async Task <JsonResult> Post() { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); string idList = HttpContext.Request.Form["IDs"].ToString().ToUpper(); string[] idLists = idList.Split(','); StringBuilder sqlStrBuilder = new StringBuilder(); foreach (var x in idLists) { string[] xSplit = x.Split('-'); sqlStrBuilder.Append("EXEC sp_PDC_Report_DailyRevenueConfirm_Set '"); sqlStrBuilder.Append(xSplit[1]); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(UserData.Username); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(xSplit[0]); sqlStrBuilder.AppendLine("'"); } string strSQL = sqlStrBuilder.ToString(); #region Product if (_hostingEnvironment.IsProduction()) { SaveDBResponse save = await DB.SaveDBResponse.FromSql(strSQL).FirstAsync(); Response.Success = save.code.Equals("000"); Response.Messages.Add(save.desc); } #endregion #region Tester else { Response.Success = true; Response.Messages.Add("Test"); } #endregion DB.Dispose(); return(Json(Response.Render())); }
public async Task <ActionResult> Get(TypeBranchDateFromDateToViewModel Filter, string FileType) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Parameter string filetype = (FileType ?? "").ToLower(); Pagination pagination = new Pagination(HttpContext); // Auth Data string userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS); DateTime dateTo = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS); string parameter = "'" + dateFrom.ToString("yyyyMMdd", enUS) + "', '" + dateTo.ToString("yyyyMMdd", enUS) + "', '" + UserData.Username + "', '" + Filter.BranchList + "'"; string sql = "EXEC sp_PDC_Report_DailyRevenueVerify_Get " + parameter; _logger.LogInformation(sql); IQueryable <DailyRevenueVerify> queryableDailyRevenueVerify = DB.DailyRevenueVerify.FromSql(sql); if (filetype.Equals("excel")) { //string exec = $"sp_PDC_Dashboard_EODCoverPage_Get '{dateFrom.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '" + dateTo.ToString("yyyyMMdd", enUS) + "', '{UserData.Username}', '{filter.BranchList}'"; string exec = $"sp_PDC_Dashboard_CloseShopCoverPage_Get '{dateFrom.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '{dateTo.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '{UserData.Username}', '{Filter.BranchList}'"; IQueryable <EOD> queryableEOD = DB.EOD.FromSql(exec); return(ExportExcelDailyRevenueVerify(dateFrom, dateTo, Filter.BranchList, await queryableDailyRevenueVerify.ToListAsync(), await queryableEOD.ToListAsync())); } int totalCount = queryableDailyRevenueVerify.Count(); List <DailyRevenueVerify> DailyRevenueVerify = queryableDailyRevenueVerify.Skip(pagination.From()).Take(pagination.To()).ToList(); Response.Success = true; Response.Result = DailyRevenueVerify; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = DailyRevenueVerify.Count(), totalCount }; DB.Dispose(); return(Json(Response.Render())); }
public async Task <ActionResult> Download() { Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); string ReportDate = Request.Query["ReportDate"]; string FileType = Request.Query["FileType"]; string Type = Request.Query["Type"]; if (Type == null) { Type = ""; } DateTime reportDate = DateTime.ParseExact(ReportDate, "dd/MM/yyyy", enUS); string sql = $"EXEC sp_RPT308_DowloadDCTopUpReport '{UserData.Username}', '{reportDate.ToString("yyyyMMdd", enUS)}'"; _logger.LogInformation(sql); List <LINEPayRemittance> LINEPayRemittance = await DB.LINEPayRemittance.FromSql(sql).ToListAsync(); if (FileType != null) { if (FileType.Equals("excel")) { return(ExportExcelDownload(LINEPayRemittance)); } } int totalCount = LINEPayRemittance.Count; LINEPayRemittance = LINEPayRemittance.Skip(pagination.From()).Take(pagination.To()).ToList(); Response.Success = true; Response.Result = LINEPayRemittance; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = LINEPayRemittance.Count, totalCount = totalCount }; DB.Dispose(); return(Json(Response.Render())); }
//[Route ("GetMonthlyCommission")] public async Task <ActionResult> GetMonthlyCommission(BranchMonthlyViewModel Filter, String FileType, String Type) { Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); if (Type == null) { Type = ""; } DateTime monthYear = DateTime.ParseExact(Filter.MonthYear, "MM/yyyy", enUS); string exec = $"sp_RPT300_FN_MonthlyExpenseSync '{UserData.Username}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}'"; _logger.LogInformation(exec); await DB.Database.ExecuteSqlCommandAsync(exec); exec = $"EXEC sp_PDC_Report_MonthlyCommissionSummary_Get '{UserData.Username}', '{Filter.BranchList}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}', { (Type.Equals("rt") ? "0" : "1") }, ''"; _logger.LogInformation(exec); List <MonthlySummaryCommission> MonthlySummaryCommission = await DB.MonthlySummaryCommission.FromSql(exec).ToListAsync(); if (FileType != null) { if (FileType.Equals("excel")) { return(ExportExcelMonthlyCommission(Type, MonthlySummaryCommission, monthYear)); } } int totalCount = MonthlySummaryCommission.Count(); MonthlySummaryCommission = MonthlySummaryCommission.Skip(pagination.From()).Take(pagination.To()).ToList(); Response.Success = true; Response.Result = MonthlySummaryCommission; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = MonthlySummaryCommission.Count(), totalCount = totalCount }; DB.Dispose(); return(Json(Response.Render())); }
public async Task <Object> Post(BranchDateFromDateToViewModel Filter) { Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); string FileType = Request.Form["filetype"]; string Type = Request.Form["Type"]; if (Type == null) { Type = ""; } DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS); DateTime dateTo = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS); string sql = $"EXEC sp_PDC_Report_DCTopUpVerify_Get '{dateFrom.ToString("yyyyMMdd", enUS)}', '{dateTo.ToString("yyyyMMdd", enUS)}', '{UserData.Username}', '{Filter.BranchList}'"; _logger.LogInformation(sql); List <LINEPayRemittance> LINEPayRemittance = await DB.LINEPayRemittance.FromSql(sql).ToListAsync(); if (FileType != null) { if (FileType.Equals("excel")) { return(ExportExcel(dateFrom, dateTo, LINEPayRemittance)); } } int totalCount = LINEPayRemittance.Count; LINEPayRemittance = LINEPayRemittance.Skip(pagination.From()).Take(pagination.To()).ToList(); Response.Success = true; Response.Result = LINEPayRemittance; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = LINEPayRemittance.Count, totalCount = totalCount }; DB.Dispose(); return(Response.Render()); }
public async Task <ActionResult> Get(TypeBranchDateFromDateToViewModel Filter, string FileType) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Parameter string filetype = (FileType ?? "").ToLower(); Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS); DateTime dateTo = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS); string parameter = "'" + dateFrom.ToString("yyyyMMdd", enUS) + "', '" + dateTo.ToString("yyyyMMdd", enUS) + "', '" + UserData.Username + "', '" + Filter.BranchList + "'"; string sql = "EXEC sp_PDC_Report_StockOrder_Get " + parameter; _logger.LogInformation(sql); List <StockOrder> StockOrder = await DB.StockOrder.FromSql(sql).ToListAsync(); if (filetype.Equals("excel")) { return(ExportExcel(dateFrom, dateTo, StockOrder)); } int totalCount = StockOrder.Count(); StockOrder = StockOrder.Skip(pagination.From()).Take(pagination.To()).ToList(); Response.Success = true; Response.Result = StockOrder; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = StockOrder.Count(), totalCount = totalCount }; DB.Dispose(); return(Json(Response.Render())); }
public object Discount() { try { // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); SqlParameter jsonInput = new SqlParameter() { ParameterName = "@jsonreq", SqlDbType = SqlDbType.NVarChar, SqlValue = "", Size = int.MaxValue }; SqlParameter jsonOutput = new SqlParameter() { ParameterName = "@jsonOutput", SqlDbType = SqlDbType.NVarChar, Direction = ParameterDirection.Output, Size = int.MaxValue }; var data = DB.Database.ExecuteSqlCommand(" sp_PDC_Get_Master_Discount @jsonreq, @jsonOutput OUTPUT ", jsonInput, jsonOutput); ResultDiscount _Discount = JsonConvert.DeserializeObject <ResultDiscount> (jsonOutput.Value.ToString()); Response.Success = true; //var data = await DB.BranchList.FromSql("EXEC sp_PDC_Branch_Get '" + UserData.Username + "', '" + type + "'" + "', '" + "'").ToListAsync(); //Response.Result = Discount; //DB.Dispose(); //return Response.Render(); var model = _Discount.Result.Select(c => new KeyValuePair <string, Object>(c.Discount_Code, c.Discount_Description)).ToList(); return(Json(new { success = true, data = model })); } catch (Exception ex) { string mss = ex.Message.ToString(); return(Response.Render()); } }
public async Task <JsonResult> Post(UpdatePRViewModel UpdatePR) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime monthYear = DateTime.ParseExact(UpdatePR.MonthYear, "MM/yyyy", enUS); StringBuilder SQLStringBuilder = new StringBuilder(); for (int i = 0; i < UpdatePR.BranchID.Count(); i++) { SQLStringBuilder.AppendLine($"EXEC sp_RPT312_UpdatePR '{UserData.Username}', '{UpdatePR.BranchID[i]}', '{UpdatePR.PR[i]}', '{monthYear.Month.ToString()}', '{monthYear.Year.ToString()}'"); } string strSQL = SQLStringBuilder.ToString(); #region Product if (_hostingEnvironment.IsProduction()) { SaveDBResponse save = await DB.SaveDBResponse.FromSql(strSQL).FirstAsync(); Response.Success = save.code.Equals("000"); Response.Messages.Add(save.desc); } #endregion #region Tester else { Response.Success = true; Response.Messages.Add("Test"); } #endregion DB.Dispose(); return(Json(Response.Render())); }
public async Task <ActionResult> MDEExportAsync(ShopDailyViewModel Filter) { // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime date = DateTime.ParseExact(Filter.Date, "dd/MM/yyyy", new CultureInfo("en-US")); // Load the Excel Template Stream xlsxStream = System.IO.File.OpenRead(_hostingEnvironment.WebRootPath + @"\assets\templates\ShopDailyMDE.xlsx"); ExcelEngine excelEngine = new ExcelEngine(); // Loads or open an existing workbook through Open method of IWorkbooks IWorkbook workbook = excelEngine.Excel.Workbooks.Open(xlsxStream); workbook.Version = ExcelVersion.Excel2013; List <MDEConsignments> mdeConsignments = await DB.MDEConsignments.FromSql($"sp_RPT316_ShopDailyMDE '{UserData.Username}', '{Filter.BranchList}', '{date.ToString("yyyyMMdd", new CultureInfo("en-US"))}', 1").ToListAsync(); List <MDEPackages> mdePackages = await DB.MDEPackages.FromSql($"sp_RPT316_ShopDailyMDE '{UserData.Username}', '{Filter.BranchList}', '{date.ToString("yyyyMMdd", new CultureInfo("en-US"))}', 2").ToListAsync(); workbook.Worksheets[0].Range["B2"].Text = $"Manifest Data Entry (MDE) Consignments {date.ToString("dd/MM/yyyy")}"; workbook.Worksheets[0].ImportData(mdeConsignments, 4, 1, false); workbook.Worksheets[1].Range["B2"].Text = $"Manifest Data Entry (MDE) Packages {date.ToString("dd/MM/yyyy")}"; workbook.Worksheets[1].ImportData(mdePackages, 4, 1, false); MemoryStream ms = new MemoryStream(); workbook.SaveAs(ms); ms.Position = 0; // Close the instance of IWorkbook. workbook.Close(); // Dispose the instance of ExcelEngine. excelEngine.Dispose(); xlsxStream.Dispose(); //return File(ms, "Application/msexcel", "KE_PDC_MonthlyCommission" + type.ToUpper() + "_Report_" + DateTime.Now.ToString("yyyMMdd_HHmmss") + ".xlsx"); return(File(ms, "Application/msexcel", $"KE_PDC_ShopDaily_MDE_Report_{date.ToString("dd_MMM_yyyy")}_{DateTime.Now.ToString("yyyMMdd_HHmmss")}.xlsx")); }
// GET: /<controller>/Type public async Task <object> Type() { // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); string sql = $"EXEC sp_PDC_BranchType_Get_Auth'{ UserData.Username }'"; Response.Success = true; Response.Result = await DB.BranchType.FromSql(sql) .GroupBy(t => t.TypeGroup, (key, list) => new { TypeGroupId = key, Types = list }) .ToListAsync(); DB.Dispose(); return(Response.Render()); }
// GET: /<controller>/ public async Task <IActionResult> Index() { // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); // Parameter string profile_id = HttpContext.Request.Query["FC"].ToString().ToUpper(); if (profile_id.Equals("ALL")) { profile_id = ""; } Response.Success = true; Response.Result = await DB.BranchList.FromSql("EXEC sp_RPT309_GetUserShopListByProfileId '" + UserData.Username + "', '" + profile_id + "'").ToListAsync(); DB.Dispose(); return(Json(Response.Render())); }
public async Task <ActionResult> Detail(TypeBranchDateFromDateToViewModel Filter, string id) { // Parameter string filetype = HttpContext.Request.Query["FileType"].ToString().ToLower(); Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", enUS); DateTime dateTo = DateTime.ParseExact(Filter.DateTo, "dd/MM/yyyy", enUS); List <DailyCODDetail> DailyCODDetail = await DB.DailyCODDetail.FromSql($"EXEC sp_RPT314_DailyCODDetail '{UserData.Username}', '{id}', '{dateFrom.ToString("yyyyMMdd", enUS)}', '{dateTo.ToString("yyyyMMdd", enUS)}'--, {pagination.From()}, {pagination.To()}").ToListAsync(); if (filetype.Equals("excel")) { return(ExportExcelDailyCODDetail(id, dateFrom, dateTo, DailyCODDetail)); } int totalCount = DailyCODDetail.Count(); DailyCODDetail = DailyCODDetail.Skip(pagination.From()).Take(pagination.To()).ToList(); Response.Success = true; Response.Result = DailyCODDetail; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = DailyCODDetail.Count(), totalCount = totalCount }; DB.Dispose(); return(Json(Response.Render())); }
public async Task <object> Get(string BranchID, string ReportDate) { // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime reportDate = DateTime.ParseExact(ReportDate, "yyyyMMdd", enUS); string sql = $"EXEC sp_PDC_Report_DCTopUpVerify_Get '{reportDate.ToString("yyyyMMdd", enUS)}', '{reportDate.ToString("yyyyMMdd", enUS)}', '{UserData.Username}', '{BranchID}'"; _logger.LogInformation(sql); List <LINEPayRemittance> LINEPayRemittance = await DB.LINEPayRemittance.FromSql(sql).ToListAsync(); if (LINEPayRemittance.Count() == 0) { return(NotFound()); } Response.Success = true; Response.Result = LINEPayRemittance; return(Response.Render()); }
// POST: /<controller>/Get public async Task <object> Get(string type, string region) { try { // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); if (type.Equals("all")) { type = string.Empty; } Response.Success = true; if (region == null) { var data = await DB.BranchList_r.FromSql("EXEC sp_PDC_Branch_Get_Auth @p0,@p1, @p2", parameters : new[] { UserData.Username, type, "" }).ToListAsync(); //var data = await DB.BranchList.FromSql("EXEC sp_PDC_Branch_Get '" + UserData.Username + "', '" + type + "'" + "', '" + "'").ToListAsync(); Response.Result = data; } else { var data = await DB.BranchList_r.FromSql("EXEC sp_PDC_Branch_Get_Auth @p0,@p1, @p2", parameters : new[] { UserData.Username, type, region }).ToListAsync(); //var data = await DB.BranchList.FromSql("EXEC sp_PDC_Branch_Get '" + UserData.Username + "', '" + type + "'" + "', '" + region + "'").ToListAsync(); Response.Result = data; } DB.Dispose(); return(Response.Render()); } catch (Exception ex) { string mss = ex.Message.ToString(); return(Response.Render()); } }
private void AddRole(UserMapRole user, List <Menu> menus, List <Claim> claims) { user.UserMenu.ForEach(m => { Menu tempMenu = menus.Find(n => n.Id.Equals(m.MenuId) && string.IsNullOrEmpty(n.Url) && !string.IsNullOrEmpty(n.Controller) && !string.IsNullOrEmpty(n.Action)); if (tempMenu != null) { string roleName = $"{tempMenu.Controller}{tempMenu.Action}"; if (!claims.Exists(c => c.Value.Equals(roleName))) { claims.Add(new Claim(ClaimTypes.Role, roleName, ClaimValueTypes.String)); if (tempMenu.Children.Count() > 0 && tempMenu.Children.FirstOrDefault().Count() > 0) { AddRole(user, tempMenu.Children.FirstOrDefault(), claims); } } } }); //return claims; }
public async Task <object> Put(ServicePointDaliyUpdateViewModel Profile) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); StringBuilder sqlStringBuilder = new StringBuilder(); sqlStringBuilder.Append("EXEC sp_SynRTSP08_SetCommisionFee N'"); sqlStringBuilder.Append("<dbxml>"); sqlStringBuilder.Append("<daily_report>"); sqlStringBuilder.Append($"<profile_id>{ Profile.ProfileId }</profile_id>"); sqlStringBuilder.Append($"<report_date>{ Profile.ReportDate }</report_date>"); sqlStringBuilder.Append($"<Con>{ Profile.Consignment }</Con>"); sqlStringBuilder.Append($"<Cash>{ Profile.Cash }</Cash>"); sqlStringBuilder.Append($"<user>{ UserData.Username }</user>"); sqlStringBuilder.Append("</daily_report>"); sqlStringBuilder.Append("</dbxml>'"); string strSQL = sqlStringBuilder.ToString(); _logger.LogInformation(strSQL); var sqlResponse = await DBRTSP.Database.ExecuteSqlCommandAsync(strSQL); Response.Success = true; Response.Result = Profile; Response.Messages.Add("Updated Successful"); DB.Dispose(); return(Response.Render()); }
public async Task <JsonResult> NoneShipmentDetail(string id, string MonthYear) { // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime monthYear = DateTime.ParseExact(MonthYear, "MM/yyyy", enUS); StringBuilder SQLStringBuilder = new StringBuilder(); SQLStringBuilder.Append("sp_RPT313_DHLVerifyNoneShipmentDetailReport '"); SQLStringBuilder.Append(UserData.Username); SQLStringBuilder.Append("','"); SQLStringBuilder.Append(id); SQLStringBuilder.Append("','"); SQLStringBuilder.Append(monthYear.Month.ToString()); SQLStringBuilder.Append("','"); SQLStringBuilder.Append(monthYear.Year.ToString()); SQLStringBuilder.Append("'"); string sql = SQLStringBuilder.ToString(); List <NoneShipmentDHL> NoneShipmentDHL = await DB.NoneShipmentDHL.FromSql(sql).ToListAsync(); //if (Details.Count() == 0) //{ // return ResponseNotFound(id); //} Response.Success = true; Response.Result = NoneShipmentDHL; DB.Dispose(); return(Json(Response.Render())); }
public async Task <ActionResult> Get(ReportViewModel Filter, string fileType) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } try { // Parameter fileType = (fileType ?? "").ToLower(); Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime dateRemittance = DateTime.ParseExact(Filter.DateRemittance, "dd/MM/yyyy", enUS); Remittance rmt = new Remittance { RemittanceDate = dateRemittance.ToString("yyyyMMdd", enUS) }; string _dateRemittance = JsonConvert.SerializeObject(rmt); SqlParameter jsonInput = new SqlParameter() { ParameterName = "@jsonreq", SqlDbType = SqlDbType.NVarChar, SqlValue = _dateRemittance, Size = int.MaxValue }; SqlParameter jsonOutput = new SqlParameter() { ParameterName = "@jsonOutput", SqlDbType = SqlDbType.NVarChar, Direction = ParameterDirection.Output, Size = int.MaxValue }; List <RabbitTopUpRabbit> mPay = new List <RabbitTopUpRabbit>(); DB.Database.ExecuteSqlCommand(" sp_PDC_TopUpRemittanceDate @jsonreq, @jsonOutput OUTPUT ", jsonInput, jsonOutput); var data = jsonOutput.Value.ToString(); if (data == "" || data == null) { Response.Success = false; Response.Result = mPay; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = 0, totalCount = 0 }; return(Json(Response.Render())); } ResultRemittancedetailRabbit MPayRemittance = JsonConvert.DeserializeObject <ResultRemittancedetailRabbit>(jsonOutput.Value.ToString()); foreach (var item in MPayRemittance.Result) { RabbitTopUpRabbit dc = new RabbitTopUpRabbit { BranchID = item.BranchID, ReportDate = item.ReportDate, DMSID = item.DMSID, branch_type = item.branch_type, ERP_ID = item.ERP_ID, BranchName = item.BranchName, TUC = item.TUC, TUP = item.TUP, TUD = item.TUD, Captured = item.Captured, CapturedBy = item.CapturedBy, CapturedDate = item.CapturedDate, RemittanceDate = item.RemittanceDate, unit_price = item.unit_price, Rabbit_transaction_Id = item.MPay_transaction_Id, created_datetime = item.created_datetime, }; mPay.Add(dc); } int count = 0; int totalCount = 0; object result = new List <object>(); if (fileType.Equals("excel")) { return(ExportExcelLINEPayRemittance(mPay)); } totalCount = mPay.Count(); mPay = mPay.Skip(pagination.From()).Take(pagination.To()).ToList(); result = mPay; count = mPay.Count(); Response.Success = true; Response.Result = result; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count = count, totalCount = totalCount }; return(Json(Response.Render())); } catch (Exception ex) { string mss = ex.Message.ToString(); return(null); } }
public async Task <JsonResult> PostVerifySelection(DCTopUpVerifySelectionViewModel Item) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime verifyDate = DateTime.ParseExact(Item.VerifyDate, "dd/MM/yyyy", enUS); DateTime remittanceDate = DateTime.ParseExact(Item.RemittanceDate, "dd/MM/yyyy", enUS); string idList = Item.IDList.ToUpper(); string[] idLists = idList.Split(','); StringBuilder sqlStrBuilder = new StringBuilder(); foreach (var x in idLists) { string[] xSplit = x.Split('-'); sqlStrBuilder.Append("EXEC sp_PDC_Report_DCTopUpVerify_Set '"); sqlStrBuilder.Append(UserData.Username); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(xSplit[1]); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(xSplit[0]); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(verifyDate.ToString("yyyyMMdd", enUS)); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append(remittanceDate.ToString("yyyyMMdd", enUS)); sqlStrBuilder.Append("', '"); sqlStrBuilder.Append("0"); //@BonusCommission sqlStrBuilder.Append("', '"); sqlStrBuilder.Append("0"); //@AdjCreditCard sqlStrBuilder.Append("', '"); sqlStrBuilder.Append("0"); //@AdjustmentOther sqlStrBuilder.Append("', '"); sqlStrBuilder.Append("0"); //@ReturnCharge sqlStrBuilder.Append("', '"); sqlStrBuilder.Append("0"); //@Suspense sqlStrBuilder.Append("', '"); sqlStrBuilder.Append("0"); //@WithHoldingTax sqlStrBuilder.Append("', '"); sqlStrBuilder.Append("0"); //@Promotion sqlStrBuilder.Append("', '"); sqlStrBuilder.Append("0"); //@BankCharge sqlStrBuilder.Append("', '"); sqlStrBuilder.Append("0"); //@AdjLinePay sqlStrBuilder.Append("', N'"); sqlStrBuilder.Append(""); //@BonusCommissionRemark sqlStrBuilder.Append("', N'"); sqlStrBuilder.Append(""); //@AdjCreditCardRemark sqlStrBuilder.Append("', N'"); sqlStrBuilder.Append(""); //@AdjustmentOtherRemark sqlStrBuilder.Append("', N'"); sqlStrBuilder.Append(""); //@ReturnChargeRemark sqlStrBuilder.Append("', N'"); sqlStrBuilder.Append(""); //@SuspenseRemark sqlStrBuilder.Append("', N'"); sqlStrBuilder.Append(""); //@WithHoldingTaxRemark sqlStrBuilder.Append("', N'"); sqlStrBuilder.Append(""); //@PromotionRemark sqlStrBuilder.Append("', N'"); sqlStrBuilder.Append(""); //@BankChargeRemark sqlStrBuilder.Append("', N'"); sqlStrBuilder.Append(""); //@AdjLinePayRemark sqlStrBuilder.Append("'"); sqlStrBuilder.AppendLine(); } string strSQL = sqlStrBuilder.ToString(); #region Product if (_hostingEnvironment.IsProduction()) { SaveDBResponse save = await DB.SaveDBResponse.FromSql(strSQL).FirstAsync(); Response.Success = save.code.Equals("000"); Response.Messages.Add(save.desc); } #endregion #region Tester else { Response.Success = true; Response.Messages.Add("Test"); } #endregion DB.Dispose(); return(Json(Response.Render())); }