//gridadded public DataGridView getProjectlistGrid(int stat) { DataGridView empGgrid = new DataGridView(); try { DataGridViewCheckBoxColumn colChk = new DataGridViewCheckBoxColumn(); colChk.Width = 50; colChk.Name = "Select"; colChk.HeaderText = "Select"; colChk.ReadOnly = false; DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle1.BackColor = System.Drawing.Color.LightSeaGreen; dataGridViewCellStyle1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; empGgrid.EnableHeadersVisualStyles = false; empGgrid.AllowUserToAddRows = false; empGgrid.AllowUserToDeleteRows = false; empGgrid.BackgroundColor = System.Drawing.SystemColors.GradientActiveCaption; empGgrid.BorderStyle = System.Windows.Forms.BorderStyle.None; empGgrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; empGgrid.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; empGgrid.ColumnHeadersHeight = 27; empGgrid.RowHeadersVisible = false; empGgrid.Columns.Add(colChk); ProjectHeaderDB phdb = new ProjectHeaderDB(); List <projectheader> PHList = new List <projectheader>(); if (stat == 0) { PHList = phdb.getFilteredProject(); } else { PHList = phdb.getFilteredProject().Where(x => x.ProjectStatus == stat).ToList(); } empGgrid.DataSource = PHList; } catch (Exception ex) { } return(empGgrid); }
public static void fillprojectCombo(System.Windows.Forms.ComboBox cmb) { cmb.Items.Clear(); try { ProjectHeaderDB projectdb = new ProjectHeaderDB(); List <projectheader> project = projectdb.getFilteredProjectHeader("", 6); foreach (projectheader poh in project) { if (poh.Status == 1) { cmb.Items.Add(poh.ProjectID); } } } catch (Exception ex) { MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } }
//Project List In GridView public DataGridView getGridViewForProjectList() { DataGridView grdCust = new DataGridView(); try { string[] strColArr = { "ProjectID", "Description", "ProjectManager" }; DataGridViewTextBoxColumn[] colArr = { new DataGridViewTextBoxColumn(), new DataGridViewTextBoxColumn(), new DataGridViewTextBoxColumn() }; DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle1.BackColor = System.Drawing.Color.LightSeaGreen; dataGridViewCellStyle1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; grdCust.EnableHeadersVisualStyles = false; grdCust.AllowUserToAddRows = false; grdCust.AllowUserToDeleteRows = false; grdCust.BackgroundColor = System.Drawing.SystemColors.GradientActiveCaption; grdCust.BorderStyle = System.Windows.Forms.BorderStyle.None; grdCust.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; grdCust.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; grdCust.ColumnHeadersHeight = 27; grdCust.RowHeadersVisible = false; grdCust.SelectionMode = DataGridViewSelectionMode.FullRowSelect; DataGridViewCheckBoxColumn colChk = new DataGridViewCheckBoxColumn(); colChk.Width = 50; colChk.Name = "Select"; colChk.HeaderText = "Select"; colChk.ReadOnly = false; grdCust.Columns.Add(colChk); foreach (string str in strColArr) { int index = Array.IndexOf(strColArr, str); colArr[index].Name = str; colArr[index].HeaderText = str; colArr[index].ReadOnly = true; if (index == 1) { colArr[index].Width = 300; } else { colArr[index].Width = 125; } //if (index == 2) // colArr[index].Visible = false; grdCust.Columns.Add(colArr[index]); } ProjectHeaderDB pdb = new ProjectHeaderDB(); List <projectheader> ProjList = pdb.getFilteredProjectHeader("", 6).OrderBy(proj => proj.ProjectID).ToList(); foreach (projectheader projh in ProjList) { grdCust.Rows.Add(); grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[0]].Value = projh.ProjectID; grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[1]].Value = projh.ShortDescription; grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[2]].Value = projh.ProjectManagerName; } } catch (Exception ex) { } return(grdCust); }