private void FillGridParam() { string strsql = "SELECT * FROM tbl_params order by id;"; DbConnection conn = db.CreateDbConnection(Database.ConnectionType.ConnectionString, OPGlobals.connString); DataTable tb = db.GetDataTable(conn, strsql); grd1.Rows.Clear(); int id = 0; try { foreach (DataRow row in tb.Rows) { id = int.Parse(row["id"].ToString()); grd1.Rows.Add(new String[] { row["id"].ToString(), row["current_year"].ToString(), Enum.GetName(typeof(Months), row["current_month"]) }); } MyGridUtils.ColorDataGrid(grd1, 0, 11); grd1.CurrentCell = null; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } id++; txtID.Text = id.ToString(); }
private void AddToGrid(DataGridView dgv) { if (String.IsNullOrEmpty(txtKPIID.Text)) { try { { dgv.Rows.Add((dgv.RowCount + 1).ToString(), "", txtEffiDes.Text, cboEffiPrefix.SelectedValue.ToString(), cboEffiPrefix.Text, txtEffiValue.Text, cboEffiUnits.SelectedValue.ToString(), cboEffiUnits.Text, cboManager.SelectedValue.ToString(), cboManager.Text, txtEffiYear.Text, cboServicePlan.SelectedValue.ToString(), cboServicePlan.Text, (chkStatus.Checked == true) ? true : false ); } MyGridUtils.ColorDataGrid(dgv); dgv.CurrentCell = null; ClearScreenData("NEW"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else { dgv.SelectedRows[0].Cells["Description"].Value = txtEffiDes.Text; dgv.SelectedRows[0].Cells["PrefixID"].Value = cboEffiPrefix.SelectedValue.ToString(); dgv.SelectedRows[0].Cells["Prefix"].Value = cboEffiPrefix.Text; dgv.SelectedRows[0].Cells["Value"].Value = txtEffiValue.Text; dgv.SelectedRows[0].Cells["UnitID"].Value = cboEffiUnits.SelectedValue.ToString(); dgv.SelectedRows[0].Cells["Unit"].Value = cboEffiUnits.Text; dgv.SelectedRows[0].Cells["SP_ID"].Value = cboServicePlan.SelectedValue.ToString(); dgv.SelectedRows[0].Cells["Service Plan"].Value = cboServicePlan.Text; dgv.SelectedRows[0].Cells["STATUS"].Value = (chkStatus.Checked == true) ? true : false; txtKPIID.Text = ""; } }
private void FillGrid() { string strsql = "Select * From view_action_with_service_plan Where view_action_with_service_plan.strategy_id = '" + lstStrategy.SelectedItems[0].SubItems[0].Text.ToString() + "'" + " ORDER BY theme_id, strategy_objective_id, strategy_rank, action_rank;"; DbConnection conn = db.CreateDbConnection(Database.ConnectionType.ConnectionString, OPGlobals.connString); DataTable tb = db.GetDataTable(conn, strsql); grdAction.Rows.Clear(); try { foreach (DataRow row in tb.Rows) { grdAction.Rows.Add(new String[] { row["action_id"].ToString(), row["action_rank"].ToString(), row["action_description"].ToString() + Environment.NewLine, "-", row["action_partner_org"].ToString(), row["strategy_id"].ToString(), "0", row["manager_id"].ToString(), row["manager_description"].ToString(), row["director_id"].ToString(), row["director_description"].ToString(), row["theme_color"].ToString(), row["service_plan"].ToString(), row["service_plan_id"].ToString(), row["council_plan_short"].ToString(), row["council_plan_id"].ToString() }); } MyGridUtils.ColorDataGrid(grdAction, 0, 11); grdAction.CurrentCell = null; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }