private void UpdateSelection(Selection newSelection) { String sqlReqStr = "UPDATE SELECTION SET NAME='"+newSelection.Name+"',COUNT_ROWS='"+ newSelection.CountRows + "' " + "WHERE TASK_ID='" + newSelection.TaskID + "' and ID='" + newSelection.ID +"';"; sqlManager.SendUpdateRequest(sqlReqStr); }
public List<Selection> GetSelectionsWithRequest(String req) { List<Selection> res = null; SQLiteCommand cmd = new SQLiteCommand(conn); cmd.Transaction = trans; cmd.CommandText = req; try { SQLiteDataReader r = cmd.ExecuteReader(); string line = String.Empty; res = new List<Selection>(); Selection selection; while (r.Read()) { selection = new Selection(); selection.ID = int.Parse(string.Format("{0}", r["ID"])); selection.TaskID = int.Parse(string.Format("{0}", r["TASK_ID"])); selection.Name = r["NAME"].ToString(); selection.CountRows = int.Parse(string.Format("{0}", r["COUNT_ROWS"])); int withResInt = int.Parse(string.Format("{0}", r["WITH_RESULT"])); if (withResInt == 0) selection.WithRes = false; else selection.WithRes = true; res.Add(selection); } r.Close(); } catch (SQLiteException ex) { Console.WriteLine(ex.Message); return null; } return res; }
private void ShowAllValuesOfSelection(Selection selection) { valuesGroupBox.Text = "Значения выборки " + selection.Name; Task curTask = arrTask[curSelectedTaskRow]; List<ValueParametr> arrValues = sqlManager.GetValuesWithRequest(String.Format("select * from VALUE_PARAM where SELECTION_ID='{0}';", selection.ID)); List<string> row; valuesDataGridView.Rows.Clear(); valuesDataGridView.Columns.Clear(); foreach (Parametr param in arrParams) { valuesDataGridView.Columns.Add(param.Name + "column", param.Name); } if (arrValues != null) { int prevIndex = arrValues[0].RowIndex; row = new List<string>(); if (!selection.WithRes)//добавляем пустую строку вместо параметра 0 row.Add(""); foreach (ValueParametr valueParam in arrValues) { if (valueParam.RowIndex != prevIndex) { valuesDataGridView.Rows.Add(row.ToArray()); row = new List<string>(); if (!selection.WithRes)//добавляем пустую строку вместо параметра 0 row.Add(""); } row.Add(valueParam.Value); prevIndex = valueParam.RowIndex; } } }