private void ArrangeDataGridView() { Dictionary <string, int> coloumnDict = new Dictionary <string, int>(); coloumnDict.Add("Code", 0); //0 coloumnDict.Add("Measure", 500); //1 coloumnDict.Add("Measured Against", 250); //2 coloumnDict.Add("Target June-2021", 120); //3 coloumnDict.Add("Progress", 100); //4 coloumnDict.Add("Comments", 500); //5 coloumnDict.Add("strategy_id", 0); //6 coloumnDict.Add("Exist", 100); //7 int[] hiddenRows = { 0, 6, 7 }; //int[] readonlyrows = { 0, 1, 2, 3, 6 }; MyGridUtils.ArrangeDataGrid(dgv, coloumnDict, hiddenRows); dgv.RowTemplate.MinimumHeight = 28; dgv.DefaultCellStyle.BackColor = Color.Beige; foreach (int i in readonlyrows) { dgv.Columns[i].ReadOnly = true; dgv.Columns[i].DefaultCellStyle.BackColor = Color.LightGray; dgv.Columns[i].DefaultCellStyle.ForeColor = Color.Black; } dgv.SelectionMode = DataGridViewSelectionMode.CellSelect; }
private void ArrangeGrid() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("#", 35); //0 dct.Add("cpwID", 0); //1 dct.Add("Service", 200); //2 dct.Add("Description", 530); //3 dct.Add("Org.Budget", 120); //4 dct.Add("Rev.Budget", 120); //5 dct.Add("Projected", 120); //6 int[] hiddenRows = { 1 }; int[] readonlyrows = { 0, 1, 2, 3, 4, 5 }; MyGridUtils.ArrangeDataGrid(dgv01, dct, hiddenRows); dgv01.DefaultCellStyle.BackColor = Color.Beige; this.dgv01.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[6].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgv01.RowTemplate.MinimumHeight = 28; foreach (int i in readonlyrows) { this.dgv01.Columns[i].ReadOnly = true; this.dgv01.Columns[i].DefaultCellStyle.BackColor = Color.LightGray; this.dgv01.Columns[i].DefaultCellStyle.ForeColor = Color.Black; } dgv01.SelectionMode = DataGridViewSelectionMode.CellSelect; }
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 GrdAction() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("ID", 100); dct.Add("action_rank", 0); dct.Add("Description", 790); dct.Add("Performance Indicator", 0); dct.Add("action_partner_org", 0); dct.Add("strategy_id", 0); dct.Add("performance_indicator_id", 0); dct.Add("ramanager_id", 0); dct.Add("manager_name", 0); dct.Add("director_id", 0); dct.Add("director_name", 0); dct.Add("Color", 0); dct.Add("Service Plan", 200); dct.Add("spid", 0); dct.Add("Council Plan", 200); dct.Add("CouncilPlanID", 0); int[] hiddenRows = { 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15 }; MyGridUtils.ArrangeDataGrid(grdAction, dct, hiddenRows, Color.LightGray, Color.LightSteelBlue); grdAction.ReadOnly = true; }
private void ArrangeGrid() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("#", 50); //0 dct.Add("Theme", 80); //1 dct.Add("Strategy", 190); //2 dct.Add("Description", 270); //3 dct.Add("Org.Budget", 120); //4 dct.Add("Rev.Budget", 120); //5 dct.Add("Service Plan", 210); //6 dct.Add("Manager", 210); //7 dct.Add("cpwID", 0); //8 dct.Add("ThemeID", 0); //9 dct.Add("Strat_Obj_id", 0); //10 dct.Add("DirectorID", 0); //11 dct.Add("ServicePlanID", 0); //12 dct.Add("ManagerID", 0); //13 dct.Add("ThemeColor", 0); //14 dct.Add("JobNo", 100); //15 dct.Add("CarryOver", 0); //16 int[] hiddenRows = { 8, 9, 10, 11, 12, 13, 14, 16 }; //int[] hiddenRows = { }; MyGridUtils.ArrangeDataGrid(dgv01, dct, hiddenRows, Color.LightGray, Color.LightSteelBlue); this.dgv01.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgv01.RowTemplate.MinimumHeight = 28; dgv01.ReadOnly = true; }
private void ArrangeCWPGrid() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("ID", 100); //0 dct.Add("Description", 800); //1 //---------INSERT CHECKBOX COULMN-- // //dct.Add("Check", 100); //2 int[] hiddenRows = { }; int[] readonlyrows = { 0, 1 }; MyGridUtils.ArrangeDataGrid(dgv03, dct, hiddenRows); dgv03.RowTemplate.MinimumHeight = 28; dgv03.DefaultCellStyle.BackColor = Color.Beige; foreach (int i in readonlyrows) { dgv03.Columns[i].ReadOnly = true; dgv03.Columns[i].DefaultCellStyle.BackColor = Color.LightGray; dgv03.Columns[i].DefaultCellStyle.ForeColor = Color.Black; } //----ADD Check box column--- AddCheckBoxColumn(dgv03, "dgv03X"); dgv03.SelectionMode = DataGridViewSelectionMode.CellSelect; }
private void ArrangeGrid() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("ID", 50); //0 dct.Add("Description", 400); //1 dct.Add("Source", 100); //2 dct.Add("Prefix", 130); //3 dct.Add("Target", 100); //4 dct.Add("Unit", 130); //5 dct.Add("ReportFrequency", 150); //6 dct.Add("Department", 200); //7 dct.Add("HowMeasured", 0); //8 dct.Add("Year", 0); //9 dct.Add("StrategyID", 0); //10 dct.Add("ManagerID", 0); //11 dct.Add("DirectorID", 0); //12 dct.Add("PrefixID", 0); //13 dct.Add("UnitID", 0); //14 int[] hiddenRows = { 8, 9, 10, 11, 12, 13, 14 }; MyGridUtils.ArrangeDataGrid(dgv01, dct, hiddenRows, Color.LightGray, Color.LightSteelBlue); this.dgv01.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dgv01.RowTemplate.MinimumHeight = 28; dgv01.ReadOnly = true; }
private void RefreshGridView() { for (int x = 0; x < 3; x++) { for (int i = 0; i < dgvList[x].RowCount; i++) { if (!MyGridUtils.IsColumnDataChanged(dgvList[x].Rows[i], new List <String>() { "Description", "PrefixID", "Value", "UnitID", "ManagerID", "SP_ID" }, new List <String>() { "BDescription", "BPrefixID", "BValue", "BUnitID", "BManagerID", "BSP_ID" })) { continue; } dgvList[x].Rows[i].Cells["BDescription"].Value = dgvList[x].Rows[i].Cells["Description"].Value; dgvList[x].Rows[i].Cells["BPrefixID"].Value = dgvList[x].Rows[i].Cells["PrefixID"].Value; dgvList[x].Rows[i].Cells["BValue"].Value = dgvList[x].Rows[i].Cells["Value"].Value; dgvList[x].Rows[i].Cells["BUnitID"].Value = dgvList[x].Rows[i].Cells["UnitID"].Value; dgvList[x].Rows[i].Cells["BManagerID"].Value = dgvList[x].Rows[i].Cells["ManagerID"].Value; dgvList[x].Rows[i].Cells["BSP_ID"].Value = dgvList[x].Rows[i].Cells["SP_ID"].Value; } } }
private void ArrangeKPMGrid() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("ID", 100); //1 dct.Add("Description", 800); //2 //---------INSERT CHECKBOX COULMN-- // int[] hiddenRows = { }; int[] readonlyrows = { 0, 1 }; for (int i = 0; i < dgvList.Count; i++) { MyGridUtils.ArrangeDataGrid(dgvList[i], dct, hiddenRows); dgvList[i].RowTemplate.MinimumHeight = 28; dgvList[i].DefaultCellStyle.BackColor = Color.Beige; foreach (int j in readonlyrows) { dgvList[i].Columns[j].ReadOnly = true; dgvList[i].Columns[j].DefaultCellStyle.BackColor = Color.LightGray; dgvList[i].Columns[j].DefaultCellStyle.ForeColor = Color.Black; } //----ADD Check box column--- AddCheckBoxColumn(dgvList[i], dgvList[i].Name.ToString() + "X"); dgvList[i].SelectionMode = DataGridViewSelectionMode.CellSelect; } }
private void ArrangeGrid() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("JCNo", 80); //1 dct.Add("CarryOver", 100); //2 int[] hiddenRows = { }; int[] readonlyrows = { }; MyGridUtils.ArrangeDataGrid(dg1, dct, hiddenRows); }
private void ArrangeGridParam() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("ID", 50); dct.Add("Year", 100); dct.Add("Month", 100); int[] hiddenRows = { }; MyGridUtils.ArrangeDataGrid(grd1, dct, hiddenRows, Color.LightGray, Color.LightSteelBlue); grd1.ReadOnly = true; }
private bool IsRowDataChanged(DataGridView dgv) { bool retVal = false; if (MyGridUtils.IsColumnDataChanged(dgv, new List <string>() { "Projected", "% Comp.", "Comment" }, new List <string>() { "BProjected", "B% Comp.", "BComment" })) { retVal = true; } return(retVal); }
private bool IsRowDataChanged(DataGridView dgv) { bool result = false; if (MyGridUtils.IsColumnDataChanged(dgv, new List <string>() { "Status", "Progress", "Remarks" }, new List <string>() { "BStatus", "BProgress", "BRemarks" })) { result = true; } return(result); }
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 tsbClose_Click(object sender, EventArgs e) { dgv01.EndEdit(); if (MyGridUtils.IsColumnDataChanged(dgv01, new List <string>() { "Status", "Progress", "Remarks" }, new List <string>() { "BStatus", "BProgress", "BRemarks" })) { if (MessageBox.Show("Data has been changed, Do you want to Save Before exit?", "OPERATION PLAN", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveOPMonthlyProgress(); } } this.Dispose(); }
private void ArrangeDataGridView() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("#", 60); //0 dct.Add("Theme", 0); //1 dct.Add("Action_id", 0); //2 dct.Add("Action", 750); //3 dct.Add("Target Date", 100); //4 dct.Add("manager_id", 0); //5 dct.Add("Responsible Manager", 200); //6 //---------INSERT COMBOBOXCOLOUMN-- //7 dct.Add("", 10); //8 dct.Add("Progress", 60); //9 dct.Add("Remarks", 500); //10 dct.Add("theme_color", 0); //10 dct.Add("Status_color", 0); //11 dct.Add("NEW_Flag", 0); //12 dct.Add("BStatus", 0); //13 dct.Add("BProgress", 0); //14 dct.Add("BRemarks", 0); //15 int[] hiddenRows = { 1, 2, 5, 10, 11, 12, 13, 14, 15 }; int[] readonlyrows = { 0, 1, 2, 3, 4, 5, 6, 10, 11, 12, 13, 14, 15 }; MyGridUtils.ArrangeDataGrid(dgv01, dct, hiddenRows); dgv01.RowTemplate.MinimumHeight = 28; dgv01.DefaultCellStyle.BackColor = Color.Beige; foreach (int i in readonlyrows) { dgv01.Columns[i].ReadOnly = true; dgv01.Columns[i].DefaultCellStyle.BackColor = Color.LightGray; dgv01.Columns[i].DefaultCellStyle.ForeColor = Color.Black; } //dgv01.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgv01.SelectionMode = DataGridViewSelectionMode.CellSelect; }
private void ArrangeGrid() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("#", 30); //0 dct.Add("cpwID", 0); //1 dct.Add("Service", 150); //2 dct.Add("Description", 400); //3 dct.Add("Revised-Council", 120); //4 dct.Add("YTD", 120); //5 dct.Add("Projected", 120); //6 dct.Add("% Comp.", 120); //7 dct.Add("Comment", 300); //8 dct.Add("BProjected", 100); //9 dct.Add("B% Comp.", 100); //10 dct.Add("BComment", 100); //11 dct.Add("NEFlag", 50); //12 //0-NEW 1-EDIT int[] hiddenRows = { 1, 9, 10, 11, 12 }; //int[] hiddenRows = { }; int[] readonlyrows = { 0, 1, 2, 3, 4, 5, 9, 10, 11, 12 }; //int[] hiddenRows = { 1 }; MyGridUtils.ArrangeDataGrid(dgv01, dct, hiddenRows); dgv01.RowTemplate.MinimumHeight = 28; dgv01.DefaultCellStyle.BackColor = Color.Beige; foreach (int i in readonlyrows) { dgv01.Columns[i].ReadOnly = true; this.dgv01.Columns[i].DefaultCellStyle.BackColor = Color.LightGray; this.dgv01.Columns[i].DefaultCellStyle.ForeColor = Color.Black; } this.dgv01.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[6].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[7].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgv01.SelectionMode = DataGridViewSelectionMode.CellSelect; }
private void ArrangeGrids() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("#", 50); //0 dct.Add("kpi_id", 0); //1 dct.Add("Description", 550); //2 dct.Add("Prefix", 50); //3 dct.Add("Est.", 60); //4 dct.Add("Unit", 50); //5 dct.Add("ManagerID", 0); //6 dct.Add("Progress", 80); //7 dct.Add("Remarks", 600); //8 dct.Add("kpm_id", 0); //9 dct.Add("BProgress", 0); //7 dct.Add("BRemarks", 0); //8 int[] hiddenRows = { 1, 6, 9, 10, 11 }; //int[] hiddenRows = { }; int[] readonlyrows = { 0, 1, 2, 3, 4, 5, 6, 9, 10, 11 }; for (int x = 0; x < 3; x++) { MyGridUtils.ArrangeDataGrid(dgv[x], dct, hiddenRows); dgv[x].RowTemplate.MinimumHeight = 28; dgv[x].DefaultCellStyle.BackColor = Color.Beige; foreach (int i in readonlyrows) { dgv[x].Columns[i].ReadOnly = true; dgv[x].Columns[i].DefaultCellStyle.BackColor = Color.LightGray; dgv[x].Columns[i].DefaultCellStyle.ForeColor = Color.Black; } dgv[x].Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgv[x].Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgv[x].Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv[x].Columns[7].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgv[x].SelectionMode = DataGridViewSelectionMode.CellSelect; } }
private void GrdDelivery() { Dictionary <string, int> dct = new Dictionary <string, int>(); //dct.Add("-", 30); dct.Add("Year", 100); int[] hiddenRows = { }; MyGridUtils.ArrangeDataGrid(grdDelivery, dct, hiddenRows, Color.LightGray, Color.LightSteelBlue); //DataGridViewCalendarColumn col = new DataGridViewCalendarColumn(); //col.HeaderText = "Target Date"; //col.Width = 100; //this.grdDelivery.Columns.Add(col); grdDelivery.ReadOnly = false; grdDelivery.Columns[0].ReadOnly = true; }
private void lstStrategyObjective_ItemCheck(object sender, ItemCheckEventArgs e) { //lastStrategyItemChecked = null; lastStrategyObjectiveItemChecked = MyGridUtils.listViewDeSelectPreviousItems(lstStrategyObjective, e, lastStrategyObjectiveItemChecked); if (e.NewValue == CheckState.Unchecked) { try { lstStrategyObjective.Items[lastStrategyItemChecked.Index].Selected = false; txtStrategyID.Text = ""; txtRank.Text = ""; } catch (Exception ex) { } } else { } FillStrategyList(); }
private void RefreshGridAfterSaveData() { for (int x = 0; x < dgv.Count; x++) { for (int i = 0; i < dgv[x].RowCount; i++) { if (!MyGridUtils.IsColumnDataChanged(dgv[x].Rows[i], new List <string>() { "Progress", "Remarks" }, new List <string>() { "BProgress", "BRemarks" })) { continue; } dgv[x].Rows[i].Cells["BProgress"].Value = dgv[x].Rows[i].Cells["Progress"].Value; dgv[x].Rows[i].Cells["BRemarks"].Value = dgv[x].Rows[i].Cells["Remarks"].Value; } } }
private void ArrangeGrid() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("JCNo", 80); //1 dct.Add("Description", 490); //2 dct.Add("Org.Budget", 90); //3 dct.Add("Rev.Budget", 90); //4 dct.Add("Service", 150); //5 dct.Add("Directore", 150); //6 dct.Add("Manager", 150); //7 dct.Add("ServiceID", 50); //8 dct.Add("DirectorID", 50); //9 dct.Add("ManagerID", 50); //10 dct.Add("YTD", 50); //11 int[] hiddenRows = { }; int[] readonlyrows = { }; MyGridUtils.ArrangeDataGrid(dg1, dct, hiddenRows); }
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()); } }
private void ArrangeGrids() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("#", 50); //0 dct.Add("ID", 0); //1 dct.Add("Description", 500); //2 dct.Add("PrefixID", 0); //3 dct.Add("Prefix", 130); //4 dct.Add("Value", 55); //5 dct.Add("UnitID", 0); //6 dct.Add("Unit", 45); //7 dct.Add("ManagerID", 0); //8 dct.Add("Manager", 230); //9 dct.Add("Est.Year", 60); //10 dct.Add("SP_ID", 0); //11 dct.Add("Service Plan", 230); //12 dct.Add("STATUS", 50); //13 dct.Add("BDescription", 0); //2 dct.Add("BPrefixID", 0); //3 dct.Add("BValue", 0); //5 dct.Add("BUnitID", 0); //6 dct.Add("BManagerID", 0); //8 dct.Add("BSP_ID", 0); //11 dct.Add("BSTATUS", 0); //13 int[] hiddenRows = { 1, 3, 6, 8, 11, 14, 15, 16, 17, 18, 19, 20 }; //int[] hiddenRows = { }; for (int i = 0; i < dgvList.Count; i++) { MyGridUtils.ArrangeDataGrid(dgvList[i], dct, hiddenRows, Color.LightGray, Color.LightSteelBlue); dgvList[i].RowTemplate.MinimumHeight = 28; dgvList[i].ReadOnly = true; } }
private void ArrangeGrid() { Dictionary <string, int> dct = new Dictionary <string, int>(); dct.Add("#", 35); //0 dct.Add("cpwID", 0); //1 dct.Add("Service", 250); //2 dct.Add("Description", 490); //3 dct.Add("Org.Budget", 150); //4 dct.Add("Rev.Budget", 150); //5 dct.Add("YTD", 150); //6 dct.Add("YtoD copy", 0); //7 dct.Add("NEFlag", 0); //8 == 0-NEW, 1-EDIT dct.Add("jobno", 0); //9 int[] hiddenRows = { 1, 7, 8, 9 }; int[] readonlyrows = { 0, 1, 2, 3, 4, 5, 7, 8, 9 }; MyGridUtils.ArrangeDataGrid(dgv01, dct, hiddenRows); dgv01.RowTemplate.MinimumHeight = 28; dgv01.DefaultCellStyle.BackColor = Color.Beige; this.dgv01.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgv01.Columns[6].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; foreach (int i in readonlyrows) { dgv01.Columns[i].ReadOnly = true; this.dgv01.Columns[i].DefaultCellStyle.BackColor = Color.LightGray; this.dgv01.Columns[i].DefaultCellStyle.ForeColor = Color.Black; } dgv01.SelectionMode = DataGridViewSelectionMode.CellSelect; }
private bool SaveDataToDatabase(string kpm_id, DataGridView dgv, DbConnection con, DbTransaction trans) { bool retval = true; KeyPerformanceIndex kpi; LAST_KPI_ID = KeyPerformanceIndex.getNextKPIIndex(); int mKPIId; bool mNewFlag = false; try { for (int i = 0; i < dgv.RowCount; i++) { if (!MyGridUtils.IsColumnDataChanged(dgv.Rows[i], new List <String>() { "Description", "PrefixID", "Value", "UnitID", "ManagerID", "SP_ID", "STATUS" }, new List <String>() { "BDescription", "BPrefixID", "BValue", "BUnitID", "BManagerID", "BSP_ID", "BSTATUS" })) { continue; } //---- Check for KPI Index in the Grid-- //--------- If Empty or Null New KPI otherwise Edit if (String.IsNullOrEmpty(dgv.Rows[i].Cells["ID"].Value.ToString())) { mKPIId = LAST_KPI_ID; LAST_KPI_ID++; mNewFlag = true; } else { mKPIId = int.Parse(dgv.Rows[i].Cells["ID"].Value.ToString()); mNewFlag = false; } kpi = new KeyPerformanceIndex(); kpi.KPIID = mKPIId; kpi.KPMID = kpm_id; kpi.ManagerID = dgv.Rows[i].Cells["ManagerID"].Value.ToString(); kpi.Description = dgv.Rows[i].Cells["Description"].Value.ToString(); kpi.Prefix = dgv.Rows[i].Cells["PrefixID"].Value.ToString(); kpi.EstimateYear = dgv.Rows[i].Cells["Est.Year"].Value.ToString(); kpi.EstimateValue = Convert.ToDouble(dgv.Rows[i].Cells["Value"].Value); kpi.Unit = dgv.Rows[i].Cells["UnitID"].Value.ToString(); kpi.ServicePlanID = dgv.Rows[i].Cells["SP_ID"].Value == null ? "000" : dgv.Rows[i].Cells["SP_ID"].Value.ToString(); kpi.Status = ((dgv.Rows[i].Cells["STATUS"].Value.ToString().ToUpper() == "TRUE") ? true : false); if (mNewFlag) { kpi.InsertKPI(db, con, trans); kpi.InsertKPIEstimate(db, con, trans); } else { kpi.UpdateKPI(db, con, trans); kpi.UpdateKPIEstimate(db, con, trans); } } } catch (Exception ex) { retval = false; } return(retval); }