protected void Clear_Click(object sender, EventArgs e) { PlayerID.Text = ""; GuardianList.ClearSelection(); TeamList.ClearSelection(); FirstName.Text = ""; LastName.Text = ""; Age.Text = ""; Gender.ClearSelection(); AlbertaHealthCareNumber.Text = ""; MedicalAlertDetails.Text = ""; PlayerList.ClearSelection(); }
void insert() { using (sql) { sql.Open(); SqlCommand auth = new SqlCommand(); SqlDataAdapter data = new SqlDataAdapter(); DataSet set = new DataSet(); auth.CommandText = "select * from User_Registration where Email = '" + Email_TB.Text + "'"; auth.Connection = sql; data.SelectCommand = auth; data.Fill(set); int check = set.Tables[0].Rows.Count; sql.Close(); if (check > 0) { Email_TB.Text = ""; Invalid.Text = "Username Already Exists. Try a different one."; } else { sql.Open(); SqlCommand command = sql.CreateCommand(); command.CommandType = CommandType.Text; /*,'"+ Country_TB.SelectedValue +"'*/ command.CommandText = "insert into User_Registration values('" + Name_TB.Text + "','" + FatherName_TB.Text + "','" + DOB_TB.Text + "','" + Phone_TB.Text + "','" + Gender.SelectedValue + "','" + Address_TB.Text + "','" + Pin.Text + "','" + Email_TB.Text + "','" + Password_TB.Text + "')"; command.ExecuteNonQuery(); Success.Text = "Registration Successful !"; Name_TB.Text = ""; FatherName_TB.Text = ""; DOB_TB.Text = ""; Phone_TB.Text = ""; Gender.ClearSelection(); Address_TB.Text = ""; //Country_TB.ClearSelection(); Pin.Text = ""; Email_TB.Text = ""; Password_TB.Text = ""; PasswordCheck_TB.Text = ""; Invalid.Text = ""; sql.Close(); } } }
protected void Button1_Click(object sender, EventArgs e) { if (Name.Text != null && Price.Text != null && Selling.Text != null && Brand.SelectedItem.Value != null && Category.SelectedItem.Value != null && Sub.SelectedItem.Value != null && Gender.SelectedItem.Value != null && Description.Text != null && MetCare.Text != null && Productdtl.Text != null) { string path1 = ""; path1 = "~/Img/" + FileUpload1.FileName; FileUpload1.SaveAs(Server.MapPath(path1)); string path2 = ""; path2 = "~/Img/" + FileUpload2.FileName; FileUpload2.SaveAs(Server.MapPath(path2)); string path3 = ""; path3 = "~/Img/" + FileUpload3.FileName; FileUpload3.SaveAs(Server.MapPath(path3)); string path4 = ""; path4 = "~/Img/" + FileUpload4.FileName; FileUpload4.SaveAs(Server.MapPath(path4)); string path5 = ""; path5 = "~/Img/" + FileUpload5.FileName; FileUpload5.SaveAs(Server.MapPath(path5)); SqlCommand cmd = new SqlCommand("sp_Project", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PName", Name.Text); cmd.Parameters.AddWithValue("@PPrice", Price.Text); cmd.Parameters.AddWithValue("@PSellPrice", Selling.Text); cmd.Parameters.AddWithValue("@PBrand", Brand.SelectedItem.Value); cmd.Parameters.AddWithValue("@PCatId", Category.SelectedItem.Value); cmd.Parameters.AddWithValue("@SubCatId", Sub.SelectedItem.Value); cmd.Parameters.AddWithValue("@PGender", Gender.SelectedItem.Value); cmd.Parameters.AddWithValue("@PDesc", Description.Text); cmd.Parameters.AddWithValue("@PDetail", Productdtl.Text); cmd.Parameters.AddWithValue("@PMet", MetCare.Text); cmd.Parameters.AddWithValue("@P1", path1); cmd.Parameters.AddWithValue("@P2", path2); cmd.Parameters.AddWithValue("@P3", path3); cmd.Parameters.AddWithValue("@P4", path4); cmd.Parameters.AddWithValue("@P5", path5); if (free.Checked == true) { cmd.Parameters.AddWithValue("@free", 1.ToString()); } else { cmd.Parameters.AddWithValue("@free", 0.ToString()); } if (txtcod.Checked == true) { cmd.Parameters.AddWithValue("@COD", 1.ToString()); } else { cmd.Parameters.AddWithValue("@COD", 0.ToString()); } if (txt30.Checked == true) { cmd.Parameters.AddWithValue("@replace", 1.ToString()); } else { cmd.Parameters.AddWithValue("@replace", 0.ToString()); } con.Open(); int k = (int)cmd.ExecuteNonQuery(); if (k == 1) { Response.Write("<Script>alert('Data recorded');/<Script>"); } else { Response.Write("<Script>alert('Data not recorded');/<Script>"); } con.Close(); Name.Text = string.Empty; Price.Text = string.Empty; Selling.Text = string.Empty; Brand.ClearSelection(); Category.ClearSelection(); Sub.ClearSelection(); Gender.ClearSelection(); Description.Text = string.Empty; MetCare.Text = string.Empty; Productdtl.Text = string.Empty; } else { Response.Write("<Script>alert('Product Cannot be Added');</Script>"); } }
protected void DeletePlayer_Click(object sender, EventArgs e) { int playerid = 0; if (string.IsNullOrEmpty(PlayerID.Text)) { errormsgs.Add("Search for a player to delete"); } else if (!int.TryParse(PlayerID.Text, out playerid)) { errormsgs.Add("Player ID is invalid"); } else if (playerid < 1) { errormsgs.Add("Product ID is invalid"); } if (errormsgs.Count > 0) { LoadMessageDisplay(errormsgs, "alert alert-danger"); } else { try { PlayerController sysmgr = new PlayerController(); int rowsaffected = sysmgr.Player_Delete(playerid); if (rowsaffected > 0) { errormsgs.Add("Player has been deleted"); LoadMessageDisplay(errormsgs, "alert alert-success"); BindPlayerList(); PlayerID.Text = ""; GuardianList.ClearSelection(); TeamList.ClearSelection(); FirstName.Text = ""; LastName.Text = ""; Age.Text = ""; Gender.ClearSelection(); AlbertaHealthCareNumber.Text = ""; MedicalAlertDetails.Text = ""; PlayerList.ClearSelection(); } else { errormsgs.Add("Player has not been deleted. Player was not found."); LoadMessageDisplay(errormsgs, "alert alert-info"); BindPlayerList(); } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException.InnerException != null) { errormsgs.Add(updateException.InnerException.Message.ToString()); } else { errormsgs.Add(updateException.Message); } LoadMessageDisplay(errormsgs, "alert alert-danger"); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { errormsgs.Add(validationError.ErrorMessage); } } LoadMessageDisplay(errormsgs, "alert alert-danger"); } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }