File manager - Edit - G:/PleskVhosts/indiaminerals.in/vgm.INFOFIXDEVELOPERS.COM/admin/DetailForm.aspx.cs
Back
using System; using System.Collections.Generic; using System.Configuration; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using WebApp.LIBS; namespace VGM.admin { public partial class DetailForm : BasePageClass { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; protected void Page_Load(object sender, EventArgs e) { } protected void Save_Click(object sender, EventArgs e) { try { string contactNo = ContactNo.Text; if (contactNo.Length != 10 || contactNo.Length > 10 || !contactNo.All(char.IsDigit)) { ShowSweetAlert("Error", "Please provide a valid 10-digit number", "error"); return; } if (string.IsNullOrEmpty(BirthDate.Text) && string.IsNullOrEmpty(AnniversaryDate.Text)) { ShowSweetAlert("Error", "Please provide either Birthday Date or Anniversary Date", "error"); return; } using (SqlConnection connection = new SqlConnection(cs)) { connection.Open(); string DetailQuery = "INSERT INTO detailform(JoiningDate, Name, Contact_no, Address, BirthDate, AnniversaryDate) VALUES (@JoiningDate, @Name, @Contact_no, @Address, @BirthDate, @AnniversaryDate)"; using (SqlCommand command = new SqlCommand(DetailQuery, connection)) { command.Parameters.AddWithValue("@JoiningDate", Convert.ToDateTime(joiningDate.Text).ToString("dd-MMM-yyyy")); command.Parameters.AddWithValue("@Name", Name.Text); command.Parameters.AddWithValue("@Contact_no", contactNo); command.Parameters.AddWithValue("@Address", Address.Text); if (!string.IsNullOrEmpty(BirthDate.Text)) { command.Parameters.AddWithValue("@BirthDate", Convert.ToDateTime(BirthDate.Text).ToString("dd-MMM-yyyy")); } else { command.Parameters.AddWithValue("@BirthDate", DBNull.Value); } if (!string.IsNullOrEmpty(AnniversaryDate.Text)) { command.Parameters.AddWithValue("@AnniversaryDate", Convert.ToDateTime(AnniversaryDate.Text).ToString("dd-MMM-yyyy")); } else { command.Parameters.AddWithValue("@AnniversaryDate", DBNull.Value); } command.ExecuteNonQuery(); } } ShowSweetAlert("Success", "Data insert successfully", "success"); joiningDate.Text = ""; Name.Text = ""; ContactNo.Text = ""; BirthDate.Text = ""; AnniversaryDate.Text = ""; Address.Text = ""; } catch (Exception ex) { Response.Write("<script>alert('An error occurred: " + ex.Message + "')</script>"); } } protected void ShowSweetAlert(string title, string message, string icon) { string script = $@" Swal.fire({{ text: '{message}', icon: '{icon}', toast: true, position: 'top-right', showConfirmButton: false, timer: 5000, customClass: {{ popup: 'swal2-small' }} }});"; ScriptManager.RegisterStartupScript(this, GetType(), "alert", script, true); } protected void SaveWithMsg_Click(object sender, EventArgs e) { Response.Redirect("DetailGridView.aspx"); } } }
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0.09 |
proxy
|
phpinfo
|
Settings