private IList <ImportSiteNumber> GetDataRow(DataSet ds) { var rowno = 0; IList <ImportSiteNumber> rdlist = new List <ImportSiteNumber>(); foreach (DataRow dr in ds.Tables[0].Rows) { rowno++; int pOnT, pOnPreT, everPonT, everPreT; if (!DatarowValueToInt(dr[2], out pOnT)) { pOnT = 0; } if (!DatarowValueToInt(dr[3], out pOnPreT)) { pOnPreT = 0; } if (!DatarowValueToInt(dr[4], out everPonT)) { everPonT = 0; } if (!DatarowValueToInt(dr[5], out everPreT)) { everPreT = 0; } string rname = Convert.ToString(dr[0]).ToUpper().Trim(); int regionid = _regions.Any(x => x.RegionName.ToUpper() == rname) ? _regions.Single(x => x.RegionName.ToUpper() == rname).Id : 0; var rd = new ImportSiteNumber(rowno, regionid, Convert.ToString(dr[0]).Trim(), Convert.ToString(dr[1]).Trim(), pOnT, pOnPreT, everPonT, everPreT, Convert.ToString(dr[6]).Trim(), Convert.ToString(dr[7]).Trim(), Convert.ToString(dr[8]).Trim(), Convert.ToString(dr[9]).Trim(), Convert.ToString(dr[10]).Trim(), Convert.ToString(dr[11]).Trim(), Convert.ToString(dr[12]).Trim()); if (!string.IsNullOrEmpty(Convert.ToString(dr[0]))) { AddImportedMCategory(new ImportedReagionOrCategory(Convert.ToString(dr[0]))); } rdlist.Add(rd); } var frm = new FrmAssignCat(_listOfImportedMCategorys, _forecast.MorbidityCategories); frm.ShowDialog(); foreach (var rd in rdlist) { if (!string.IsNullOrEmpty(rd.RegionName)) { rd.MCategory = _listOfImportedMCategorys[rd.RegionName].MCategory; if (!string.IsNullOrEmpty(rd.SiteName)) { rd.Site = _forecast.UseRegionAsCat ? DataRepository.GetSiteByName(rd.SiteName, rd.MCategory.RegionId) : DataRepository.GetSiteByName(rd.SiteName); if (rd.Site != null) { if (!IsSiteSelected(rd.Site.Id)) { _selectedSiteId.Add(rd.Site.Id); if (rd.Vct < 0 || rd.CD4 < 0 || rd.Chemistry < 0 || rd.Hematology < 0 || rd.ViralLoad < 0 || rd.Consumable < 0 || rd.OtherTest < 0) { rd.HasError = true; rd.ErrorDescription = "Error: there is invalid value in CVT to Consumables"; } } else { rd.HasError = true; rd.ErrorDescription = "Error:ART site already exist."; } } else { rd.HasError = true; rd.ErrorDescription = "Error: unable to found ART site"; } } else { rd.HasError = true; rd.ErrorDescription = "Error: ART site name is empty"; } } else { rd.HasError = true; rd.ErrorDescription = "Error: Category/Region name is empty"; } } return(rdlist); }
private IList<ImportSiteNumber> GetDataRow(DataSet ds) { var rowno = 0; IList<ImportSiteNumber> rdlist = new List<ImportSiteNumber>(); foreach (DataRow dr in ds.Tables[0].Rows) { rowno++; int pOnT,pOnPreT, everPonT, everPreT; if (!DatarowValueToInt(dr[2], out pOnT)) pOnT = 0; if (!DatarowValueToInt(dr[3], out pOnPreT)) pOnPreT = 0; if (!DatarowValueToInt(dr[4], out everPonT)) everPonT = 0; if (!DatarowValueToInt(dr[5], out everPreT)) everPreT = 0; string rname = Convert.ToString(dr[0]).ToUpper().Trim(); int regionid = _regions.Any(x => x.RegionName.ToUpper() == rname) ? _regions.Single(x => x.RegionName.ToUpper() == rname).Id : 0; var rd = new ImportSiteNumber(rowno, regionid, Convert.ToString(dr[0]).Trim(), Convert.ToString(dr[1]).Trim(), pOnT, pOnPreT, everPonT, everPreT, Convert.ToString(dr[6]).Trim(), Convert.ToString(dr[7]).Trim(), Convert.ToString(dr[8]).Trim(), Convert.ToString(dr[9]).Trim(), Convert.ToString(dr[10]).Trim(), Convert.ToString(dr[11]).Trim(), Convert.ToString(dr[12]).Trim()); if (!string.IsNullOrEmpty(Convert.ToString(dr[0]))) AddImportedMCategory(new ImportedReagionOrCategory(Convert.ToString(dr[0]).Trim())); rdlist.Add(rd); } var frm = new FrmAssignCat(_listOfImportedMCategorys, _forecast.MorbidityCategories); frm.ShowDialog(); foreach (var rd in rdlist) { if (!string.IsNullOrEmpty(rd.RegionName)) { rd.MCategory = _listOfImportedMCategorys[rd.RegionName.Trim()].MCategory; if (!string.IsNullOrEmpty(rd.SiteName)) { rd.Site = _forecast.UseRegionAsCat ? DataRepository.GetSiteByName(rd.SiteName, rd.MCategory.RegionId) : DataRepository.GetSiteByName(rd.SiteName,rd.RegionId); if (rd.Site != null) { if (!IsSiteSelected(rd.Site.Id)) { _selectedSiteId.Add(rd.Site.Id); if (rd.Vct < 0 || rd.CD4 < 0 || rd.Chemistry < 0 || rd.Hematology < 0 || rd.ViralLoad < 0 || rd.Consumable < 0 || rd.OtherTest< 0) { rd.HasError = true; rd.ErrorDescription = "Error: there is invalid value in CVT to Consumables"; } } else { rd.HasError = true; rd.ErrorDescription = "Error:ART site already exist."; } } else { rd.HasError = true; rd.ErrorDescription = "Error: unable to found ART site"; } } else { rd.HasError = true; rd.ErrorDescription = "Error: ART site name is empty"; } } else { rd.HasError = true; rd.ErrorDescription = "Error: Category/Region name is empty"; } } return rdlist; }