public async Task <IActionResult> GetAllReportDataHome2([FromBody] ModelMenuHome2_InterfaceData search_data) { var requestUri = $"{_WebApiModel.BaseURL}/{"PrivateDocMenuHome"}/{"GetAllReportDataHome2"}"; string authHeader = HttpContext.Request?.Headers["Authorization"]; if (authHeader != null && authHeader.StartsWith("Bearer")) { BearerToken = authHeader.Substring("Bearer ".Length).Trim(); } var response = await HttpRequestFactory.Post(requestUri, BearerToken, search_data); switch (response.StatusCode) { case HttpStatusCode.Unauthorized: return(Unauthorized(response.ContentAsString())); case HttpStatusCode.BadRequest: return(BadRequest(response.ContentAsString())); case HttpStatusCode.OK: return(Ok(response.ContentAsString())); default: return(StatusCode(500)); } }
public async Task <ModelMenuHome2_InterfaceData> MenuHome2InterfaceDataAsync(string RegisterId) { ModelMenuHome2_InterfaceData resp = new ModelMenuHome2_InterfaceData(); var cultureInfo = new CultureInfo("th-TH"); CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; int thai_year = CommonData.GetYearOfPeriod(); resp.ListYear = new List <ModelSelectOption>(); ModelSelectOption year_current = new ModelSelectOption(); year_current.value = (thai_year).ToString(); year_current.label = (thai_year).ToString(); resp.ListYear.Add(year_current); for (int i = 1; i < 5; i++) { ModelSelectOption year_next = new ModelSelectOption(); year_next.value = (thai_year + i).ToString(); year_next.label = (thai_year + i).ToString(); resp.ListYear.Add(year_next); } ModelSelectOption all_year = new ModelSelectOption(); all_year.value = "All"; all_year.label = "เลือก..."; resp.ListYear.Add(all_year); //------------------------------------------------------------------------------------------ resp.ListAcceptType = new List <ModelSelectOption>(); ModelSelectOption accept_type_1 = new ModelSelectOption(); accept_type_1.value = "1"; accept_type_1.label = "แบบประเมินเบื้องต้นสำหรับห้องปฏิบัติการ"; resp.ListAcceptType.Add(accept_type_1); ModelSelectOption accept_type_2 = new ModelSelectOption(); accept_type_2.value = "2"; accept_type_2.label = "แบบประเมินเบื้องต้นสำหรับโรงเรือนทดลองสำหรับพืชดัดแปลงพันธุกรรม"; resp.ListAcceptType.Add(accept_type_2); ModelSelectOption accept_type_all = new ModelSelectOption(); accept_type_all.value = "ALL"; accept_type_all.label = "เลือก..."; resp.ListAcceptType.Add(accept_type_all); //------------------------------------------------------------------------------------------ resp.ListReportData = new List <ModelMenuHome2ReportData>(); resp.ListReportData = await GetAllReportDataHome2Async(null); resp.UserPermission = await _IRegisterUserRepository.GetPermissionPageAsync(RegisterId, "M002"); return(resp); }
public async Task <IActionResult> MenuHome2InterfaceData(string RegisterId) { ModelMenuHome2_InterfaceData e = await _IDocMenuHomeService.MenuHome2InterfaceDataAsync(RegisterId); if (e != null) { return(Ok(e)); } else { return(BadRequest()); } }
public async Task <IActionResult> GetAllReportDataHome2([FromBody] ModelMenuHome2_InterfaceData search_data) { IList <ModelMenuHome2ReportData> e = await _IDocMenuHomeService.GetAllReportDataHome2Async(search_data); if (e != null) { return(Ok(e)); } else { return(BadRequest()); } }
public async Task <IList <ModelMenuHome2ReportData> > GetAllReportDataHome2Async(ModelMenuHome2_InterfaceData search_data) { return(await _IDocMenuHomeRepository.GetAllReportDataHome2Async(search_data)); }
public async Task <IList <ModelMenuHome2ReportData> > GetAllReportDataHome2Async(ModelMenuHome2_InterfaceData search_data) { string sql = "SELECT ROW_NUMBER() OVER (ORDER BY A.doc_id ASC) as col1, " + "A.room_number as col2, A.faculty_laboratory as col3, " + "A.department as col4,A.laboratory_address as col5,A.building as col6, " + "A.floor as col7, CONVERT(VARCHAR(10),A.doc_date,103) AS col8, " + "CONVERT(VARCHAR(10),B.doc_date,103) AS col9, C.name_thai as col10, B.project_key_number as col11, " + "CONVERT(VARCHAR(10),B.meeting_date,103) as col12, (F.name_thai + ' ' + E.safety_type + ' ' + F.name_thai_sub) as col13, " + "CONVERT(VARCHAR(10),D.doc_date,103) as col14, CONVERT(VARCHAR(10),E.doc_date,103) as col15, " + "B.year_of_meeting, A.project_according_type_method " + "FROM Doc_MenuA2 A " + "LEFT OUTER JOIN Doc_MenuB2 B " + "ON A.doc_id = B.project_id " + "LEFT OUTER JOIN MST_InitialResult C " + "ON B.initial_result = C.id " + "LEFT OUTER JOIN Doc_MenuC1_2 D " + "ON B.project_key_number = D.project_number " + "LEFT OUTER JOIN Doc_MenuC2_2 E " + "ON B.project_key_number = E.project_number " + "LEFT OUTER JOIN MST_ApprovalType F " + "ON E.approval_type = F.id " + "WHERE 1=1 "; if (search_data != null) { if (!string.IsNullOrEmpty(search_data.defaultyear) && search_data.defaultyear.ToLower() != "all") { sql += " AND B.year_of_meeting ='" + search_data.defaultyear + "'"; } if (!string.IsNullOrEmpty(search_data.defaultaccepttype) && search_data.defaultaccepttype.ToLower() != "all") { sql += " AND A.project_according_type_method ='" + search_data.defaultaccepttype + "'"; } } using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); using (SqlCommand command = new SqlCommand(sql, conn)) { SqlDataReader reader = await command.ExecuteReaderAsync(); if (reader.HasRows) { int row_count = 1; IList <ModelMenuHome2ReportData> e = new List <ModelMenuHome2ReportData>(); while (await reader.ReadAsync()) { ModelMenuHome2ReportData item = new ModelMenuHome2ReportData(); item.col1 = row_count.ToString(); item.col2 = reader["col2"].ToString(); item.col3 = reader["col3"].ToString(); item.col4 = reader["col4"].ToString(); item.col5 = reader["col5"].ToString(); item.col6 = reader["col6"].ToString(); item.col7 = reader["col7"].ToString(); item.col8 = reader["col8"].ToString(); item.col9 = reader["col9"].ToString(); item.col10 = reader["col10"].ToString(); item.col11 = reader["col11"].ToString(); item.col12 = reader["col12"].ToString(); item.col13 = reader["col13"].ToString(); item.col14 = reader["col14"].ToString(); item.col15 = reader["col15"].ToString(); e.Add(item); row_count++; } return(e); } } conn.Close(); } return(null); }