public DiseaseDistroPcVm(AdminLevel a, DiseaseDistroPc s, ICalcIndicators c) { r = new DiseaseRepository(); this.model = s; adminLevel = a; calc = c; }
public IntvBaseVm(AdminLevel a, IntvDetails d, ICalcIndicators c) { r = new IntvRepository(); this.model = r.GetById(d.Id); adminLevel = a; calc = c; }
public ProcessBaseVm(AdminLevel a, ProcessDetails s, ICalcIndicators c) { r = new ProcessRepository(); this.model = r.GetById(s.Id); adminLevel = a; calc = c; }
public SurveyBaseVm(AdminLevel a, SurveyDetails s, ICalcIndicators c) { r = new SurveyRepository(); this.model = r.GetById(s.Id); adminLevel = a; calc = c; }
public SurveyBaseVm(AdminLevel a, int typeId, ICalcIndicators c) { adminLevel = a; r = new SurveyRepository(); model = r.CreateSurvey(typeId); calc = c; }
public DashboardTabs(AdminLevel adminLevel, AdminLevelType t) : base() { this.adminlevelType = t; this.adminLevel = adminLevel; InitializeComponent(); }
public DiseaseDistroPcVm(AdminLevel a, int did, ICalcIndicators c) { adminLevel = a; r = new DiseaseRepository(); model = r.Create((DiseaseType)did); model.AdminLevelId = adminLevel.Id; calc = c; }
public ProcessBaseVm(AdminLevel a, int typeId, ICalcIndicators c) { adminLevel = a; r = new ProcessRepository(); model = r.Create(typeId); model.AdminLevelId = adminLevel.Id; calc = c; }
public IntvBaseVm(AdminLevel a, int typeId, ICalcIndicators c) { adminLevel = a; r = new IntvRepository(); model = r.CreateIntv(typeId); model.AdminLevelId = adminLevel.Id; calc = c; }
public DemographyView(AdminLevelDemography d, AdminLevel a, bool canViewEdit) : base() { canEdit = canViewEdit; adminLevel = a; this.model = d; InitializeComponent(); }
public DiseaseDashboard(IFetchActivities f, AdminLevel l, bool readOnly) : base() { InitializeComponent(); fetcher = f; adminLevel = l; isReadOnly = readOnly; }
public DiseaseDashboard(bool readOnly) : base() { InitializeComponent(); fetcher = null; adminLevel = null; isReadOnly = readOnly; }
private void LoadDash(AdminLevel adminLevel) { IFetchActivities fetcher = new ActivityFetcher(adminLevel); DiseaseDashboard dash = new DiseaseDashboard(fetcher, adminLevel, false); dash.ReloadView = (v) => { ReloadView(v); }; dash.LoadView = (v) => { LoadView(v); }; dash.LoadForm = (v) => { LoadForm(v); }; dash.StatusChanged = (s) => { StatusChanged(s); }; dash.LoadContent(); //dash.Dock = DockStyle.Fill; pnlLf.Controls.Add(dash); }
public void BindData(ProcessBase e, List<AdminLevel> u, AdminLevel s) { source = s; Localizer.TranslateControl(this); sae = e; destinations = u; var idInd = e.IndicatorValues.FirstOrDefault(i => i.Indicator.DisplayName == "SaeId"); lnkName.Text = e.DateReported.ToShortDateString(); if (idInd != null && !string.IsNullOrEmpty(idInd.DynamicValue)) lnkName.Text = idInd.DynamicValue + " - " + lnkName.Text; destinations.Insert(0, new AdminLevel { Id = -1, Name = "" }); bindingSource1.DataSource = destinations; if (destinations.Count > 0) cbUnits.DropDownWidth = BaseForm.GetDropdownWidth(destinations.Select(a => a.Name)); }
private void Demo_Load(object sender, EventArgs e) { if (!DesignMode) { adminLevelBoundToGlobalTree = adminLevel; adminLevel = Util.DeepClone<AdminLevel>(adminLevel); Localizer.TranslateControl(this); demo = new DemoRepository(); if (model == null) { model = new AdminLevelDemography(); model.AdminLevelId = adminLevel.Id; } else originalDate = model.DateDemographyData; lblType.Text = Translations.Demography; StatusChanged(model.UpdatedBy); if (!canEdit) { btnTopSave.Visible = false; btnBottomSave.Visible = false; } if(!Roles.IsUserInRole(ApplicationData.Instance.CurrentUser.UserName, "RoleDataEnterer") && !Roles.IsUserInRole(ApplicationData.Instance.CurrentUser.UserName, "RoleAdmin")) { lnkEditAdminLevelUnit.Visible = false; btnTopSave.Visible = false; btnBottomSave.Visible = false; } bsDemo.DataSource = model; BindAdminLevel(); } }
public void BindData(AdminLevel e, List<TaskForceAdminUnit> u) { Localizer.TranslateControl(this); existing = e; taskForceUnits = u; h3Required1.SetMaxWidth(300); DemoRepository demo = new DemoRepository(); var parentNames = demo.GetAdminLevelParentNames(existing.Id); if (parentNames.Count == 0) h3Required1.Text = e.Name; else h3Required1.Text = ""; foreach (var pname in parentNames) h3Required1.Text += pname.Name + " > "; if (h3Required1.Text.EndsWith(" > ")) h3Required1.Text = h3Required1.Text.Substring(0, h3Required1.Text.LastIndexOf(" > ")); taskForceUnits.Insert(0, new TaskForceAdminUnit { Id = -1, Name = "" }); bindingSource1.DataSource = taskForceUnits; if (taskForceUnits.Count > 1) cbUnits.DropDownWidth = BaseForm.GetDropdownWidth(taskForceUnits.Select(a => a.Name)); }
private void SaveMatch(TaskForceAdminUnit match, AdminLevel u, DemoRepository demo) { match.NadaId = u.Id; var adminLevel = demo.GetAdminLevelById(u.Id); adminLevel.TaskForceId = match.Id; adminLevel.TaskForceName = match.Name; demo.UpdateTaskForceData(adminLevel, ApplicationData.Instance.GetUserId()); }
public ActivityFetcher(AdminLevel adminLevel) { this.adminLevel = adminLevel; }
public AdminUnitMatcher(AdminLevel e, List<TaskForceAdminUnit> u) : base() { InitializeComponent(); BindData(e, u); }
private void GetChildren(List<AdminLevel> children, AdminLevel parent) { if (parent.Children.Count == 0) children.Add(parent); else foreach (var i in parent.Children) GetChildren(children, i); }
private void SelectItem(AdminLevel item) { if(Selected.FirstOrDefault(a => a.Id == item.Id) == null) Selected.Add(item); }
public void Select(AdminLevel obj) { lblAdminLevel.Text = obj.Name; }
private void DeleteNode(AdminLevel item, List<AdminLevel> oldList) { oldList.Remove(item); }
public void CreateImportFile(string filename, bool importDemography, int rows, AdminLevel filterLevel) { // Get data filterBy = filterLevel; int dropdownCol = GetParams(); DataTable data = CreateNewImportDataTable(importDemography); DemoRepository demo = new DemoRepository(); CountryDemography recentCountryDemo = demo.GetCountryDemoRecent(); // Create excel System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Microsoft.Office.Interop.Excel.Application xlsApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); Microsoft.Office.Interop.Excel.Workbook xlsWorkbook; Microsoft.Office.Interop.Excel.Worksheet xlsWorksheet; Microsoft.Office.Interop.Excel.Worksheet xlsValidation; object oMissing = System.Reflection.Missing.Value; validationRanges = new Dictionary<string, string>(); //Create new workbook xlsWorkbook = xlsApp.Workbooks.Add(true); //Get the first worksheet xlsWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)(xlsWorkbook.Worksheets[1]); // add hidden validation worksheet xlsValidation = (Microsoft.Office.Interop.Excel.Worksheet)xlsWorkbook.Worksheets.Add(oMissing, xlsWorksheet, oMissing, oMissing); xlsValidation.Name = validationSheetName; xlsValidation.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetHidden; // Add columns int iCol = 0; foreach (DataColumn c in data.Columns) { iCol++; xlsWorksheet.Cells[1, iCol] = c.ColumnName; } string totalPopColumn = "F"; // Add rows for (int r = 1; r <= rows + 1; r++) { for (int i = 1; i < data.Columns.Count + 1; i++) { if (r == 1) { // Add the header the first time through xlsWorksheet.Cells[1, i] = data.Columns[i - 1].ColumnName; } else { if (i == 1 && filterByType != null) xlsWorksheet.Cells[r, i] = filterLevel.Name; if (dropdownCol == i && dropdownValues.Count > 0) { AddDataValidation(xlsWorksheet, xlsValidation, Util.GetExcelColumnName(i), r, dropdownBy.DisplayName, TranslationLookup.GetValue("PleaseSelect"), dropdownValues, oldCI); } if (data.Columns[i - 1].ColumnName == TranslationLookup.GetValue("UrbanOrRural")) AddDataValidation(xlsWorksheet, xlsValidation, Util.GetExcelColumnName(i), r, TranslationLookup.GetValue("UrbanOrRural"), TranslationLookup.GetValue("PleaseSelect"), new List<string> { TranslationLookup.GetValue("AdminUnitUrban"), TranslationLookup.GetValue("AdminUnitRural"), TranslationLookup.GetValue("AdminUnitPeriRural")}, oldCI); if (importDemography) { if (data.Columns[i - 1].ColumnName == "* " + TranslationLookup.GetValue("YearCensus")) xlsWorksheet.Cells[r, i] = recentCountryDemo.YearCensus; if (data.Columns[i - 1].ColumnName == "* " + TranslationLookup.GetValue("GrowthRate")) xlsWorksheet.Cells[r, i] = recentCountryDemo.GrowthRate; if (data.Columns[i - 1].ColumnName == "* " + TranslationLookup.GetValue("TotalPopulation")) totalPopColumn = Util.GetExcelColumnName(i); if (data.Columns[i - 1].ColumnName == TranslationLookup.GetValue("Pop0Month") && recentCountryDemo.Percent6mos.HasValue) xlsWorksheet.Cells[r, i] = string.Format("={2}{1}*{0}/100", recentCountryDemo.Percent6mos, r, totalPopColumn); if (data.Columns[i - 1].ColumnName == TranslationLookup.GetValue("PopPsac") && recentCountryDemo.PercentPsac.HasValue) xlsWorksheet.Cells[r, i] = string.Format("={2}{1}*{0}/100", recentCountryDemo.PercentPsac, r, totalPopColumn); if (data.Columns[i - 1].ColumnName == "* " + TranslationLookup.GetValue("PopSac") && recentCountryDemo.PercentSac.HasValue) xlsWorksheet.Cells[r, i] = string.Format("={2}{1}*{0}/100", recentCountryDemo.PercentSac, r, totalPopColumn); if (data.Columns[i - 1].ColumnName == TranslationLookup.GetValue("Pop5yo") && recentCountryDemo.Percent5yo.HasValue) xlsWorksheet.Cells[r, i] = string.Format("={2}{1}*{0}/100", recentCountryDemo.Percent5yo, r, totalPopColumn); if (data.Columns[i - 1].ColumnName == TranslationLookup.GetValue("PopAdult") && recentCountryDemo.PercentAdult.HasValue) xlsWorksheet.Cells[r, i] = string.Format("={2}{1}*{0}/100", recentCountryDemo.PercentAdult, r, totalPopColumn); if (data.Columns[i - 1].ColumnName == TranslationLookup.GetValue("PopFemale") && recentCountryDemo.PercentFemale.HasValue) xlsWorksheet.Cells[r, i] = string.Format("={2}{1}*{0}/100", recentCountryDemo.PercentFemale, r, totalPopColumn); if (data.Columns[i - 1].ColumnName == TranslationLookup.GetValue("PopMale") && recentCountryDemo.PercentMale.HasValue) xlsWorksheet.Cells[r, i] = string.Format("={2}{1}*{0}/100", recentCountryDemo.PercentMale, r, totalPopColumn); if (data.Columns[i - 1].ColumnName == TranslationLookup.GetValue("PercentRural") && recentCountryDemo.PercentRural.HasValue) xlsWorksheet.Cells[r, i] = string.Format("={2}{1}*{0}/100", recentCountryDemo.PercentRural, r, totalPopColumn); } } } } var last = xlsWorksheet.Cells.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeLastCell, Type.Missing); var range = xlsWorksheet.get_Range("A1", last); range.Columns.AutoFit(); xlsApp.DisplayAlerts = false; xlsWorkbook.SaveAs(filename, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, oMissing, oMissing, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlUserResolution, true, oMissing, oMissing, oMissing); xlsApp.Visible = true; xlsWorksheet = null; xlsValidation = null; xlsWorkbook = null; xlsApp = null; System.Threading.Thread.CurrentThread.CurrentCulture = oldCI; }
protected virtual string GetAdminLevelName(AdminLevel adminLevel, IHaveDynamicIndicatorValues form) { return adminLevel.Name; }
public ImportResult ImportData(string filePath, int userId, bool importDemography, bool doAggregate, int rows, AdminLevel filterLevel, DateTime dateReported) { try { System.Globalization.CultureInfo cultureEn = new System.Globalization.CultureInfo("en-US"); filterBy = filterLevel; GetParams(); DataSet ds = LoadDataFromFile(filePath); if (ds.Tables.Count == 0) return new ImportResult(TranslationLookup.GetValue("NoDataFound")); string errorMessage = ""; Dictionary<string, int> parentIds = demo.GetParentIds(filterBy, dropdownBy); List<AdminLevel> levels = new List<AdminLevel>(); foreach (DataRow row in ds.Tables[0].Rows) { int parentId = 1; if (parentIds.Count > 0) if (parentIds.ContainsKey(row["* " + dropdownBy.DisplayName].ToString().Trim().ToLower())) parentId = parentIds[row["* " + dropdownBy.DisplayName].ToString().Trim().ToLower()]; var adminLevel = new AdminLevel { AdminLevelTypeId = locationType.Id, LevelNumber = locationType.LevelNumber, Name = row["* " + locationType.DisplayName].ToString(), UrbanOrRural = row[TranslationLookup.GetValue("UrbanOrRural")].ToString(), ParentId = parentId, CurrentDemography = null }; double d1 = 0; if (double.TryParse(row[TranslationLookup.GetValue("LatWho")].ToString(), NumberStyles.Any, cultureEn, out d1)) adminLevel.LatWho = d1; if (double.TryParse(row[TranslationLookup.GetValue("LngWho")].ToString(), NumberStyles.Any, cultureEn, out d1)) adminLevel.LngWho = d1; if (importDemography) { var demography = new AdminLevelDemography(); demography.Notes = row[TranslationLookup.GetValue("Notes")].ToString(); demography.DateDemographyData = dateReported; // need to do the required validation, do all and then show errors int i = 0; if (int.TryParse(row["* " + TranslationLookup.GetValue("YearCensus")].ToString(), out i)) demography.YearCensus = i; double d = 0; int integer = 0; if (double.TryParse(row["* " + TranslationLookup.GetValue("GrowthRate")].ToString(), NumberStyles.Any, cultureEn, out d)) demography.GrowthRate = d; if (double.TryParse(row[TranslationLookup.GetValue("PercentRural")].ToString(), NumberStyles.Any, cultureEn, out d)) demography.PercentRural = d; if (TryParseAsIntThenDouble(row["* " + TranslationLookup.GetValue("TotalPopulation")].ToString(), NumberStyles.Any, cultureEn, out integer)) demography.TotalPopulation = integer; if (TryParseAsIntThenDouble(row[TranslationLookup.GetValue("Pop0Month")].ToString(), NumberStyles.Any, cultureEn, out integer)) demography.Pop0Month = integer; if (TryParseAsIntThenDouble(row[TranslationLookup.GetValue("PopPsac")].ToString(), NumberStyles.Any, cultureEn, out integer)) demography.PopPsac = integer; if (TryParseAsIntThenDouble(row["* " + TranslationLookup.GetValue("PopSac")].ToString(), NumberStyles.Any, cultureEn, out integer)) demography.PopSac = integer; if (TryParseAsIntThenDouble(row[TranslationLookup.GetValue("Pop5yo")].ToString(), NumberStyles.Any, cultureEn, out integer)) demography.Pop5yo = integer; if (TryParseAsIntThenDouble(row[TranslationLookup.GetValue("PopAdult")].ToString(), NumberStyles.Any, cultureEn, out integer)) demography.PopAdult = integer; if (TryParseAsIntThenDouble(row[TranslationLookup.GetValue("PopFemale")].ToString(), NumberStyles.Any, cultureEn, out integer)) demography.PopFemale = integer; if (TryParseAsIntThenDouble(row[TranslationLookup.GetValue("PopMale")].ToString(), NumberStyles.Any, cultureEn, out integer)) demography.PopMale = integer; adminLevel.CurrentDemography = demography; } var demographyErrors = (adminLevel.CurrentDemography != null && !adminLevel.CurrentDemography.IsValid()) ? adminLevel.CurrentDemography.GetAllErrors(true) : ""; var adminErrors = !adminLevel.IsValid() ? adminLevel.GetAllErrors(true) : ""; if (!string.IsNullOrEmpty(demographyErrors) && !string.IsNullOrEmpty(adminErrors)) errorMessage += string.Format(TranslationLookup.GetValue("ImportErrors"), adminLevel.Name) + adminErrors + "," + demographyErrors + Environment.NewLine; else if (!string.IsNullOrEmpty(demographyErrors) || !string.IsNullOrEmpty(adminErrors)) errorMessage += string.Format(TranslationLookup.GetValue("ImportErrors"), adminLevel.Name) + adminErrors + demographyErrors + Environment.NewLine; levels.Add(adminLevel); } // Validation rules and errors if (levels.Count != rows) errorMessage = string.Format(TranslationLookup.GetValue("ImportRecordsDontMatch"), rows, levels.Count) + Environment.NewLine + errorMessage; if (!string.IsNullOrEmpty(errorMessage)) return new ImportResult(TranslationLookup.GetValue("ImportErrorHeader") + Environment.NewLine + errorMessage); demo.BulkImportAdminLevelsForLevel(levels, locationType.Id, userId); if (doAggregate) demo.AggregateUp(locationType, dateReported, userId, null, countryDemoId); int rec = levels.Count; return new ImportResult { WasSuccess = true, Count = rec, Message = string.Format(TranslationLookup.GetValue("ImportSuccess"), rec) }; } catch (Exception ex) { return new ImportResult(TranslationLookup.GetValue("UnexpectedException") + ex.Message); } }
void picker_OnSelect(Model.AdminLevel obj) { h3Required1.Text = obj.Name; selected = obj; }
public void Select(AdminLevel obj, bool hideSelect) { h3Required1.Text = obj.Name; selected = obj; fieldLink1.Visible = hideSelect; }
public ProcessBaseVm(AdminLevel a, ProcessBase s, ICalcIndicators c) { this.model = s; adminLevel = a; calc = c; }
private void adminLevelAdd_OnSave(AdminLevel a) { LoadDashboard(new DashboardView()); }