Click here to Skip to main content
15,900,906 members

Comments by afiqdoherty (Top 9 by date)

afiqdoherty 19-Sep-16 23:53pm View    
SOOO????
afiqdoherty 19-Sep-16 23:53pm View    
thanks for the suggestion. already tried it, but didn't work out :'(
afiqdoherty 19-Sep-16 22:45pm View    
Deleted
i just asking for error cause if you guys have experience with this situation,

and F.U btw,
afiqdoherty 19-Sep-16 22:16pm View    
#region UPLOAD FORM FILLER
DataSet ds = new DataSet();
if (Request.Files["FileRawMaterial"].ContentLength > 0)
{
   string fileExtension = System.IO.Path.GetExtension(Request.Files["FileRawMaterial"].FileName);

if (fileExtension == ".xls" || fileExtension == ".xlsx")
{
   string fileLocation = ConfigurationManager.AppSettings["fileserver"] + DateTime.Now.Year + "\\BulkUpload\\";
                        
  if (!Directory.Exists(fileLocation))
  {
     Directory.CreateDirectory(fileLocation);
  }

 fileLocation = ConfigurationManager.AppSettings["fileserver"] + DateTime.Now.Year + "\\BulkUpload\\" + Request.Files["FileRawMaterial"].FileName;

if (System.IO.File.Exists(fileLocation))
{
  System.IO.File.Delete(fileLocation);
}

Request.Files["FileRawMaterial"].SaveAs(fileLocation);

string excelConnectionString = null;

//connection String for xls file format.
if (fileExtension == ".xls")
{
   excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
}

//connection String for xlsx file format.
else if (fileExtension == ".xlsx")
{
   excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
}

//Create Connection to Excel work book and add oledb namespace
System.Data.OleDb.OleDbConnection excelConnection = new System.Data.OleDb.OleDbConnection(excelConnectionString);

excelConnection.Open();

DataTable dt = new DataTable();

//edit page
dt = excelConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
                    
if (dt == null)
{
   return null;
}

String[] excelSheets = new String[dt.Rows.Count];

int t = 0;

//excel data saves in temp file here.
foreach (DataRow row in dt.Rows)
{
    excelSheets[t] = row["TABLE_NAME"].ToString();
    t++;
}

string query = string.Format("Select * from [{0}]", excelSheets[0]);
using (System.Data.OleDb.OleDbDataAdapter dataAdapter = new System.Data.OleDb.OleDbDataAdapter(query, excelConnection))
{
    dataAdapter.Fill(ds);
}

excelConnection.Close();

}
if (fileExtension.ToString().ToLower().Equals(".xml"))
{
   string fileLocation = ConfigurationManager.AppSettings["fileserver"] + DateTime.Now.Year + "\\BulkUpload\\";

if (!Directory.Exists(fileLocation))
{
    Directory.CreateDirectory(fileLocation);
}

fileLocation = ConfigurationManager.AppSettings["fileserver"] + DateTime.Now.Year + "\\BulkUpload\\" + Request.Files["FileRawMaterial"].FileName;

if (System.IO.File.Exists(fileLocation))
{
    System.IO.File.Delete(fileLocation);
}
Request.Files["FileUpload"].SaveAs(fileLocation);
System.Xml.XmlTextReader xmlreader = new System.Xml.XmlTextReader(fileLocation);
                       
      ds.ReadXml(xmlreader);
      xmlreader.Close();
}

 if (objUpdateFinishProductCompleteForm.FinishProductCompleteFormNew.Manufacturerbrn == null)
 {
      SSO_id = MyCOOApps.CommonFunction.Common.readSSOToken();
      FinishProductCompleteForm CompanyBRN = FinishProductCompleteFormDAL.GetCompanyBRN(SSO_id);

                        objUpdateFinishProductCompleteForm.FinishProductCompleteFormNew.Manufacturerbrn = CompanyBRN.Manufacturerbrn;
}

 string checkInvoice = null;

 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
 {
    if (ds.Tables[0].Rows[i][0] == null)
    {
       checkInvoice = "no invoice";
       break;
    }
 }

if (checkInvoice == null)
{
                        objUpdateFinishProductCompleteForm.FinishProductCompleteFormNew.UserIDint = INTuserID.UserIDint;
                        
FinishProductCompleteForm objFormFiller = FinishProductCompleteFormDAL.uploadFormFiller(ds, objUpdateFinishProductCompleteForm.FinishProductCompleteFormNew);

}

if (checkInvoice == "no invoice")
{
   objUpdateFinishProductCompleteForm.SearchRM = "showBulkUploadEDIT";

    ModelS
afiqdoherty 8-Sep-16 0:26am View    
yup, still giving the same error :(