protected void btnAdd_Click(object sender, EventArgs e) { if (Page.IsValid) { ServiceReference1.Station station = new ServiceReference1.Station(); station.Station_Name = txtNamestation.Text; station.Longtitude = Convert.ToDouble(txtLong.Text); station.Latitude = Convert.ToDouble(txtLa.Text); if (rbtn1.Checked) { station.Status = rbtn1.Text; } else { station.Status = rbtn2.Text; } ServiceReference1.Service1Client sr = new ServiceReference1.Service1Client(); if (Check_Name() == false) { ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('This station has already existed. Please check the coordinate or the name of the station again !!!');", true); } else { if (sr.Add_Stations(station) == 1) { ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Add successed !!!');", true); Reset(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('Add failed !!!');", true); } } } }
protected void btnUp_Click(object sender, EventArgs e) { if (Page.IsValid) { ServiceReference1.Station station = new ServiceReference1.Station(); station.Station_ID = ids; station.Station_Name = txtNamestation.Text; station.Longtitude = Convert.ToDouble(txtLong.Text); station.Latitude = Convert.ToDouble(txtLa.Text); if (rbtn1.Checked) { station.Status = "Active"; } if (rbtn2.Checked) { station.Status = "Block"; } if (Check_Location() == false) { ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('This station has already existed. Please check the coordinate or the name of the station again !!!');", true); } else { if (station.Status == "Block" && Check_Station() == false) { ScriptManager.RegisterStartupScript(this, GetType(), "Thông báo", "alert('There are still trains on this route. Can not Update. Please, try again !!!');", true); } else { ServiceReference1.Service1Client sr = new ServiceReference1.Service1Client(); if (sr.Update_Stations(station) == 1) { ScriptManager.RegisterStartupScript(this, GetType(), "thông báo", "alert('Update successed !!!');", true); Reset(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "thông báo", "alert('Update failed !!!');", true); } } } } }