File manager - Edit - G:/PleskVhosts/indiaminerals.in/vgm.INFOFIXDEVELOPERS.COM/admin/Special_investigation.aspx.cs
Back
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; using WebApp.LIBS; using System.IO; namespace VGM.admin { public partial class Special_investigation : BasePageClass { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; SqlConnection con; SqlCommand cmd; SqlDataAdapter da; protected void Page_Load(object sender, EventArgs e) { } protected void submitButton_Click(object sender, EventArgs e) { try { da = new SqlDataAdapter("select * from registration where tag_no = '" + registration.Text + "'", cs); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { label2.Text = dt.Rows[0]["owner_name"].ToString(); label3.Text = dt.Rows[0]["owner_mobile_no"].ToString(); label4.Text = dt.Rows[0]["owner_address"].ToString(); label6.Text = dt.Rows[0]["animal_category"].ToString(); label8.Text = dt.Rows[0]["dob"].ToString(); label10.Text = dt.Rows[0]["age"].ToString(); label12.Text = dt.Rows[0]["color"].ToString(); label14.Text = dt.Rows[0]["gender"].ToString(); label16.Text = dt.Rows[0]["weight"].ToString(); label18.Text = dt.Rows[0]["species"].ToString(); label20.Text = dt.Rows[0]["disease_diagnosis"].ToString(); label22.Text = dt.Rows[0]["prognosis"].ToString(); } else { Response.Write("<script>alert('Please insert Correct Tag no.')</script>"); } } catch(Exception ex) { Response.Write("<script>alert('An error occurred: " + ex.Message + "')</script>"); } } protected void submitButton2_Click(object sender, EventArgs e) { try { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; con = new SqlConnection(cs); con.Open(); string a = "insert into investigation(Tag_no,Special_observation,Date) values (" + registration.Text + ",'" + caseHistory.Text + "','" + Convert.ToDateTime(From.Text).ToString("dd-MMM-yyyy") + "')"; cmd = new SqlCommand(a, con); cmd.ExecuteNonQuery(); Response.Write("<script>if(confirm('Data inserted successfully.')){ window.location = 'Investigation_list.aspx'; }</script>"); con.Close(); SaveToCSV(); registration.Focus(); } catch(Exception ex) { Response.Write("<script>alert('An error occurred: " + ex.Message + "')</script>"); } } private void SaveToCSV() { try { string dateTime = DateTime.Now.ToString("yyyy-MM-dd"); string time = DateTime.Now.ToString("HH:mm:ss"); string tittle = "Special Investigation"; // Get additional details (you may customize this part) string details = $"Tag no. {registration.Text} Special Investigation held"; // Combine date, time, and details in CSV format with comma delimiter string contentToSave = $"\"{dateTime}\",\"{time}\",\"{tittle}\",\"{details}\""; // Specify the path to the CSV file (including the file name) string filePath = Server.MapPath("~/data/LogData.csv"); // Check if the directory exists, if not, create it string directoryPath = Path.GetDirectoryName(filePath); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } // Check if the file exists, if not, create and add headers if (!File.Exists(filePath)) { File.WriteAllText(filePath, "Date,Time,Tittle,Details" + Environment.NewLine); } // Save the content to the file File.AppendAllText(filePath, contentToSave + Environment.NewLine); } catch (Exception ex) { Response.Write("<script>alert('An error occurred while saving to CSV: " + ex.Message + "')</script>"); } } } }
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0.05 |
proxy
|
phpinfo
|
Settings