private void SaveSurveyButton_Click(object sender, EventArgs e) { DbConnector db = DbConnector.GetInstance(); for (int i = 0; i < _surveys.Count; i++) { DateTime dt = DateTime.Parse(SurveysTable.GetControlFromPosition(1, i).Text); _surveys[i].type_id = _st.Find(x => x.Name == SurveysTable.GetControlFromPosition(0, i).Text).id; _surveys[i].DateTime = dt.ToString("yyy-MM-dd HH:mm:ss"); _surveys[i].Result = SurveysTable.GetControlFromPosition(2, i).Text; _surveys[i].employeeId = db.GetEmployeeProfile(SurveysTable.GetControlFromPosition(3, i).Text).id; db.UpdateSurvey(_surveys[i]); } LoadEntriesSurveys(); }
public void LoadEntriesSurveys() { SurveysTable.Controls.Clear(); _surveys = DbConnector.GetInstance().GetSurveys(_card.id); SurveysTable.RowCount = _tests.Count; SurveysTable.Update(); for (int i = 0; i < _surveys.Count; i++) { ComboBox n = new ComboBox(); n.Font = new Font("Calibri", 12); n.BeginUpdate(); _st.ForEach(x => n.Items.Add(x.Name)); n.EndUpdate(); n.Text = _surveys[i].Type; DateTimePicker lb1 = new DateTimePicker(); lb1.Size = new Size(120, lb1.Height); lb1.Text = _surveys[i].DateTime; lb1.Show(); TextBox lb2 = new TextBox(); lb2.Font = new Font("Calibri", 12); lb2.Text = _surveys[i].Result; lb2.Show(); ComboBox cb = new ComboBox(); cb.Font = new Font("Calibri", 12); cb.BeginUpdate(); _employees.ForEach(x => cb.Items.Add(x.Name)); cb.EndUpdate(); cb.Text = _surveys[i].EmployeeName; Label lb3 = new Label(); lb3.Font = new Font("Calibri", 12); lb3.Text = _st.Find(x => x.Name == _surveys[i].Type).Cost.ToString(); lb3.Show(); DeleteButton vb = new DeleteButton(_surveys[i].id, "survey"); vb.Click += vb_Click; this.SurveysTable.Controls.Add(n, 0, i); this.SurveysTable.Controls.Add(lb1, 1, i); this.SurveysTable.Controls.Add(lb2, 2, i); this.SurveysTable.Controls.Add(cb, 3, i); this.SurveysTable.Controls.Add(lb3, 4, i); this.SurveysTable.Controls.Add(vb, 5, i); } }