/// <summary> /// insert the record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Add_btn_Click(object sender, EventArgs e) { InspectionProcessVo inspProcessVo = new InspectionProcessVo(); inspProcessVo.InspectionFormatId = FormatId; inspProcessVo.InspectionFormatCode = FormatCode; inspProcessVo.InspectionFormatName = FormatName; AddInspectionProcessForFormatForm newAddForm = new AddInspectionProcessForFormatForm(CommonConstants.MODE_ADD, inspProcessVo); newAddForm.ShowDialog(); if (newAddForm.IntSuccess > 0) { messageData = new MessageData("mmci00001", Properties.Resources.mmci00001, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(); if (InspectionProcessDetails_dgv.Rows.Count > 0 && InspectionProcessDetails_dgv.Columns.Count > 0 && InspectionProcessDetails_dgv.Columns["colInspectionProcessId"] != null) { int searchProcessId; if (newAddForm.IntSuccess > 0) { searchProcessId = newAddForm.IntSuccess; } else { return; } DataGridViewRow row = InspectionProcessDetails_dgv.Rows .Cast <DataGridViewRow>() .FirstOrDefault(r => r.Cells["colInspectionProcessId"].Value.ToString().Equals(searchProcessId.ToString())); if (row == null) { return; } InspectionProcessDetails_dgv.Rows[row.Index].Selected = true; InspectionProcessDetails_dgv_CellClick(sender, new DataGridViewCellEventArgs(0, row.Index)); InspectionProcessDetails_dgv.FirstDisplayedScrollingRowIndex = row.Index; } } }
/// <summary> /// passing update data to update form /// </summary> private void BindUpdateInspectionProcessData() { int selectedrowindex = InspectionProcessDetails_dgv.SelectedCells[0].RowIndex; InspectionProcessVo inspProcessVo = (InspectionProcessVo)InspectionProcessDetails_dgv.Rows[selectedrowindex].DataBoundItem; AddInspectionProcessForFormatForm newAddForm = new AddInspectionProcessForFormatForm(CommonConstants.MODE_UPDATE, inspProcessVo); newAddForm.ShowDialog(this); if (newAddForm.IntSuccess > 0) { messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); if (newAddForm.ReturnFormatId > 0) { FormatId = newAddForm.ReturnFormatId; } //FormDatatableFromVo(); //ComboBind(InspectionFormatId_cmb, inspectionformatDatatable, "Name", "Id"); //InspectionFormatId_cmb.SelectedValue = FormatId; GridBind(); } else if (newAddForm.IntSuccess == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); //GridBind(); } InspectionProcessDetails_dgv.Rows[selectedrowindex].Selected = true; InspectionProcessDetails_dgv_CellClick(this, new DataGridViewCellEventArgs(0, selectedrowindex)); InspectionProcessDetails_dgv.FirstDisplayedScrollingRowIndex = selectedrowindex; }
private void ProcessCopy_cntxMnu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (string.IsNullOrEmpty(e.ClickedItem.Text) || InspectionProcessDetails_dgv.Rows.Count == 0) { return; } if (InspectionProcessDetails_dgv.SelectedRows.Count > 0) { ProcessCopy_cntxMnu.Items.Clear(); this.Cursor = Cursors.WaitCursor; int selectedrowindex = InspectionProcessDetails_dgv.SelectedCells[0].RowIndex; InspectionProcessVo InspectionCopyVo = (InspectionProcessVo)InspectionProcessDetails_dgv.Rows[selectedrowindex].DataBoundItem; InspectionProcessVo inspProcessVo = new InspectionProcessVo(); inspProcessVo.InspectionFormatId = FormatId; inspProcessVo.InspectionFormatCode = FormatCode; inspProcessVo.InspectionFormatName = FormatName; inspProcessVo.InspectionProcessIdCopy = InspectionCopyVo.InspectionProcessId; inspProcessVo.InspectionProcessName = InspectionCopyVo.InspectionProcessName; AddInspectionProcessForFormatForm newAddForm = new AddInspectionProcessForFormatForm(CommonConstants.MODE_ADD, inspProcessVo); newAddForm.ShowDialog(); if (newAddForm.IntSuccess > 0) { messageData = new MessageData("mmci00001", Properties.Resources.mmci00001, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(); if (InspectionProcessDetails_dgv.Rows.Count > 0 && InspectionProcessDetails_dgv.Columns.Count > 0 && InspectionProcessDetails_dgv.Columns["colInspectionProcessId"] != null) { int searchProcessId; if (newAddForm.IntSuccess > 0) { searchProcessId = newAddForm.IntSuccess; } else { this.Cursor = Cursors.Default; return; } DataGridViewRow row = InspectionProcessDetails_dgv.Rows .Cast <DataGridViewRow>() .FirstOrDefault(r => r.Cells["colInspectionProcessId"].Value.ToString().Equals(searchProcessId.ToString())); if (row == null) { this.Cursor = Cursors.Default; return; } InspectionProcessDetails_dgv.Rows[row.Index].Selected = true; InspectionProcessDetails_dgv_CellClick(sender, new DataGridViewCellEventArgs(0, row.Index)); InspectionProcessDetails_dgv.FirstDisplayedScrollingRowIndex = row.Index; } } this.Cursor = Cursors.Default; } }