Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Manufacturer Convert(Manufacturer manufacturer)
- {
- var pricefileEngine = "";
- var pricefileHome = "";
- List<string> priceFiles = new List<string>();
- foreach (var file in manufacturer.Files)
- {
- if (file.Contains("BSENG_10"))
- {
- pricefileEngine = file;
- priceFiles.Add(pricefileEngine);
- }
- if (file.Contains("BS_10"))
- {
- pricefileHome = file;
- priceFiles.Add(pricefileHome);
- }
- }
- //PRICE_FILE_ENGINE
- var excelData = FileHelper.GetExcelDataSet(pricefileEngine);
- foreach (DataRow row in excelData.Tables[0].Rows)
- {
- var part = new Part();
- part.PartNumber = row[1].ToString().Trim();
- part.Description = row[2].ToString().Trim();
- //while (!string.IsNullOrWhiteSpace(row[9].ToString().Trim()))
- //{
- // part.SubPartNumber = row[9].ToString().Trim();
- //}
- decimal value;
- if (decimal.TryParse(row[5].ToString().Trim(), out value))
- {
- part.ListPrice = value;
- }
- if (decimal.TryParse(row[9].ToString().Trim(), out value))
- {
- part.DealerPrice = value; // Base
- }
- if (decimal.TryParse(row[13].ToString().Trim(), out value)) part.Weight = value;
- if (!string.IsNullOrWhiteSpace(row[14].ToString().Trim())) part.UpcCode = row[14].ToString().Trim();
- int index = manufacturer.Parts.BinarySearch(part);
- if (index < 0) manufacturer.Parts.Insert(~index, part);
- else if (part.ListPrice != manufacturer.Parts[index].ListPrice || part.DealerPrice != manufacturer.Parts[index].DealerPrice)
- MessageBox.Show("Duplicate P/N: " + part.PartNumber);
- }
- //PRICE_FILE_HOME
- var excelData2 = FileHelper.GetExcelDataSet(pricefileHome);
- foreach (DataRow row in excelData2.Tables[0].Rows)
- {
- var part = new Part();
- part.PartNumber = row[1].ToString().Trim();
- part.Description = row[2].ToString().Trim();
- if (!string.IsNullOrWhiteSpace(row[4].ToString().Trim()))
- {
- part.SubPartNumber = row[4].ToString().Trim();
- }
- decimal value;
- if (decimal.TryParse(row[5].ToString().Trim(), out value))
- {
- part.ListPrice = value;
- }
- if (decimal.TryParse(row[9].ToString().Trim(), out value))
- {
- part.DealerPrice = value; // Base
- }
- if (decimal.TryParse(row[12].ToString().Trim(), out value)) part.Weight = value;
- if (!string.IsNullOrWhiteSpace(row[13].ToString().Trim())) part.UpcCode = row[13].ToString().Trim();
- int index = manufacturer.Parts.BinarySearch(part);
- if (index < 0) manufacturer.Parts.Insert(~index, part);
- else if (part.ListPrice != manufacturer.Parts[index].ListPrice || part.DealerPrice != manufacturer.Parts[index].DealerPrice)
- MessageBox.Show("Duplicate P/N: " + part.PartNumber);
- }
- //MessageBox.Show("Number of files converted: " + count);
- return manufacturer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement