/* This event is used to Import all suggestion in the form of CSV format*/ protected void btnUpload_Click(object sender, EventArgs e) { string Service, StrStatus; int Status; string Error = string.Empty; StoreFront ObjStoreFront = new StoreFront(); DataSet ds = new DataSet(); string strExtension; strExtension = Path.GetExtension(flUpload.Value); if (strExtension == ".CSV" || strExtension == ".csv") { string fileName; string line; string fileDir; StreamReader sr; fileDir = Server.MapPath("../StoreData/"); fileName = fileDir + "/" + Convert.ToString(DateTime.Now.Ticks) + ".txt"; flUpload.PostedFile.SaveAs(fileName); sr = File.OpenText(fileName); int recordCount = 0; while (sr.Peek() != -1) { line = sr.ReadLine(); string[] recordArray; char[] splitter = { ',' }; recordArray = line.Split(splitter); if (recordArray[0].Replace(",", "") == "ServiceName") { continue; } else { if (recordArray.Length == 2) { Service = (recordArray[0].Trim().Replace('#', ',')); StrStatus = (recordArray[1].Trim().Replace('#', ',')); if (StrStatus == "Active") { Status = 1; } else if (StrStatus == "InActive") { Status = 0; } else { Status = 1; } int Dup = ObjStoreFront.AddAdditionalServiceExcel(Service, Status); if (Dup == 0) { if (Error == "") { Error = "Duplicate Additional service - " + Service; } else { Error = Error + ", " + Service; } } recordCount++; } else { Error = "coloumn count does not match"; } } } if (Error == "") { SuccesfullMessage("Record Added successfully."); } else { ErrMessage(Error); } } else { ErrMessage("Sorry, File Format Not Supported. You can upload files in .csv format only."); } BindGrid(); }