/// <summary> /// Function to Update values in Route Table /// </summary> /// <param name="routeinfo"></param> /// <returns></returns> public bool RouteEditing(RouteInfo routeinfo) { bool isEdit = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RouteEditing", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@routeId", SqlDbType.Decimal); sprmparam.Value = routeinfo.RouteId; sprmparam = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar); sprmparam.Value = routeinfo.RouteName; sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal); sprmparam.Value = routeinfo.AreaId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = routeinfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = routeinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = routeinfo.Extra2; int ina = sccmd.ExecuteNonQuery(); if (ina > 0) { isEdit = true; } else { isEdit = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(isEdit); }
/// <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> /// Function to insert values to Route Table /// </summary> /// <param name="routeinfo"></param> /// <returns></returns> public decimal RouteAddParticularFields(RouteInfo routeinfo) { decimal decAreaId = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RouteAddParticularFields", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar); sprmparam.Value = routeinfo.RouteName; sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal); sprmparam.Value = routeinfo.AreaId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = routeinfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = routeinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = routeinfo.Extra2; object objRouteId = sccmd.ExecuteScalar(); if (objRouteId != null) { decAreaId = decimal.Parse(objRouteId.ToString()); } else { decAreaId = 0; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decAreaId); }
/// <summary> /// Function to get particular values from Route table based on the parameter /// </summary> /// <param name="routeId"></param> /// <returns></returns> public RouteInfo RouteView(decimal routeId) { RouteInfo routeinfo = new RouteInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RouteView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@routeId", SqlDbType.Decimal); sprmparam.Value = routeId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { routeinfo.RouteId = decimal.Parse(sdrreader[0].ToString()); routeinfo.RouteName = sdrreader[1].ToString(); routeinfo.AreaId = decimal.Parse(sdrreader[2].ToString()); routeinfo.Narration = sdrreader[3].ToString(); routeinfo.ExtraDate = DateTime.Parse(sdrreader[4].ToString()); routeinfo.Extra1 = sdrreader[5].ToString(); routeinfo.Extra2 = sdrreader[6].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(routeinfo); }
/// <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); } }
/// <summary> /// Function to Update values in Route Table /// </summary> /// <param name="routeinfo"></param> public void RouteEdit(RouteInfo routeinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RouteEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@routeId", SqlDbType.Decimal); sprmparam.Value = routeinfo.RouteId; sprmparam = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar); sprmparam.Value = routeinfo.RouteName; sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal); sprmparam.Value = routeinfo.AreaId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = routeinfo.Narration; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = routeinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = routeinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = routeinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }