private void UpdateSupplements(int childId) { ChildSupplements su = ChildSupplements.GetChildSupplementsByChild(childId); if (su != null) { su.ChildId = childId; su.Vita = chkVitA.Checked; su.Mebendezol = chkMebendezol.Checked; su.Date = DateTime.Now; // or // DateTime date = DateTime.ParseExact(lblVitADate.Text, ConfigurationDate.GetConfigurationDateById(int.Parse(Configuration.GetConfigurationByName("DateFormat").Value)).DateFormat.ToString(), CultureInfo.CurrentCulture); // su.Date = date; su.ModifiedOn = DateTime.Now; su.ModifiedBy = CurrentEnvironment.LoggedUser.Id; ChildSupplements.Update(su); } else { su = new ChildSupplements(); su.ChildId = childId; su.Vita = chkVitA.Checked; su.Mebendezol = chkMebendezol.Checked; su.Date = DateTime.Now; // or // DateTime date = DateTime.ParseExact(lblVitADate.Text, ConfigurationDate.GetConfigurationDateById(int.Parse(Configuration.GetConfigurationByName("DateFormat").Value)).DateFormat.ToString(), CultureInfo.CurrentCulture); // su.Date = date; su.ModifiedOn = DateTime.Now; su.ModifiedBy = CurrentEnvironment.LoggedUser.Id; ChildSupplements.Insert(su); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { List <string> actionList = null; string sessionNameAction = ""; if (CurrentEnvironment.LoggedUser != null) { sessionNameAction = "__GIS_actionList_" + CurrentEnvironment.LoggedUser.Id; actionList = (List <string>)Session[sessionNameAction]; } if ((actionList != null) && actionList.Contains("ViewChildSupplements") && (CurrentEnvironment.LoggedUser != null)) { int userId = CurrentEnvironment.LoggedUser.Id; string language = CurrentEnvironment.Language; int languageId = int.Parse(language); List <WordTranslate> wordTranslateList = WordTranslate.GetWordByLanguage(languageId, "ChildSupplements"); Dictionary <string, string> wtList = new Dictionary <string, string>(); foreach (WordTranslate vwt in wordTranslateList) { wtList.Add(vwt.Code, vwt.Name); } //controls //this.lblChildId.Text = wtList["ChildSupplementsChild"]; this.lblVitA.Text = wtList["ChildSupplementsVita"]; this.lblMebendezol.Text = wtList["ChildSupplementsMebendezol"]; this.lblDate.Text = wtList["ChildSupplementsDate"]; //grid header text //gvChildSupplements.Columns[1].HeaderText = wtList["ChildSupplementsChild"]; gvChildSupplements.Columns[3].HeaderText = wtList["ChildSupplementsVita"]; gvChildSupplements.Columns[4].HeaderText = wtList["ChildSupplementsMebendezol"]; gvChildSupplements.Columns[2].HeaderText = wtList["ChildSupplementsDate"]; //actions this.btnAdd.Visible = actionList.Contains("AddChildSupplements"); //this.btnEdit.Visible = actionList.Contains("EditChildSupplements"); //validators //rfvChildId.ErrorMessage = wtList["ChildSupplementsMandatory"]; //ceDate.Format = ConfigurationDate.GetConfigurationDateById(int.Parse(Configuration.GetConfigurationByName("DateFormat").Value)).DateFormat; //revDate.ErrorMessage = ConfigurationDate.GetConfigurationDateById(int.Parse(Configuration.GetConfigurationByName("DateFormat").Value)).DateFormat; //revDate.ValidationExpression = ConfigurationDate.GetConfigurationDateById(int.Parse(Configuration.GetConfigurationByName("DateFormat").Value)).DateExpresion; int id = -1; string _id = Request.QueryString["id"]; if (!String.IsNullOrEmpty(_id)) { int.TryParse(_id, out id); HttpContext.Current.Session["_childId"] = id; lblVitADate.Text = DateTime.Today.Date.ToString("dd-MMM-yyyy"); lblMebendezolDate.Text = DateTime.Today.Date.ToString("dd-MMM-yyyy"); ChildSupplements su = ChildSupplements.GetChildSupplementsByChild(id); if (su != null) { chkVitA.Checked = su.Vita; chkMebendezol.Checked = su.Mebendezol; } else { chkVitA.Checked = false; chkMebendezol.Checked = false; } } } else { Response.Redirect("Default.aspx"); } } }
protected void btnAdd_Click(object sender, EventArgs e) { try { if (Page.IsValid) { int userId = CurrentEnvironment.LoggedUser.Id; int id = -1; string _id = Request.QueryString["id"].ToString(); int.TryParse(_id, out id); int i; ChildSupplements su = ChildSupplements.GetChildSupplementsByChild(id); if (su != null) { su.Vita = chkVitA.Checked; su.Mebendezol = chkMebendezol.Checked; su.Date = DateTime.Now; su.ModifiedOn = DateTime.Now; su.ModifiedBy = userId; i = ChildSupplements.Update(su); } else { su = new ChildSupplements(); su.ChildId = id; su.Vita = chkVitA.Checked; su.Mebendezol = chkMebendezol.Checked; su.Date = DateTime.Now; su.ModifiedOn = DateTime.Now; su.ModifiedBy = userId; i = ChildSupplements.Insert(su); } if (i > 0) { lblSuccess.Visible = true; lblWarning.Visible = false; lblError.Visible = false; gvChildSupplements.DataBind(); gvChildSupplements.Visible = true; //ClearControls(this); } else { lblSuccess.Visible = false; lblWarning.Visible = false; lblError.Visible = true; } } } catch (Exception ex) { lblSuccess.Visible = false; lblWarning.Visible = false; lblError.Visible = true; } }
/// <summary> /// Populate Controls on the page by using the vaccination appointment /// </summary> /// <param name="app">The vaccination appointment that is being called</param> private void PopulateControls(VaccinationAppointment app) { List <VaccinationEvent> le = VaccinationEvent.GetVaccinationEventByAppointmentId(app.Id); lnkChild.Text = app.Child.Name; lnkChild.PostBackUrl = "Child.aspx?id=" + app.Child.Id; lblChildBirthdate.Text = app.Child.Birthdate.ToString("dd-MMM-yyyy"); chbxOutreach.Checked = app.Outreach; string doses = ""; VaccinationEvent o = null; foreach (VaccinationEvent ve in le) { doses += ve.Dose.Fullname + " "; lblHealthCenter.Text = ve.HealthFacility.Name; o = ve; } lblVaccineDose.Text = doses; lblScheduledDate.Text = app.ScheduledDate.ToString("dd-MMM-yyyy"); //ConfigurationDate.GetConfigurationDateById(int.Parse(Configuration.GetConfigurationByName("DateFormat").Value)).DateFormat); if (!o.IsActive) { lblInfo.Visible = true; btnEdit.Visible = false; btnRemove.Visible = false; gvVaccinationEvent.Visible = false; } foreach (VaccinationEvent ve in le) { int datediff = DateTime.Today.Date.Subtract(ve.Child.Birthdate).Days; if (ve.Dose.FromAgeDefinitionId != 0 && ve.Dose.FromAgeDefinitionId != null) { if (datediff < ve.Dose.FromAgeDefinition.Days) { lblInfo.Visible = true; break; } } if (ve.Dose.ToAgeDefinitionId != 0 && ve.Dose.ToAgeDefinitionId != null) { if (datediff > ve.Dose.ToAgeDefinition.Days) { lblInfo.Visible = true; break; } } } // populate supplements table lblVitADate.Text = DateTime.Today.Date.ToString("dd-MMM-yyyy"); lblMebendezolDate.Text = DateTime.Today.Date.ToString("dd-MMM-yyyy"); ChildSupplements su = ChildSupplements.GetChildSupplementsByChild(app.Child.Id, DateTime.Today.Date); //get by date if (su != null) { chkVitA.Checked = su.Vita; chkMebendezol.Checked = su.Mebendezol; } else { chkVitA.Checked = false; chkMebendezol.Checked = false; } //populate facility dropdownlist int hfId = CurrentEnvironment.LoggedUser.HealthFacilityId; HealthFacility hf = HealthFacility.GetHealthFacilityById(hfId); string where = string.Empty; if (!hf.TopLevel) { string s = HealthFacility.GetAllChildsForOneHealthFacility(hfId, true); where = string.Format(@"AND ""ID"" in ( {0})", s); } odsHealthF.SelectParameters.Clear(); odsHealthF.SelectParameters.Add("ids", where); odsHealthF.DataBind(); if (hf.VaccinationPoint) { ddlHealthFacility.SelectedValue = hfId.ToString(); } //populate events grid odsVaccinationEvent.SelectParameters.Clear(); odsVaccinationEvent.SelectParameters.Add("appId", app.Id.ToString()); }