private int ImportRecordFromFile(string fname) { string strCompanyCode = ""; string strCompanyName = ""; string strCompanyTypeID = ""; string strMemberTypeID = ""; string strNetworkID = ""; string strUserID = ""; string strSecVendorID = ""; string strBuyerCompanyTypeID = ""; string strBuyerCompanyName = ""; string strVendorClass = ""; string strVendorGroup = ""; string strVendorAdd1 = ""; string strVendorAdd2 = ""; string strVendorAdd3 = ""; string strVendorAdd4 = ""; string strPostalCode = ""; string strVendorRegNum = ""; string strPhoneNumber = ""; string strEmailID = ""; string strAccountCurrency = ""; int iCount = 0; strCompanyTypeID = "2"; strMemberTypeID = "2"; if (Session["UserID"] != null) { strUserID = Session["UserID"].ToString().Trim(); SqlConnection objConn = new SqlConnection(CBSAppUtils.PrimaryConnectionString); objConn.Open(); StreamReader MyFileStream = null; strBuyerCompanyID = "180918";//"20944";//124529 for AnchorSafety changed to 180918 for JKS string fileName = ""; fileName = fname; FileInfo fi = new FileInfo(Server.MapPath(ConfigurationManager.AppSettings["UploadExcel"]) + fname); if (fi.Exists) { MyFileStream = File.OpenText(Server.MapPath(ConfigurationManager.AppSettings["UploadExcel"]) + fileName); string MyLine; int i = 1; while (MyFileStream.Peek() != -1) { i++; MyLine = MyFileStream.ReadLine(); if (i > 0) { MyLine = MyLine.Replace("\\", "").Replace("\"", ""); String[] MyArray = MyLine.Split(','); strCompanyCode = MyArray[0].ToString().Trim(); strSecVendorID = MyArray[1].ToString().Trim(); strBuyerCompanyTypeID = MyArray[2].ToString().Trim(); strBuyerCompanyName = MyArray[3].ToString().Trim(); strVendorClass = MyArray[4].ToString().Trim(); strVendorGroup = MyArray[5].ToString().Trim(); strCompanyName = MyArray[6].ToString().Trim(); strVendorAdd1 = MyArray[7].ToString().Trim(); strVendorAdd2 = MyArray[8].ToString().Trim(); strVendorAdd3 = MyArray[9].ToString().Trim(); strVendorAdd4 = MyArray[10].ToString().Trim(); strPostalCode = MyArray[11].ToString().Trim(); strVendorRegNum = MyArray[12].ToString().Trim(); strPhoneNumber = MyArray[13].ToString().Trim(); strEmailID = MyArray[14].ToString().Trim(); strAccountCurrency = MyArray[15].ToString().Trim(); if (strCompanyName.Trim() != "" && strCompanyName.ToUpper().Trim().IndexOf("VENDOR_NAME") == -1) { strNetworkID = System.Guid.NewGuid().ToString().Substring(0, 11).Trim(); int intRecordCount = 0; sqlCmd = new SqlCommand("sp_ImportRecordsFromURL_NL", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@CompanyCode", strCompanyCode); sqlCmd.Parameters.Add("@CompanyName", strCompanyName); sqlCmd.Parameters.Add("@CompanyTypeID", strCompanyTypeID); sqlCmd.Parameters.Add("@MemberTypeID", strMemberTypeID); sqlCmd.Parameters.Add("@NetworkID", strNetworkID); sqlCmd.Parameters.Add("@BuyerCompanyID", strBuyerCompanyID); sqlCmd.Parameters.Add("@UserID", 0); sqlCmd.Parameters.Add("@SecVendorID", strSecVendorID); sqlCmd.Parameters.Add("@BuyerCompanyTypeID", strBuyerCompanyTypeID); sqlCmd.Parameters.Add("@BuyerCompanyName", strBuyerCompanyName); sqlCmd.Parameters.Add("@VendorClass", strVendorClass); sqlCmd.Parameters.Add("@VendorGroup", strVendorGroup); sqlCmd.Parameters.Add("@VendorAdd1", strVendorAdd1); sqlCmd.Parameters.Add("@VendorAdd2", strVendorAdd2); sqlCmd.Parameters.Add("@VendorAdd3", strVendorAdd3); sqlCmd.Parameters.Add("@VendorAdd4", strVendorAdd4); sqlCmd.Parameters.Add("@PostalCode", strPostalCode); sqlCmd.Parameters.Add("@VendorRegNum", strVendorRegNum); sqlCmd.Parameters.Add("@PhoneNumber", strPhoneNumber); sqlCmd.Parameters.Add("@EmailID", strEmailID); sqlCmd.Parameters.Add("@AccountCurrency", strAccountCurrency); SqlParameter paramReturnValue = objComm.Parameters.Add("ReturnValue", SqlDbType.Int); paramReturnValue.Direction = ParameterDirection.ReturnValue; try { objComm.ExecuteNonQuery(); intRecordCount = Convert.ToInt32(objComm.Parameters["ReturnValue"].Value); } catch (Exception ex) { string ss = ex.Message.ToString(); } finally { objComm.Dispose(); } if (intRecordCount > 0) { iCount = iCount + 1; } strNetworkID = ""; } } } } MyFileStream.Close(); if (fi.Exists) { fi.Delete(); fi = null; } } return(iCount); }