public CountryDeptModel GraduationFromDiffYear(string year = "0", string country = "") { CountryDeptModel model = new CountryDeptModel(); string countryNo = country; var gradData = getGradData(countryNo, year); foreach (DataRow gradRow in gradData.Rows) { model.DeptName.Add(gradRow.ItemArray.GetValue(1).ToString()); model.GraduationNumber.Add((int)gradRow.ItemArray.GetValue(2)); } model.CountryNo = countryNo; return(model); }
public IActionResult Index() { // admin check if (getUserStatusNo() != "1") { return(Redirect("~/Home/Error")); } MgtGradModel mgtModel = new MgtGradModel(); mgtModel.Years = getTime(); mgtModel.CountryDepts = new List <CountryDeptModel>(); var sqlStr = string.Format("select [CountryNo], [CountryName] from Countries"); var data = _DB_GetData(sqlStr); foreach (DataRow row in data.Rows) { CountryDeptModel country = new CountryDeptModel(); country.CountryNo = row.ItemArray.GetValue(0).ToString(); country.CountryName = row.ItemArray.GetValue(1).ToString(); country.CountryDeptNo = new List <string>(); country.DeptName = new List <string>(); // get dept sqlStr = string.Format( "SELECT [CountryDeptNo], [DeptName] " + "FROM[dbo].[CountryDepartment] as countryDept " + "inner join[dbo].[Department] as dept " + "on countryDept.DeptNo = dept.DeptNo " + "where countryNo = {0}; ", country.CountryNo); var deptData = _DB_GetData(sqlStr); foreach (DataRow deptRow in deptData.Rows) { country.CountryDeptNo.Add(deptRow.ItemArray.GetValue(0).ToString()); country.DeptName.Add(deptRow.ItemArray.GetValue(1).ToString()); } mgtModel.CountryDepts.Add(country); } return(View("MgtGradData", mgtModel)); }
public Dictionary <string, CountryDeptModel> GraduationFromDiffCountry(string year = "0") { var data = getGradData("-1", year); Dictionary <string, CountryDeptModel> graduationData = new Dictionary <string, CountryDeptModel>(); foreach (DataRow row in data.Rows) { string countryNo = row.ItemArray.GetValue(0).ToString(); if (!graduationData.ContainsKey(countryNo)) { graduationData[countryNo] = new CountryDeptModel(); } graduationData[countryNo].DeptName.Add(row.ItemArray.GetValue(1).ToString()); graduationData[countryNo].GraduationNumber.Add((int)row.ItemArray.GetValue(2)); } return(graduationData); }