protected void btnAdd_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrueVoterConnectionString"].ConnectionString); SqlCommand cmd = new SqlCommand(); try { if (FileId.HasFile) { string path = ""; path = Server.MapPath("File_Upload"); path = path + "\\" + FileId.FileName; string aa = FileId.FileName; string[] fileEx = aa.Split('.'); string fileExtention = fileEx[1].ToString(); if (fileExtention == "xls" || fileExtention == "xlsx") { if (File.Exists(path)) { File.Delete(path); FileId.SaveAs(path); } else { FileId.SaveAs(path); } string sheetName = aa.Substring(0, 31); // excelSubject = "ControlChart"; string sheetcheck = sheetName.Substring(29, 2); if (sheetcheck == "Co") { string strQuery = "SELECT * FROM [" + sheetName + "$]"; DataSet dscount = GetDataTable(strQuery); FetchQuestion(dscount); } else { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) Control Chart file only.. ')</Script>"); } } else { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) file only')</Script>"); } } else { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) file only')</Script>"); } } catch { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) Control Chart file only.. ')</Script>"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (ddlDistirct.SelectedIndex > 0 && ddlLocalBody.SelectedIndex > 0 && ddlLocalBodytype.SelectedIndex > 0) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrueVoterConnectionString"].ConnectionString); SqlCommand cmd = new SqlCommand(); try { if (FileId.HasFile) { string path = ""; path = Server.MapPath("File_Upload"); path = path + "\\" + FileId.FileName; string aa = FileId.FileName; string[] fileEx = aa.Split('.'); string fileExtention = fileEx[1].ToString(); if (fileExtention == "xls" || fileExtention == "xlsx") { if (File.Exists(path)) { File.Delete(path); FileId.SaveAs(path); } else { FileId.SaveAs(path); } if (fileEx[0].ToString() == "BoothAdd") { string strQuery = "SELECT * FROM [BoothAdd$]"; DataSet dscount = GetDataTable(strQuery); GetRefMoNo(); FetchQuestion(dscount); } else { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) Booth Address file only.. ')</Script>"); } } } else { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) file only')</Script>"); } } catch { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) Booth Address file only.. ')</Script>"); } } else { Response.Write("<Script>alert('Please Select All Details')</Script>"); } }
protected void btnAdd_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand(); try { if (FileId.HasFile) { string path = ""; path = Server.MapPath("File_Upload"); path = path + "\\" + FileId.FileName; string aa = FileId.FileName; string[] fileEx = aa.Split('.'); string fileExtention = fileEx[1].ToString(); if (fileExtention == "xls" || fileExtention == "xlsx") { if (File.Exists(path)) { File.Delete(path); FileId.SaveAs(path); } else { FileId.SaveAs(path); } if (fileEx[0].ToString() == "StandardRates") { string strQuery = "SELECT * FROM [StandardRates$]"; DataSet dscount = GetDataTable(strQuery); FetchQuestion(dscount); } else { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) StandardRates file only.')</Script>"); } } else { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) file only..')</Script>"); } } else { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) file only...')</Script>"); } } catch { Response.Write("<Script>alert('Please upload .xls or .xlsx(Excel WorkBook) StandardRates file only....')</Script>"); } }