Esempio n. 1
0
        public int newBus(addBusBE user)
        {
            SqlConnection con = new SqlConnection(conn);

            con.Open();
            SqlCommand cmd = new SqlCommand("usp_InsertBus", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@bus_id", user.bus_no);
            cmd.Parameters.AddWithValue("@name", user.bus_name);
            cmd.Parameters.AddWithValue("@bus_type", user.bus_type);

            try
            {
                cmd.ExecuteNonQuery();
                return(1);
            }

            catch
            {
                return(-1);

                throw;
            }

            finally
            {
                con.Close();
                con.Dispose();
            }
        }
Esempio n. 2
0
        public int BalAddBus(addBusBE a)
        {
            DAL.InsertBus obj   = new DAL.InsertBus();
            int           error = obj.newBus(a);

            return(error);
        }
Esempio n. 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string confirmValue = Request.Form["confirm_value"];

            if (confirmValue == "Yes" && txtBusID.Text != "" && txtBusName.Text != "")
            {
                addBusBE obj = new addBusBE();
                obj.bus_no   = txtBusID.Text;
                obj.bus_name = txtBusName.Text;
                obj.bus_type = drpBusType.SelectedItem.Value;
                MasterBAL obj1  = new MasterBAL();
                int       error = obj1.BalAddBus(obj);

                if (error == 1)
                {
                    string script = "alert('Bus Added Successfully');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", script, true);

                    txtBusID.Text            = "";
                    txtBusName.Text          = "";
                    drpBusType.SelectedIndex = 0;
                }
                else
                {
                    string script = "alert('Bus Already Exists!!');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", script, true);

                    txtBusID.Text            = "";
                    txtBusName.Text          = "";
                    drpBusType.SelectedIndex = 0;
                }
            }
            else
            {
                string script = "alert('Fill All Fields!!!');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", script, true);

                txtBusID.Text            = "";
                txtBusName.Text          = "";
                drpBusType.SelectedIndex = 0;
            }
        }