/// <summary> /// Function to save the new route /// </summary> public void SaveFunction() { try { RouteBll BllRoute = new RouteBll(); 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 (BllRoute.RouteCheckExistence(txtRouteName.Text.Trim(), 0, Convert.ToDecimal(cmbArea.SelectedValue.ToString())) == false) { decRoute = BllRoute.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 edit already existing route /// </summary> public void EditFunction() { try { RouteBll BllRoute = new RouteBll(); 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 (BllRoute.RouteCheckExistence(txtRouteName.Text.Trim(), decRouteId, Convert.ToDecimal(cmbArea.SelectedValue.ToString())) == false) { if (BllRoute.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); } }