public int BalAddRoute(addRouteBE a) { DAL.InsertBus obj = new DAL.InsertBus(); int error = obj.newRoute(a); return(error); }
public int newRoute(addRouteBE user) { SqlConnection con = new SqlConnection(conn); con.Open(); SqlCommand cmd = new SqlCommand("usp_InsertRoute", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@route_id", user.route_id); cmd.Parameters.AddWithValue("@from", user.from); cmd.Parameters.AddWithValue("@to", user.to); cmd.Parameters.AddWithValue("@cost", user.cost); try { cmd.ExecuteNonQuery(); return(1); } catch { return(-1); throw; } finally { con.Close(); con.Dispose(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes" && txtCost.Text != "" && txtRouteId.Text != "") { addRouteBE obj = new addRouteBE(); obj.route_id = txtRouteId.Text; obj.from = drpFrom.SelectedItem.Value; obj.to = drpTo.SelectedItem.Value; obj.cost = Convert.ToInt32(txtCost.Text); MasterBAL obj1 = new MasterBAL(); int error = obj1.BalAddRoute(obj); if (error == 1) { string script = "alert('Route Added Successfully');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", script, true); txtRouteId.Text = ""; txtCost.Text = ""; drpFrom.SelectedIndex = 0; drpTo.SelectedIndex = 0; } else { string script = "alert('Route Already Exists!!!');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", script, true); txtRouteId.Text = ""; txtCost.Text = ""; drpFrom.SelectedIndex = 0; drpTo.SelectedIndex = 0; } } else { string script = "alert('Fill All Fields!!!');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", script, true); txtRouteId.Text = ""; txtCost.Text = ""; drpFrom.SelectedIndex = 0; drpTo.SelectedIndex = 0; } }