/// <summary> /// On double clicking on the datagridview, It displays the details of the rack to edit or delete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvRoute_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { if (dgvRoute.Rows[e.RowIndex].Cells["dgvtxtRouteName"].Value.ToString() != "NA") { RouteSP spRoute = new RouteSP(); RouteInfo infoRoute = new RouteInfo(); infoRoute = spRoute.RouteView(Convert.ToDecimal(dgvRoute.CurrentRow.Cells["dgvtxtRouteId"].Value.ToString())); decRouteId = Convert.ToDecimal(dgvRoute.CurrentRow.Cells["dgvtxtRouteId"].Value.ToString()); txtRouteName.Text = infoRoute.RouteName; cmbArea.SelectedValue = infoRoute.AreaId.ToString(); txtNarration.Text = infoRoute.Narration; btnSave.Text = "Update"; btnDelete.Enabled = true; txtRouteName.Focus(); } else { Messages.InformationMessage("Default Route cannot update or delete"); Clear(); } } } catch (Exception ex) { MessageBox.Show("RT19" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save the new route /// </summary> public void SaveFunction() { try { RouteSP spRoute = new RouteSP(); RouteInfo infoRoute = new RouteInfo(); infoRoute.RouteName = txtRouteName.Text.Trim(); infoRoute.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); infoRoute.Narration = txtNarration.Text.Trim(); infoRoute.Extra1 = String.Empty; infoRoute.Extra2 = String.Empty; if (spRoute.RouteCheckExistence(txtRouteName.Text.Trim(), 0, Convert.ToDecimal(cmbArea.SelectedValue.ToString())) == false) { decRoute = spRoute.RouteAddParticularFields(infoRoute); { Messages.SavedMessage(); Clear(); GridFill(); if (frmCustomerobj != null) { this.Close(); } } } else { Messages.InformationMessage(" Route name already exist"); txtRouteName.Focus(); } } catch (Exception ex) { MessageBox.Show("RT4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill all Routes in datagridview based on the search key /// </summary> public void GridFill() { try { RouteSP spRoute = new RouteSP(); DataTable dtbl = new DataTable(); dtbl = spRoute.RouteSearch(txtRouteNameSearch.Text.Trim(), cmbAreaSearch.Text.ToString()); dgvRoute.DataSource = dtbl; } catch (Exception ex) { MessageBox.Show("RT3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Route combobox /// </summary> public void RouteViewForComboFill() { try { RouteSP spRoute = new RouteSP(); DataTable dtbl = spRoute.RouteViewForComboFill(); cmbRoute.DataSource = dtbl; cmbRoute.DisplayMember = "routeName"; cmbRoute.ValueMember = "routeId"; cmbRoute.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show("SORP7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the Area combobox /// </summary> public void AreaComboFill() { try { RouteSP spRoute = new RouteSP(); DataTable dtbl = new DataTable(); dtbl = spRoute.AreafillInRoute(); cmbArea.DataSource = dtbl; cmbArea.ValueMember = "areaId"; cmbArea.DisplayMember = "areaName"; cmbArea.SelectedIndex = -1; } catch (Exception ex) { MessageBox.Show("RT1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// creating a default route under the creating area /// </summary> public void RouteNACreateUnderTheArea() { try { RouteSP spRoute = new RouteSP(); RouteInfo infoRoute = new RouteInfo(); infoRoute.RouteName = "NA"; infoRoute.AreaId = decAreaId; infoRoute.Narration = txtNarration.Text.Trim(); infoRoute.Extra1 = string.Empty; infoRoute.Extra2 = string.Empty; infoRoute.ExtraDate = DateTime.Today; spRoute.RouteAdd(infoRoute); } catch (Exception ex) { MessageBox.Show("AR2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Area combobox fill for Search /// </summary> public void AreaComboFillSearch() { try { RouteSP spRoute = new RouteSP(); DataTable dtbl = new DataTable(); dtbl = spRoute.AreafillInRoute(); DataRow dr = dtbl.NewRow(); dr[1] = "All"; dtbl.Rows.InsertAt(dr, 0); cmbAreaSearch.DataSource = dtbl; cmbAreaSearch.ValueMember = "areaId"; cmbAreaSearch.DisplayMember = "areaName"; } catch (Exception ex) { MessageBox.Show("RT2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Delete the Route /// </summary> public void DeleteFunction() { try { RouteSP spRoute = new RouteSP(); if (spRoute.RouteDeleting(decRouteId) == -1) { Messages.ReferenceExistsMessage(); } else { Messages.DeletedMessage(); GridFill(); Clear(); } } catch (Exception ex) { MessageBox.Show("RT7" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit already existing route /// </summary> public void EditFunction() { try { RouteSP spRoute = new RouteSP(); RouteInfo infoRoute = new RouteInfo(); infoRoute.RouteName = txtRouteName.Text.Trim(); infoRoute.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); infoRoute.Narration = txtNarration.Text.Trim(); infoRoute.Extra1 = String.Empty; infoRoute.Extra2 = String.Empty; infoRoute.RouteId = decRouteId; if (spRoute.RouteCheckExistence(txtRouteName.Text.Trim(), decRouteId, Convert.ToDecimal(cmbArea.SelectedValue.ToString())) == false) { if (spRoute.RouteEditing(infoRoute)) { Messages.UpdatedMessage(); GridFill(); Clear(); } else if (infoRoute.RouteId == 1) { Messages.InformationMessage("Cannot update"); Clear(); txtRouteName.Focus(); } } else { Messages.InformationMessage(" Route name already exist"); txtRouteName.Focus(); } } catch (Exception ex) { MessageBox.Show("RT5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }