File manager - Edit - G:/PleskVhosts/indiaminerals.in/vgm.INFOFIXDEVELOPERS.COM/admin/Registration_form.aspx.cs
Back
using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using WebApp.LIBS; using System.IO; namespace VGM.admin { public partial class Registration_form : BasePageClass { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; SqlConnection con; SqlCommand cd; SqlDataAdapter da; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { da = new SqlDataAdapter("select distinct(animal_name) from animal_master", cs); DataTable dt = new DataTable(); da.Fill(dt); comboBox1.DataSource = dt; comboBox1.DataTextField = "animal_name"; comboBox1.DataBind(); } } protected void button1_Click(object sender, EventArgs e) { string connectionString = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; try { using (SqlConnection con = new SqlConnection(connectionString)) { if (rbActive.Checked == false && rbDepressed.Checked == false && rbDull.Checked == false && rbOther.Checked == false) { label1.Text = "Please Select Option"; label1.Visible = true; } string condition; if (rbActive.Checked == true) { condition = "1"; } else if (rbDull.Checked == true) { condition = "2"; } else if (rbDepressed.Checked == true) { condition = "3"; } else { condition = otherText.Text; } if (chkSameAsOwner.Checked) { txtEmergencyFullName.Text = txtOwnerFullName.Text; txtEmergencyMobile.Text = txtOwnerMobile.Text; txtEmergencyAddress.Text = txtOwnerAddress.Text; } else { txtEmergencyFullName.Text = ""; txtEmergencyMobile.Text = ""; txtEmergencyAddress.Text = ""; } string status; if (check1.Checked==false) { status = "Own"; } else { status = "Admitted"; } string age = "0"; string dob = ""; DateTime d1; d1 = Convert.ToDateTime(TextBox1.Text); string insertQuery = @"INSERT INTO registration (tag_no, animal_category, animal_arrived, species, age, gender, color, weight, dob, disease_diagnosis,prognosis, owner_name, owner_mobile_no,owner_address, em_name, em_mobile_no, em_address, [condition], body_temperature,rectal_palpation, case_history,status,Date,category,assign_to) VALUES (@TagNo, @AnimalCategory, @AnimalArrived, @Species, @Age, @Gender, @Color, @Weight, @DOB, @DiseaseDiagnosis,@Prognosis, @OwnerName, @OwnerMobileNo,@owneraddress, @EmName, @EmMobileNo, @EmAddress, @Condition, @BodyTemperature,@RectalPalpation, @CaseHistory,@status,@date,@category,@assign_to)"; using (SqlCommand cmd = new SqlCommand(insertQuery, con)) { con.Open(); cmd.Parameters.AddWithValue("@TagNo", txtTagNo.Text); cmd.Parameters.AddWithValue("@AnimalCategory", comboBox1.Text); cmd.Parameters.AddWithValue("@AnimalArrived", comboBox2.Text); cmd.Parameters.AddWithValue("@Species", txtSpeciesBreed.Text); cmd.Parameters.AddWithValue("@Age", age); cmd.Parameters.AddWithValue("@Gender", comboBox3.Text); cmd.Parameters.AddWithValue("@Color", txtColorMarkings.Text); cmd.Parameters.AddWithValue("@Weight", (txtWeight.Text.Length>0? txtWeight.Text:"0")); cmd.Parameters.AddWithValue("@DOB", dob); cmd.Parameters.AddWithValue("@DiseaseDiagnosis", txtDiseaseDiagnosis.Text); cmd.Parameters.AddWithValue("@Prognosis", txtPrognosis.Text); cmd.Parameters.AddWithValue("@OwnerName", txtOwnerFullName.Text); cmd.Parameters.AddWithValue("@OwnerMobileNo", txtOwnerMobile.Text); cmd.Parameters.AddWithValue("@owneraddress", txtOwnerAddress.Text); cmd.Parameters.AddWithValue("@EmName", txtEmergencyFullName.Text); cmd.Parameters.AddWithValue("@EmMobileNo", txtEmergencyMobile.Text); cmd.Parameters.AddWithValue("@EmAddress", txtEmergencyAddress.Text); cmd.Parameters.AddWithValue("@Condition", condition); cmd.Parameters.AddWithValue("@BodyTemperature", (txtBodyTemperature.Text.Length > 0 ? txtBodyTemperature.Text : "0")); cmd.Parameters.AddWithValue("@RectalPalpation", txtRectalPalpation.Text); cmd.Parameters.AddWithValue("@CaseHistory", txtCaseHistory.Text); cmd.Parameters.AddWithValue("@status", status); cmd.Parameters.AddWithValue("@date",d1); cmd.Parameters.AddWithValue("@category", category.SelectedValue); cmd.Parameters.AddWithValue("@assign_to", AssignedTo.Text); cmd.ExecuteNonQuery(); Response.Write("<script>if(confirm('Record Inserted.')){ window.location = 'Upload.aspx?tag_no=" + txtTagNo.Text + "'; }</script>"); con.Close(); } SaveToCSV(); txtTagNo.Text = ""; comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 0; txtSpeciesBreed.Text = ""; comboBox3.Text = ""; txtColorMarkings.Text = ""; txtWeight.Text = ""; txtDiseaseDiagnosis.Text = ""; txtPrognosis.Text = ""; txtOwnerFullName.Text = ""; txtOwnerMobile.Text = ""; txtOwnerAddress.Text = ""; txtEmergencyFullName.Text = ""; txtEmergencyMobile.Text = ""; txtEmergencyAddress.Text = ""; txtBodyTemperature.Text = ""; txtRectalPalpation.Text = ""; txtCaseHistory.Text = ""; category.SelectedIndex = 0; } } 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 = "Registration"; string details = $"New Registration of Tag no. {txtTagNo.Text}"; // 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>"); } } protected void chkSameAsOwner_CheckedChanged(object sender, EventArgs e) { } } }
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0.05 |
proxy
|
phpinfo
|
Settings