private IList <ImportProUsageData> GetDataRow(DataSet ds) { string testName; string insName; string proName; decimal rate; string tName = ""; string iName = ""; string pName = ""; Test test = null; Instrument instrument = null; int rowno = 0; bool haserror; IList <ImportProUsageData> rdlist = new List <ImportProUsageData>(); foreach (DataRow dr in ds.Tables[0].Rows) { rowno++; haserror = false; testName = Convert.ToString(dr[0]).Trim(); //region name insName = Convert.ToString(dr[1]).Trim(); proName = Convert.ToString(dr[2]).Trim(); try { rate = decimal.Parse(Convert.ToString(dr[3]), System.Globalization.NumberStyles.Float); } catch { rate = 1; } ImportProUsageData rd = new ImportProUsageData(testName, insName, proName, rate, rowno); if (tName != testName) { if (!string.IsNullOrEmpty(testName)) { test = DataRepository.GetTestByName(testName); } else { test = null; } tName = testName; } if (test != null) { rd.Test = test; if (iName != insName) { if (!String.IsNullOrEmpty(insName)) { instrument = DataRepository.GetInstrumentByName(insName); } else { instrument = null; } iName = insName; } if (instrument != null) { rd.Instrument = instrument; if (!String.IsNullOrEmpty(proName)) { rd.Product = DataRepository.GetProductByName(proName); if (rd.Product == null) { haserror = true; } else if (test.IsExsistProductUsage(instrument.Id, rd.Product.Id)) { rd.IsExist = true; } } else { haserror = true; } } else { haserror = true; } } else { haserror = true; } rd.HasError = haserror; rdlist.Add(rd); } return(rdlist); }
private IList <ImportProUsageData> GetDataRow(DataSet ds) { string testName; string insName; string proName; string period; int noOfTest; decimal rate; string tName = ""; string iName = ""; bool isForTest = false; bool isForPeriod = false; bool isForInstrument = false; MasterConsumable cons = null; Test test = null; Instrument instrument = null; bool isnew = false; int rowno = 0; bool haserror; IList <ImportProUsageData> rdlist = new List <ImportProUsageData>(); List <string> con = new List <string>(); foreach (DataRow dr in ds.Tables[0].Rows) { rowno++; haserror = false; testName = Convert.ToString(dr[0]).Trim(); //region name insName = Convert.ToString(dr[1]).Trim(); proName = Convert.ToString(dr[2]).Trim(); period = Convert.ToString(dr[3]).Trim(); try { noOfTest = int.Parse(Convert.ToString(dr[4])); } catch { noOfTest = 0; } try { rate = decimal.Parse(Convert.ToString(dr[5])); } catch { rate = 1; } try { isForTest = Convert.ToBoolean(int.Parse(Convert.ToString(dr[6]))); } catch { isForTest = false; } try { isForPeriod = Convert.ToBoolean(int.Parse(Convert.ToString(dr[7]))); } catch { isForPeriod = false; } try { isForInstrument = Convert.ToBoolean(int.Parse(Convert.ToString(dr[8]))); } catch { isForInstrument = false; } ImportProUsageData rd = new ImportProUsageData(testName, insName, proName, period, noOfTest, rate, isForTest, isForPeriod, isForInstrument, rowno); if (!string.IsNullOrEmpty(Convert.ToString(dr[0]))) { SaveConsumable(Convert.ToString(dr[0])); } if (tName != testName) { if (!string.IsNullOrEmpty(testName)) { test = DataRepository.GetTestByName(testName); } else { test = null; } tName = testName; } if (test != null) { // rd.Test = test; cons = DataRepository.GetConsumableByName(testName); rd.Cons = cons; if (iName != insName) { if (!String.IsNullOrEmpty(insName)) { instrument = DataRepository.GetInstrumentByName(insName); } else { instrument = null; } iName = insName; } if (instrument != null) { rd.Instrument = instrument; if (!String.IsNullOrEmpty(proName) && !String.IsNullOrEmpty(rd.Period)) { rd.Product = DataRepository.GetProductByName(proName); if (rd.Product == null) { haserror = true; } if (!isnew) { if (cons.IsExsistUsageRatePerInst(instrument.Id, rd.Product.Id) && rd.IsForInstrument == true) { rd.IsExist = true; } } } else { haserror = true; } } // else // haserror = true; if (rd.IsForPeriod == true) { if (!String.IsNullOrEmpty(proName) && !String.IsNullOrEmpty(rd.Period)) { rd.Product = DataRepository.GetProductByName(proName); if (rd.Product == null) { haserror = true; } if (!isnew) { if (cons.IsExsistUsageRatePerPeriod(rd.Product.Id)) { rd.IsExist = true; } } } else { haserror = true; } } if (rd.IsForTest == true) { if (!String.IsNullOrEmpty(proName) && rd.NoOfTest > 0) { rd.Product = DataRepository.GetProductByName(proName); if (rd.Product == null) { haserror = true; } if (!isnew) { if (cons.IsExsistUsageRatePerPeriod(rd.Product.Id)) { rd.IsExist = true; } } } else { haserror = true; } } } else { haserror = true; } rd.HasError = haserror; rdlist.Add(rd); isnew = false; } return(rdlist); }