/// <summary> /// selects user record for updation and show inspectionformat form /// </summary> private void BindUpdateInspectionFormatData() { int selectedrowindex = InspectionFormatDetails_dgv.SelectedCells[0].RowIndex; InspectionFormatVo selectedInspectionFormat = (InspectionFormatVo)InspectionFormatDetails_dgv.Rows[selectedrowindex].DataBoundItem; AddInspectionFormatMasterForm newAddForm = new AddInspectionFormatMasterForm(CommonConstants.MODE_UPDATE, selectedInspectionFormat); newAddForm.ShowDialog(this); if (newAddForm.IntSuccess > 0) { messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); InspectionFormatDetails_dgv.Rows[selectedrowindex].Selected = true; InspectionFormatDetails_dgv_CellClick(this, new DataGridViewCellEventArgs(0, selectedrowindex)); InspectionFormatDetails_dgv.FirstDisplayedScrollingRowIndex = selectedrowindex; } else if (newAddForm.IntSuccess == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } }
/// <summary> /// event to open the add screen /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Add_btn_Click(object sender, EventArgs e) { AddInspectionFormatMasterForm newAddForm = new AddInspectionFormatMasterForm(CommonConstants.MODE_ADD, null); newAddForm.ShowDialog(); if (newAddForm.IntSuccess > 0) { messageData = new MessageData("mmci00001", Properties.Resources.mmci00001, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); if (InspectionFormatDetails_dgv.Rows.Count > 0 && InspectionFormatDetails_dgv.Columns.Count > 0 && InspectionFormatDetails_dgv.Columns["colInspectionFormatId"] != null) { int searchItemId; if (newAddForm.IntSuccess > 0) { searchItemId = newAddForm.IntSuccess; } else { searchItemId = 0; } DataGridViewRow row = InspectionFormatDetails_dgv.Rows .Cast <DataGridViewRow>() .FirstOrDefault(r => r.Cells["colInspectionFormatId"].Value.ToString().Equals(searchItemId.ToString())); if (row == null) { return; } InspectionFormatDetails_dgv.Rows[row.Index].Selected = true; InspectionFormatDetails_dgv_CellClick(sender, new DataGridViewCellEventArgs(0, row.Index)); InspectionFormatDetails_dgv.FirstDisplayedScrollingRowIndex = row.Index; } } }
private void FormatCopy_cntxMnu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (string.IsNullOrEmpty(e.ClickedItem.Text) || InspectionFormatDetails_dgv.Rows.Count == 0) { return; } if (InspectionFormatDetails_dgv.SelectedRows.Count > 0) { FormatCopy_cntxMnu.Items.Clear(); this.Cursor = Cursors.WaitCursor; int selectedrowindex = InspectionFormatDetails_dgv.SelectedCells[0].RowIndex; InspectionFormatVo InspectionCopyVo = (InspectionFormatVo)InspectionFormatDetails_dgv.Rows[selectedrowindex].DataBoundItem; InspectionFormatVo inspectionInVo = new InspectionFormatVo(); inspectionInVo.InspectionFormatIdCopy = InspectionCopyVo.InspectionFormatId; inspectionInVo.InspectionFormatName = InspectionCopyVo.InspectionFormatName; AddInspectionFormatMasterForm newAddForm = new AddInspectionFormatMasterForm(CommonConstants.MODE_ADD, inspectionInVo); newAddForm.ShowDialog(); if (newAddForm.IntSuccess > 0) { messageData = new MessageData("mmci00001", Properties.Resources.mmci00001, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); if (InspectionFormatDetails_dgv.Rows.Count > 0 && InspectionFormatDetails_dgv.Columns.Count > 0 && InspectionFormatDetails_dgv.Columns["colInspectionFormatId"] != null) { int searchItemId; if (newAddForm.IntSuccess > 0) { searchItemId = newAddForm.IntSuccess; } else { searchItemId = 0; } DataGridViewRow row = InspectionFormatDetails_dgv.Rows .Cast <DataGridViewRow>() .FirstOrDefault(r => r.Cells["colInspectionFormatId"].Value.ToString().Equals(searchItemId.ToString())); if (row == null) { return; } InspectionFormatDetails_dgv.Rows[row.Index].Selected = true; InspectionFormatDetails_dgv_CellClick(sender, new DataGridViewCellEventArgs(0, row.Index)); InspectionFormatDetails_dgv.FirstDisplayedScrollingRowIndex = row.Index; } } this.Cursor = Cursors.Default; } }