public ActionResult SearchByMaterial(MasterListSearchViewModel model, GridSettings gridSettings) { var result = _materialDomain.SearchCriteria(model.MasterCode, gridSettings); if (!result.IsSuccess) { return(Json(null)); } return(Json(result.Data)); }
public ActionResult SearchByProduct(MasterListSearchViewModel model, GridSettings gridSettings) { var result = _productDomain.SearchPrint(model.MasterCode, gridSettings); if (!result.IsSuccess) { return(Json(null)); } return(Json(result.Data)); }
public ActionResult SearchByPreProduct(MasterListSearchViewModel model, GridSettings gridSettings) { try { var results = _preProductDomain.SearchMaterialList(model.MasterCode, gridSettings); return(Json(results.Data)); } catch (Exception ex) { return(Json(new { Success = false, ex.Message })); } }
/// <summary> /// Render master list page. /// </summary> /// <returns></returns> public ActionResult Index() { ViewBag.ScreenId = "TCPP061F"; var model = new MasterListSearchViewModel { GridMaterial = GenerateGridMaterial(), GridPreProduct = GenerateGridPreProduct(), GridProduct = GenerateGridProduct() }; return(View(model)); }
public async Task <ActionResult> Print(MasterListSearchViewModel masterListSearchViewModel) { try { var companyName = WebConfigurationManager.AppSettings["CompanyName"]; // Parameter hasn't been initialized. if (masterListSearchViewModel == null) { masterListSearchViewModel = new MasterListSearchViewModel(); TryValidateModel(masterListSearchViewModel); } // Parameters are invalid. if (!ModelState.IsValid) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } string renderedData; // Base on what user selects, print the related. switch (masterListSearchViewModel.SearchBy) { case 1: // Find the template absolute path. var exportPreProductAbsolutePath = Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MasterListPreProduct)); // Read the template. var masterListPreProductTemplate = await _exportReportDomain.ReadTemplateFileAsync(exportPreProductAbsolutePath); // Find all records. var preProducts = _preProductDomain.MaterialListPrint(masterListSearchViewModel.MasterCode); //#if DEBUG // preProducts.Data.data = preProducts.Data.data.Take(10); //#endif var lstPreProduct = new { Data = new { preProducts.Data.data, currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm"), companyName } }; // Render template renderedData = await _exportReportDomain.ExportToFlatFileAsync(lstPreProduct.Data, masterListPreProductTemplate); break; case 2: // Find the template absolute path. var exportProductAbsolutePath = Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MasterListProduct)); // Read the template. var masterListProductTemplate = await _exportReportDomain.ReadTemplateFileAsync(exportProductAbsolutePath); // Find all records. var products = _productDomain.SearchPrint(masterListSearchViewModel.MasterCode, null); var lstproduct = new { Data = new { products.Data.data, currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm"), companyName } }; // Render template renderedData = await _exportReportDomain.ExportToFlatFileAsync(lstproduct.Data, masterListProductTemplate); break; default: // Find the template absolute path. var exportMaterialAbsolutePath = Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MasterListMaterial)); // Read the template. var masterListMaterialTemplate = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialAbsolutePath); // Find all records. var materials = _materialDomain.SearchCriteria(masterListSearchViewModel.MasterCode, null); // materials.Data.data = materials.Data.data.ToList(); var material = new { Data = new { materials.Data.data, currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm"), companyName } }; // Render template renderedData = await _exportReportDomain.ExportToFlatFileAsync(material.Data, masterListMaterialTemplate); break; } var jsonResult = Json(new { render = renderedData, }); jsonResult.MaxJsonLength = int.MaxValue; return(jsonResult); } catch (Exception exception) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }