private bool CheckBTN(string BTN) { try { bool bFalse = false; LeadsBL ObjLeads = new LeadsBL(); DataSet dsLeads = new DataSet(); if (Session["LeadBTNs"] == null) { dsLeads = ObjLeads.LeadsCheckBTN(); Session["LeadBTNs"] = dsLeads; } else { dsLeads = (DataSet)Session["LeadBTNs"]; } DataView dv = new DataView(); DataTable dt = new DataTable(); dv = dsLeads.Tables[0].DefaultView; dv.RowFilter = "Phone=" + BTN + ""; dt = dv.ToTable(); if (dt.Rows.Count > 0) { bFalse = true; } return bFalse; } catch (Exception ex) { throw ex; } }
protected void btnSubmit_Click(object sender, EventArgs e) { LeadsBL ObjLeads = new LeadsBL(); DataSet dsLeads = new DataSet(); dsLeads = ObjLeads.LeadsCheckBTN(); Session["LeadBTNs"] = dsLeads; string FILENAME = string.Empty; string OpenPath = string.Empty; string SaveLoc = string.Empty; string FileExt = string.Empty; string hp = string.Empty; string sLoc = string.Empty; ArrayList RowNo = new ArrayList(); ArrayList ColNo = new ArrayList(); ArrayList SArray = new ArrayList(); FilesBL objFilesBL = new FilesBL(); IDataReader IdataReader = null; if (Page.IsValid) { try { FileExt = System.IO.Path.GetExtension(fuAttachments.PostedFile.FileName); //Get The Ext of File //FileName = Server.MapPath(".") + fuAttachments.PostedFile.FileName; if (FileExt != ".xls") { if (FileExt != ".xlsx") { lblErrorMsg.Text = "You have Selected a Wrong File.Kindly Select Excel File"; //grdErrors.DataSource = null; //grdErrors.DataBind(); return; } } if (fuAttachments.HasFile) { OpenPath = fuAttachments.PostedFile.FileName; FILENAME = OpenPath; if (FILENAME.Contains("\\")) { string[] strFile = FILENAME.Split('\\'); int max = strFile.Length - 1; FILENAME = strFile[max].ToString(); } ViewState["FileName"] = FILENAME; SaveLoc = Server.MapPath("LeadsUpload\\"); if (System.IO.Directory.Exists(SaveLoc) == false) { // Try to create the directory. System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(SaveLoc); } SaveLoc = Server.MapPath("LeadsUpload\\" + FILENAME); fuAttachments.PostedFile.SaveAs(SaveLoc); Session["SaveLocation"] = SaveLoc; Session["FileName"] = FILENAME; IdataReader = objFilesBL.Get_FileByFileName(FILENAME); while (IdataReader.Read()) { lblErrorMsg.Text = "Leads File Already Exists. Please Upload a new file"; btnUpload.Text = "Upload"; return; } ReadExcelData(SaveLoc); } else { btnSubmit.Text = "Process"; btnSubmit.Enabled = true; btnUpload.Enabled = false; } } catch (Exception ex) { throw ex; //bool rethrow = ExceptionPolicy.HandleException(ex, ConstantClass.StrCRMUIPolicy); //if (rethrow) // throw; //Redirecting to error message page //Response.Redirect(ConstantClass.StrErrorPageURL); } } divresults.Visible = true; }