/// <summary> /// Fills PayHead in datagridview on cell begin edit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvSalaryPackage_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { try { DataTable dtbl = new DataTable(); PayHeadSP SPPayHead = new PayHeadSP(); if (dgvSalaryPackage.CurrentCell.ColumnIndex == dgvSalaryPackage.Columns["dgvcmbPayHead"].Index) { dtbl = SPPayHead.PayHeadViewAll(); if (dtbl.Rows.Count < 2) { DataRow dr = dtbl.NewRow(); dr[0] = 0; dr[1] = 0; dtbl.Rows.InsertAt(dr, 0); } if (dgvSalaryPackage.RowCount > 1) { int inGridRowCount = dgvSalaryPackage.RowCount; for (int inI = 0; inI < inGridRowCount - 1; inI++) { if (inI != e.RowIndex) { int inTableRowcount = dtbl.Rows.Count; for (int inJ = 0; inJ < inTableRowcount; inJ++) { if (dgvSalaryPackage.Rows[inI].Cells["dgvcmbPayHead"].Value != null && dgvSalaryPackage.Rows[inI].Cells["dgvcmbPayHead"].Value.ToString() != string.Empty) { if (dtbl.Rows[inJ]["payHeadId"].ToString() == dgvSalaryPackage.Rows[inI].Cells["dgvcmbPayHead"].Value.ToString()) { dtbl.Rows.RemoveAt(inJ); break; } } } } } } DataGridViewComboBoxCell dgvccPayHead = (DataGridViewComboBoxCell)dgvSalaryPackage[dgvSalaryPackage.Columns["dgvcmbPayHead"].Index, e.RowIndex]; dgvccPayHead.DataSource = dtbl; dgvccPayHead.ValueMember = "payHeadId"; dgvccPayHead.DisplayMember = "payHeadName"; } } catch (Exception ex) { formMDI.infoError.ErrorString = "SPC25:" + ex.Message; } }
/// <summary> /// Function to fill PayHead combobox /// </summary> public void GridPayHeadFill() { try { PayHeadSP SPPayHead = new PayHeadSP(); DataTable dtblPayHead = new DataTable(); dtblPayHead = SPPayHead.PayHeadViewAll(); DataRow drrow = dtblPayHead.NewRow(); dtblPayHead.Rows.InsertAt(drrow, 0); dgvcmbPayHead.DataSource = dtblPayHead; dgvcmbPayHead.ValueMember = "payHeadId"; dgvcmbPayHead.DisplayMember = "payHeadName"; } catch (Exception ex) { formMDI.infoError.ErrorString = "SPC7:" + ex.Message; } }
/// <summary> /// Function to fill PayHead combobox /// </summary> public void PayHeadComboFill() { try { PayHeadSP spPayHead = new PayHeadSP(); DataTable dtblPayHead = spPayHead.PayHeadViewAll(); DataRow dr = dtblPayHead.NewRow(); dr[2] = "All"; dtblPayHead.Rows.InsertAt(dr, 0); cmbPayHead.DataSource = dtblPayHead; cmbPayHead.ValueMember = "payHeadId"; cmbPayHead.DisplayMember = "payHeadName"; } catch (Exception ex) { formMDI.infoError.ErrorString = "PHR:1 " + ex.Message; } }