public static DAYS_REPORT getDiaReportado(int idUser, int day) { DAYS_REPORT dia = null; try { using (goliazco_FWEntities entity = new goliazco_FWEntities()) { dia = (from t in entity.DAYS_REPORT where t.idUser == idUser && t.day == day select t).FirstOrDefault(); } } catch (Exception ex) { throw new Exception(ex.Message); } return(dia); }
public static DAYS_REPORT getReportedDayByUser(int idUser, int day) { DAYS_REPORT reportedDay = null; goliazco_FWEntities entity = null; try { entity = new goliazco_FWEntities(); entity.Configuration.LazyLoadingEnabled = true; reportedDay = (from t in entity.DAYS_REPORT where t.idUser == idUser && t.day == day select t).FirstOrDefault(); } catch (Exception ex) { throw new Exception(ex.Message); } return(reportedDay); }
private void ArmarTable() { //DAYS excerciseForDay = DaysDao.getDay(int.Parse(ddlDay.SelectedValue)); DAYS excerciseForDay = DaysDao.getDay(1); if (Users != null) { DataTable tabla = new DataTable("Usuarios"); DataColumn dtColumnIdUser = new DataColumn("idUser"); tabla.Columns.Add(dtColumnIdUser); DataColumn dtName = new DataColumn("name"); tabla.Columns.Add(dtName); DataColumn dtAge = new DataColumn("age"); tabla.Columns.Add(dtAge); DataColumn dtGender = new DataColumn("gender"); tabla.Columns.Add(dtGender); DataColumn dtNationality = new DataColumn("nationality"); tabla.Columns.Add(dtNationality); DataColumn dtEmail = new DataColumn("email"); tabla.Columns.Add(dtEmail); DataColumn dtPass = new DataColumn("pass"); tabla.Columns.Add(dtPass); DataColumn dtHades = new DataColumn("hades_pb"); tabla.Columns.Add(dtHades); DataColumn dtPoseidon = new DataColumn("poseidon_pb"); tabla.Columns.Add(dtPoseidon); DataColumn dtVenus = new DataColumn("venus_pb"); tabla.Columns.Add(dtVenus); if (excerciseForDay != null && excerciseForDay.DAYS_CONFIG != null && excerciseForDay.DAYS_CONFIG.Count > 0) { List <DAYS_CONFIG> excer = excerciseForDay.DAYS_CONFIG.ToList(); for (int i = 0; i < excer.Count; i++) { DataColumn column = new DataColumn(excer[i].name + " " + excer[i].dataType); BoundField columna = new BoundField(); columna.DataField = excer[i].name + " " + excer[i].dataType; columna.HeaderText = excer[i].name + " " + excer[i].dataType; columna.SortExpression = excer[i].name + " " + excer[i].dataType; gvUsuarios.Columns.Add(columna); tabla.Columns.Add(column); } } for (int j = 0; j < Users.Count; j++) { DataRow dw = tabla.NewRow(); dw.SetField("idUser", Users[j].idUser); dw.SetField("name", Users[j].name); dw.SetField("age", Users[j].age); dw.SetField("gender", Users[j].gender); dw.SetField("nationality", Users[j].nationality); dw.SetField("email", Users[j].email); dw.SetField("pass", Users[j].pass); dw.SetField("hades_pb", Users[j].hades_pb); dw.SetField("poseidon_pb", Users[j].poseidon_pb); dw.SetField("venus_pb", Users[j].venus_pb); //if (Users[j].DAYS_REPORT != null && Users[j].DAYS_REPORT.Count > 0) //{ DAYS_REPORT diaSolicitado = UserDao.getDiaReportado(Users[j].idUser, 1); if (diaSolicitado != null) { List <REPORT_DAY> diasReportados = DaysDao.getDiasReportados(diaSolicitado.idRegister); for (int i = 0; i < diasReportados.Count; i++) { dw.SetField(diasReportados[i].Name + " " + diasReportados[i].DataInform, diasReportados[i].Inform); } } //} tabla.Rows.Add(dw); } //TablaUsuarios = tabla; //gvUsuarios.DataSource = TablaUsuarios; //gvUsuarios.DataBind(); } }
public static bool SaveInform(int idUser, int day, int idRegister, int[] idReportedDays, string[] names, string[] dataTypes, string[] inform) { bool resp = false; try { goliazco_FWEntities entity = new goliazco_FWEntities(); if (idRegister > 0) { DAYS_REPORT reportedDay = (from t in entity.DAYS_REPORT where t.idRegister == idRegister && t.idUser == idUser select t).FirstOrDefault(); reportedDay.date = DateTime.Now; if (reportedDay != null) { int i; for (i = 0; i < idReportedDays.Length; i++) { REPORT_DAY reporteDeDia = (from t in reportedDay.REPORT_DAY where t.idReportDay == idReportedDays[i] select t).FirstOrDefault(); reporteDeDia.Name = names[i]; reporteDeDia.DataInform = dataTypes[i]; reporteDeDia.Inform = inform[i]; } if (names.Length > idReportedDays.Length) { for (int j = i; j < names.Length; j++) { REPORT_DAY newReport = new REPORT_DAY(); newReport.Name = names[j]; newReport.DataInform = dataTypes[j]; newReport.Inform = inform[j]; reportedDay.REPORT_DAY.Add(newReport); } } } entity.SaveChanges(); resp = true; } else { entity.Configuration.LazyLoadingEnabled = true; entity.Configuration.ValidateOnSaveEnabled = true; DAYS_REPORT newReportedDay = new DAYS_REPORT(); newReportedDay.USERS = (from t in entity.USERS where t.idUser == idUser select t).FirstOrDefault(); newReportedDay.day = day; newReportedDay.date = DateTime.Now; for (int i = 0; i < names.Length; i++) { //THis is a new report any day. only report 1 excercise REPORT_DAY reportForDay = new REPORT_DAY(); reportForDay.Inform = inform[i]; reportForDay.Name = names[i]; reportForDay.DataInform = dataTypes[i]; newReportedDay.REPORT_DAY.Add(reportForDay); } entity.DAYS_REPORT.Add(newReportedDay); entity.SaveChanges(); resp = true; } } catch (Exception ex) { throw new Exception(ex.Message); } return(resp); }
private void LoadDayRegisteredToBeModified() { diaReported = DaysDao.getReportedDayByUser(LoggedUser.idUser, int.Parse(Request["Day"])); if (diaReported != null) { hdIdDayReported.Value = diaReported.idRegister.ToString(); int cont = 1; foreach (REPORT_DAY confDay in diaReported.REPORT_DAY) { if (confDay != null && confDay.Name != null) { if (confDay.Name == lblReport1.Text && confDay.DataInform == ddlDataTypeReport1.SelectedValue) { cont = 1; } if (confDay.Name == lblReport2.Text && confDay.DataInform == ddlDataTypeReport2.SelectedValue) { cont = 2; } if (confDay.Name == lblReport3.Text && confDay.DataInform == ddlDataTypeReport3.SelectedValue) { cont = 3; } if (confDay.Name == lblReport4.Text && confDay.DataInform == ddlDataTypeReport4.SelectedValue) { cont = 4; } if (confDay.Name == lblReport5.Text && confDay.DataInform == ddlDataTypeReport5.SelectedValue) { cont = 5; } if (confDay.Name == lblReport6.Text && confDay.DataInform == ddlDataTypeReport6.SelectedValue) { cont = 6; } if (confDay.Name == lblReport7.Text && confDay.DataInform == ddlDataTypeReport7.SelectedValue) { cont = 7; } if (confDay.Name == lblReport8.Text && confDay.DataInform == ddlDataTypeReport8.SelectedValue) { cont = 8; } if (confDay.Name == lblReport9.Text && confDay.DataInform == ddlDataTypeReport9.SelectedValue) { cont = 9; } if (confDay.Name == lblReport10.Text && confDay.DataInform == ddlDataTypeReport10.SelectedValue) { cont = 10; } } HtmlGenericControl divPanel = (HtmlGenericControl)FindControl("div" + cont); divPanel.Style.Remove("display"); HiddenField hdField = (HiddenField)FindControl("hdReport" + cont); hdField.Value = confDay.idReportDay.ToString(); Label lbl = (Label)FindControl("lblReport" + cont); lbl.Text = confDay.Name; DropDownList ddl = (DropDownList)FindControl("ddlDataTypeReport" + cont); ddl.Items.Insert(0, confDay.DataInform); TextBox txt = (TextBox)FindControl("txtReport" + cont); txt.Text = confDay.Inform; switch (confDay.DataInform) { case "Time": txt.CssClass = "validateTime"; break; case "Integer": txt.MaxLength = 4; txt.CssClass = "validateOnlyNumber"; break; case "Broken/Unbroken": txt.CssClass = "validateOnlyBOrU"; txt.MaxLength = 1; break; } //cont++; } } }