private void InsertData() { List <List <string> > ListDataSession = GetSessionData(); var container = Master.FindControl("Body"); for (int i = 0; i < ListDataSession.Count; i++) { for (int i2 = 0; i2 <= 9; i2++) //--Var { string tbName = "tbEdit" + i.ToString() + i2.ToString(); var txtBox = container.FindControl(tbName); ((TextBox)txtBox).Text = ListDataSession[i][i2].Replace(" ", ""); } string lbName = "lbEdit" + i.ToString() + "0"; var listboxData = container.FindControl(lbName) as ListBox; List <int> IdSubject = GetSessionDataIDs(); List <int> IdRel = _business.GetRelationDoctorHasHospitals(IdSubject[i]); //--Var if (IdRel.Count > 0) { foreach (int IdRel1 in IdRel) { ListItem li = new ListItem(); li = listboxData.Items.FindByValue(IdRel1.ToString()); li.Selected = true; } IdRel.Clear(); } } }
private void InsertData() { List <List <string> > ListData = GetData(); int count = 0; for (int i = 0; i < ListData.Count; i++) { List <int> IdSubject = GetDataIDs(); string lbName; var listboxData = new ListBox(); List <int> IdRel = new List <int>(); var container = Master.FindControl("Body"); for (int i2 = 0; i2 <= 2; i2++) //--Var { string tbName = "tbEdit" + i.ToString() + i2.ToString(); var txtBox = container.FindControl(tbName); DateTime dateTime = DateTime.Today; sortingPar = string.Format(" WHERE Project_ID = {0}", GetDataIDs()[i]); List <ProjectCode> CurrentProject = new List <ProjectCode>(); CurrentProject = _business.GetProjects(sortingPar); switch (i2) { case 0: ((TextBox)txtBox).Text = ListData[i][count].Replace(" ", ""); break; case 1: dateTime = DateTime.ParseExact(Convert.ToString(CurrentProject[0].Start_date), "dd-MMM-yyyy", CultureInfo.InvariantCulture); ((TextBox)txtBox).Text = dateTime.ToString("yyyy-MM-dd"); break; case 2: dateTime = DateTime.ParseExact(Convert.ToString(CurrentProject[0].End_date), "dd-MMM-yyyy", CultureInfo.InvariantCulture); ((TextBox)txtBox).Text = dateTime.ToString("yyyy-MM-dd"); break; } } lbName = "lbEdit" + i.ToString() + "0"; listboxData = container.FindControl(lbName) as ListBox; IdRel = _business.GetRelationProjectHasCRAs(IdSubject[i]); //--Var if (IdRel.Count > 0) { foreach (int IdRel1 in IdRel) { ListItem li = new ListItem(); li = listboxData.Items.FindByValue(IdRel1.ToString()); li.Selected = true; } IdRel.Clear(); } lbName = "lbEdit" + i.ToString() + "1"; listboxData = container.FindControl(lbName) as ListBox; IdRel = _business.GetRelationProjectHasDoctors(IdSubject[i]); //--Var if (IdRel.Count > 0) { foreach (int IdRel1 in IdRel) { ListItem li = new ListItem(); li = listboxData.Items.FindByValue(IdRel1.ToString()); li.Selected = true; } IdRel.Clear(); } lbName = "lbEdit" + i.ToString() + "2"; listboxData = container.FindControl(lbName) as ListBox; IdRel = _business.GetRelationProjectHasHospitals(IdSubject[i]); //--Var if (IdRel.Count > 0) { foreach (int IdRel1 in IdRel) { ListItem li = new ListItem(); li = listboxData.Items.FindByValue(IdRel1.ToString()); li.Selected = true; } IdRel.Clear(); } lbName = "lbEdit" + i.ToString() + "3"; listboxData = container.FindControl(lbName) as ListBox; IdRel = _business.GetRelationProjectHasProjectManagers(IdSubject[i]); //--Var if (IdRel.Count > 0) { foreach (int IdRel1 in IdRel) { ListItem li = new ListItem(); li = listboxData.Items.FindByValue(IdRel1.ToString()); li.Selected = true; } IdRel.Clear(); } } }