public void FullUpdate() { if (Ubox.Text.Contains("Administrator")) { string[] txt = Ubox.Text.Split('|'); string sql = "Select UserID, FullName from users where(Role='Expert');"; Aclb1.Items.Clear(); sqldata = GetData(sql, 2); foreach (string[] x in sqldata) { Aclb1.Items.Add(x[0] + "|" + x[1]); } sqldata.Clear(); comboBox1.Items.Clear(); sql = "select * from project"; sqldata = GetData(sql, 2); foreach (string[] x in sqldata) { comboBox1.Items.Add(x[0] + "|" + x[1]); } Acb.Items.Clear(); itbox.Items.Clear(); sqldata.Clear(); Art.Clear(); } else if (Ubox.Text.Contains("Expert")) { other.Rows.Clear(); other.Columns.Clear(); string[] txt = Ecb.Text.Split('|'); Eqgrid.Rows.Clear(); Eqgrid.Columns.Clear(); Eagrid.Rows.Clear(); Eagrid.Columns.Clear(); Eqgrid.Columns.Add("Question Text", "Question Text"); Eqgrid.Columns.Add("Unit", "Unit"); Eqgrid.Columns.Add("Max", "Max"); Eqgrid.Columns.Add("Min", "Min"); string sql = "Select questionid,unit,maximum,minimum,text from question where qid=" + txt[0] + ";"; sqldata = GetData(sql, 5); sql = "select Max(iteration) from answer where (userid=" + Ubox.Text[0] + " and questionid=(select top 1 questionid from question where qid=" + Ecb.Text[0] + "));"; var cmd = new SqlCommand(); cmd.Connection = Main.conn; cmd.CommandText = sql; SqlDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { if (it < Convert.ToInt32(reader[0].ToString())) { it = Convert.ToInt32(reader[0].ToString()); } } } catch { it = 0; } reader.Close(); if (it < 1) { El3.Visible = true; etb.Visible = true; } else { } Eagrid.Columns.Add("Answer", "Answer"); Eagrid.Columns.Add("Explanation", "Explanation"); for (int i = 0; i < sqldata.Count; i++) { Eqgrid.Rows.Add(); Eqgrid.Rows[i].HeaderCell.Value = sqldata[i][0]; Eqgrid.Rows[i].Cells[0].Value = sqldata[i][4]; Eqgrid.Rows[i].Cells[1].Value = sqldata[i][1]; Eqgrid.Rows[i].Cells[2].Value = sqldata[i][2]; Eqgrid.Rows[i].Cells[3].Value = sqldata[i][3]; Eagrid.Rows.Add(); Eagrid.Rows[i].HeaderCell.Value = sqldata[i][0]; } sqldata.Clear(); Sb.Visible = true; other.Columns.Clear(); other.Rows.Clear(); sql = "select questionid from question where qid=" + Ecb.Text[0] + ";"; sqldata = GetData(sql, 1); int max = 0; sql = "select max(iteration) from answer where questionid=" + sqldata[0][0] + ";"; cmd = new SqlCommand(); cmd.Connection = Main.conn; cmd.CommandText = sql; reader = cmd.ExecuteReader(); try { while (reader.Read()) { if (max < Convert.ToInt32(reader[0].ToString())) { max = Convert.ToInt32(reader[0].ToString()); } } } catch { max = 0; } reader.Close(); if (max >= 1) { other.Columns.Add("Answer", "Answer"); other.Columns.Add("Explanation", "Explanation"); foreach (string[] x in sqldata) { sql = "select answer, explanation from answer where questionid=" + x[0] + " and iteration=" + max + " and userid!=" + Ubox.Text[0] + ";"; List <string[]> ans = GetData(sql, 2); foreach (string[] y in ans) { other.Rows.Add(); other.Rows[other.Rows.Count - 1].HeaderCell.Value = x[0]; other.Rows[other.Rows.Count - 1].Cells[0].Value = y[0]; other.Rows[other.Rows.Count - 1].Cells[1].Value = y[1]; } } sqldata.Clear(); } } }