public void gvPlantList_OnRowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { if ((!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Header.ToString())) & (!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Footer.ToString()))) { System.Web.UI.WebControls.Label lbl = new Label(); System.Web.UI.WebControls.HiddenField hfField = new HiddenField(); try { lbl = (Label)e.Row.Cells[0].FindControl("lblBusorg_out"); if (!String.IsNullOrEmpty(lbl.Text)) { BUSINESS_ORG busorg = SQMModelMgr.LookupBusOrg(entities, SessionManager.SessionContext.ActiveCompany().COMPANY_ID, Convert.ToDecimal(lbl.Text)); if (busorg != null) { lbl.Text = busorg.ORG_NAME; } } lbl = (Label)e.Row.Cells[0].FindControl("lblStatus_out"); hfField = (HiddenField)e.Row.Cells[0].FindControl("hfStatus_out"); lbl.Text = WebSiteCommon.GetStatusString(hfField.Value); } catch { } } }
public BusinessLocation ProblemBusinessLocation() { BusinessLocation problemLocation = new BusinessLocation(); if (this.IncidentList != null && this.IncidentList.Count > 0) { INCIDENT incident = this.IncidentList[0]; if (incident.INCIDENT_TYPE == "QI") { problemLocation.Company = SQMModelMgr.LookupCompany((decimal)incident.RESP_COMPANY_ID); problemLocation.BusinessOrg = SQMModelMgr.LookupBusOrg((decimal)incident.RESP_BUS_ORG_ID); problemLocation.Plant = SQMModelMgr.LookupPlant((decimal)incident.RESP_PLANT_ID); } else { problemLocation.Company = SQMModelMgr.LookupCompany((decimal)incident.DETECT_COMPANY_ID); problemLocation.BusinessOrg = SQMModelMgr.LookupBusOrg((decimal)incident.DETECT_BUS_ORG_ID); problemLocation.Plant = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID); } } else { problemLocation.Company = this.ProbCase.COMPANY; } return(problemLocation); }
protected void AddPlant(decimal busOrgID, decimal plantID) { newLocation.BusinessOrg = SQMModelMgr.LookupBusOrg(busOrgID); newLocation.Company = SQMModelMgr.LookupCompany(newLocation.BusinessOrg.COMPANY_ID); newLocation.Plant = null; OnBusinessLocationAdd(newLocation); }
protected void lnkView_Click(object sender, EventArgs e) { LinkButton lnk = (LinkButton)sender; decimal busOrgID = Convert.ToDecimal(lnk.CommandArgument.ToString().Trim()); SessionManager.BusinessOrg = SQMModelMgr.LookupBusOrg(entities, SessionManager.SessionContext.ActiveCompany().COMPANY_ID, busOrgID); Response.Redirect("/Admin/Administrate_ViewBusOrg.aspx"); }
protected void lbSave_Click(object sender, EventArgs e) { BUSINESS_ORG bu = (BUSINESS_ORG)SessionManager.BusinessOrg; BUSINESS_ORG busOrg = null; if (!Page.IsValid) { return; } if (bu == null) { busOrg = new BUSINESS_ORG(); } else { busOrg = SQMModelMgr.LookupBusOrg(entities, SessionManager.SessionContext.ActiveCompany().COMPANY_ID, bu.BUS_ORG_ID); } bool success; decimal decVal; busOrg.ORG_NAME = GetFindControlValue("tbOrgname", hfBase, out success); busOrg.DUNS_CODE = GetFindControlValue("tbOrgLocCode", hfBase, out success); if (decimal.TryParse(GetFindControlValue("tbThreshold", hfBase, out success), out decVal)) { busOrg.THRESHOLD_AMT = decVal; } busOrg.PREFERRED_CURRENCY_CODE = GetFindControlValue("ddlCurrencyCodes", hfBase, out success); busOrg.STATUS = GetFindControlValue("ddlStatus", hfBase, out success); string sel = GetFindControlValue("ddlParentBusOrg", hfBase, out success); if (string.IsNullOrEmpty(sel)) { busOrg.PARENT_BUS_ORG_ID = Convert.ToInt32(null); } else { busOrg.PARENT_BUS_ORG_ID = Int32.Parse(sel); } busOrg = (BUSINESS_ORG)SQMModelMgr.SetObjectTimestamp((object)busOrg, SessionManager.UserContext.UserName(), busOrg.EntityState); if (bu == null) { busOrg.COMPANY_ID = SessionManager.SessionContext.ActiveCompany().COMPANY_ID; SQMModelMgr.CreateBusOrg(entities, busOrg); SessionManager.BusOrgSearchCriteria = busOrg.ORG_NAME; } else { entities.SaveChanges(); } SessionManager.BusinessOrg = busOrg; SetupPage(); }
protected void SelectBusOrg(decimal busOrgID) { newLocation.BusinessOrg = SQMModelMgr.LookupBusOrg(busOrgID); newLocation.Plant = null; lblSelBusOrg.Text = newLocation.BusinessOrg.ORG_NAME; lblSelPlant.Text = ""; pnlSelectCompany.Visible = false; if (OnBusinessLocationChange != null) { OnBusinessLocationChange(newLocation); } }
protected void PreviewFile(object sender, EventArgs e) { byte[] fileContent; if (ddlDataType.SelectedValue.Equals("")) { SetStatusMessage("You must select a file type from the drop down list"); } else if (ddlPlantSelect.SelectedIndex == 0 && ddlDataType.SelectedValue.Equals("RECEIPT")) { SetStatusMessage("You must select a Receiving Location to upload a receipt record"); } else { // validate the date in the select control periodYear = 0; periodMonth = 0; List <SETTINGS> sets = SQMSettings.SelectSettingsGroup("FILE_UPLOAD", ""); // ABW 20140805 string fileName = ddlDataType.SelectedValue.ToString() + ".TXT"; int primaryCompany = Convert.ToInt32(sets.Find(x => x.SETTING_CD == "CompanyID").VALUE); PSsqmEntities Entities = new PSsqmEntities(); BUSINESS_ORG busOrg = SQMModelMgr.LookupBusOrg(Entities, primaryCompany, "", true, false); selectedFile = tbFileSelected.Text = flUpload.FileName; int fileLen = flUpload.PostedFile.ContentLength; fileContent = new byte[Convert.ToInt32(fileLen)]; int nBytes = flUpload.PostedFile.InputStream.Read(fileContent, 0, Convert.ToInt32(fileLen)); fileDelimiter = sets.Find(x => x.SETTING_CD == "FileDelimiter1").VALUE.ToCharArray(); plantDataMultiplier = 1; //fileReader = new SQMFileReader().InitializeCSV(1, flUpload.PostedFile.FileName, fileContent, fileDelimiter, plantDataMultiplier); fileReader = new SQMFileReader().InitializeCSV(primaryCompany, fileName, fileContent, fileDelimiter, plantDataMultiplier, periodYear, periodMonth, busOrg.PREFERRED_CURRENCY_CODE); using (StreamReader sr = new StreamReader(fileReader.FileStream)) { string line; int lineNo = 0; while ((line = sr.ReadLine()) != null) { fileReader.PreviewList.Add(line); } gvPreview.DataSource = fileReader.PreviewList; gvPreview.DataBind(); gvPreview.Visible = true; gvExcelPreview.Visible = false; } } if (ddlDataType.SelectedValue.Equals("RECEIPT")) { dvPlantSelect.Style.Add("display", "inline"); } }
protected void SelectPlant(decimal plantID) { newLocation.Plant = SQMModelMgr.LookupPlant(plantID); if (newLocation.BusinessOrg == null || (newLocation.BusinessOrg.BUS_ORG_ID != newLocation.Plant.BUS_ORG_ID)) { newLocation.BusinessOrg = SQMModelMgr.LookupBusOrg((decimal)newLocation.Plant.BUS_ORG_ID); lblSelBusOrg.Text = newLocation.BusinessOrg.ORG_NAME; } lblSelPlant.Text = newLocation.Plant.PLANT_NAME; pnlSelectCompany.Visible = false; if (OnBusinessLocationChange != null) { OnBusinessLocationChange(newLocation); } }
protected void SaveBusOrg() { BUSINESS_ORG bu = (BUSINESS_ORG)SessionManager.EffLocation.BusinessOrg; BUSINESS_ORG busOrg = null; if (!Page.IsValid) { return; } if (bu == null) { busOrg = SQMModelMgr.CreateBusOrg(entities, SessionManager.EffLocation.Company.COMPANY_ID, ""); } else { busOrg = SQMModelMgr.LookupBusOrg(entities, SessionManager.EffLocation.Company.COMPANY_ID, bu.BUS_ORG_ID); } bool success; decimal decVal; busOrg.ORG_NAME = GetFindControlValue("tbOrgname", hfBase, out success); busOrg.DUNS_CODE = GetFindControlValue("tbOrgLocCode", hfBase, out success); busOrg.PREFERRED_CURRENCY_CODE = GetFindControlValue("ddlCurrencyCodes", hfBase, out success); busOrg.STATUS = GetFindControlValue("ddlStatus", hfBase, out success); string sel = GetFindControlValue("ddlParentBusOrg", hfBase, out success); if (string.IsNullOrEmpty(sel)) { busOrg.PARENT_BUS_ORG_ID = Convert.ToInt32(null); } else { busOrg.PARENT_BUS_ORG_ID = Int32.Parse(sel); } busOrg = (BUSINESS_ORG)SQMModelMgr.SetObjectTimestamp((object)busOrg, SessionManager.UserContext.UserName(), busOrg.EntityState); entities.SaveChanges(); SessionManager.EffLocation.BusinessOrg = busOrg; // SetupPage(); }
public static BusinessLocation LookupHRLocation() { if (SessionManager.UserContext.Person != null) { SessionManager.UserContext.HRLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)SessionManager.UserContext.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)SessionManager.UserContext.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)SessionManager.UserContext.Person.PLANT_ID)); } return(SessionManager.UserContext.HRLocation); }
public UserContext Initialize(string SSOID, string pwd, bool activeOnly) { SQM.Website.PSsqmEntities ctx = new PSsqmEntities(); this.LoginStatus = LoginStatus.SSOUndefined; SQM_ACCESS access = SQMModelMgr.LookupCredentials(ctx, SSOID, pwd, true); if (access != null) { string key = SQMModelMgr.GetPasswordKey(); // AW - for now, we want to allow if the password = the password OR the encrypted password string password = WebSiteCommon.Decrypt(access.PASSWORD, key); //string encrypt = WebSiteCommon.Encrypt(pwd, key); //string ss = encrypt; /* * if ((string.IsNullOrEmpty(pwd) && (SSOID.ToLower() != "admin")) || (pwd != password && pwd != access.PASSWORD)) * this.LoginStatus = LoginStatus.PasswordMismatch; */ //if (!string.IsNullOrEmpty(access.PASSWORD) && (pwd != password && pwd != access.PASSWORD)) if (pwd != password && pwd != access.PASSWORD) { this.LoginStatus = LoginStatus.PasswordMismatch; } else if (activeOnly && access.STATUS == "I") { this.LoginStatus = LoginStatus.Inactive; } else if (access.STATUS == "L") { this.LoginStatus = LoginStatus.Locked; } else { if ((this.Person = SQMModelMgr.LookupPerson(ctx, 0, access.SSO_ID, false)) == null) { this.LoginStatus = LoginStatus.PersonUndefined; } else { this.LoginStatus = LoginStatus.Success; this.HRLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID)); if (this.HRLocation.Company == null) { this.LoginStatus = LoginStatus.CompanyUndefined; } else { this.PrivList = SQMModelMgr.SelectPrivGroupPerson(this.Person.PRIV_GROUP, "COMMON"); SessionManager.EffLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID)); this.WorkingLocation = new BusinessLocation(); this.WorkingLocation = SessionManager.EffLocation; this.PlantAccessList = new List <decimal>(); this.PlantAccessList.Add(this.WorkingLocation.Plant.PLANT_ID); if (!string.IsNullOrEmpty(Person.NEW_LOCATION_CD)) { decimal plantID; string[] locs = Person.NEW_LOCATION_CD.Split(','); foreach (string locid in locs) { if (!string.IsNullOrEmpty(locid)) { if (decimal.TryParse(locid, out plantID) && plantID != this.WorkingLocation.Plant.PLANT_ID) { this.PlantAccessList.Add(plantID); } } } } access.LAST_LOGON_DT = WebSiteCommon.CurrentUTCTime(); int ctxstatus = 0; SQMModelMgr.UpdateCredentials(ctx, access, "", out ctxstatus); this.Credentials = access; this.TimeZoneID = this.HRLocation.Plant.LOCAL_TIMEZONE; this.LocalTime = !string.IsNullOrEmpty(this.TimeZoneID) ? WebSiteCommon.LocalTime(DateTime.UtcNow, this.TimeZoneID) : DateTime.UtcNow; this.Language = SQMModelMgr.LookupLanguage(ctx, "", this.Person.PREFERRED_LANG_ID.HasValue ? (int)this.Person.PREFERRED_LANG_ID : 1, false); if (SessionManager.CreateSessionContext(this) == null) { this.LoginStatus = LoginStatus.SessionError; } this.InboxReviews = 0; } } } } return(this); }
public static BusinessLocation SetIncidentLocation(PLANT plant) { return(SessionManager.IncidentLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)plant.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)plant.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)plant.PLANT_ID))); }
public UserContext Initialize(string SSOID, string pwd, bool activeOnly) { SQM.Website.PSsqmEntities ctx = new PSsqmEntities(); this.LoginStatus = LoginStatus.SSOUndefined; SQM_ACCESS access = SQMModelMgr.LookupCredentials(ctx, SSOID, pwd, true); if (access != null) { string key = SQMModelMgr.GetPasswordKey(); // AW - for now, we want to allow if the password = the password OR the encrypted password string password = WebSiteCommon.Decrypt(access.PASSWORD, key); //string encrypt = WebSiteCommon.Encrypt(pwd, key); //string ss = encrypt; /* * if ((string.IsNullOrEmpty(pwd) && (SSOID.ToLower() != "admin")) || (pwd != password && pwd != access.PASSWORD)) * this.LoginStatus = LoginStatus.PasswordMismatch; */ //if (!string.IsNullOrEmpty(access.PASSWORD) && (pwd != password && pwd != access.PASSWORD)) if (pwd != password && pwd != access.PASSWORD) { this.LoginStatus = LoginStatus.PasswordMismatch; } else if (activeOnly && access.STATUS == "I") { this.LoginStatus = LoginStatus.Inactive; } else if (access.STATUS == "L") { this.LoginStatus = LoginStatus.Locked; } else { if ((this.Person = SQMModelMgr.LookupPerson(ctx, 0, access.SSO_ID, false)) == null) { this.LoginStatus = LoginStatus.PersonUndefined; } else { this.LoginStatus = LoginStatus.Success; this.HRLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID)); if (this.HRLocation.Company == null) { this.LoginStatus = LoginStatus.CompanyUndefined; } else { SessionManager.EffLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID)); if (this.Person.PERSON_RESP.ALT_COMPANY_ID > 0) { this.WorkingLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.PERSON_RESP.ALT_COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.PERSON_RESP.ALT_BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PERSON_RESP.ALT_PLANT_ID)); } else { this.WorkingLocation = new BusinessLocation(); this.WorkingLocation = SessionManager.EffLocation; } //this.WorkingLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID)); this.PlantAccessList = new List <decimal>(); if (!string.IsNullOrEmpty(Person.NEW_LOCATION_CD)) { decimal plantID; string[] locs = Person.NEW_LOCATION_CD.Split(','); foreach (string locid in locs) { if (decimal.TryParse(locid, out plantID)) { this.PlantAccessList.Add(plantID); } } } access.LAST_LOGON_DT = WebSiteCommon.CurrentUTCTime(); int ctxstatus = 0; SQMModelMgr.UpdateCredentials(ctx, access, "", out ctxstatus); this.Credentials = access; this.TimeZoneID = WebSiteCommon.GetXlatValue("timeZone", this.Person.PREFERRED_TIMEZONE); this.DelegateList = new List <decimal>(); this.DelegateList = SQMModelMgr.SelectDelegateList(ctx, this.Person.PERSON_ID).Select(l => l.PERSON_ID).ToList(); this.EscalationAssignments = SQMModelMgr.SelectPersonEscalationList(ctx, this.Person.PERSON_ID); if (SessionManager.CreateSessionContext(this) == null) { this.LoginStatus = LoginStatus.SessionError; } this.InboxReviews = 0; this.TaskList = new List <TaskItem>(); } } } } return(this); }
protected void DisplayIssue() { tbPartNumber.Text = qualityIssue.Part.PART_NUM; tbSupplier.Text = qualityIssue.Supplier.COMPANY_NAME; gvQISamples.DataSource = qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE; gvQISamples.DataBind(); if (!qualityIssue.IsNew) { // PROB_DEFINE probDefine = new PROB_DEFINE(); // probDefine = qualityIssue.UpdateProblemDefinition(probDefine); lblIssueDate_out.Text = WebSiteCommon.LocalTime((DateTime)qualityIssue.Incident.CREATE_DT, SessionManager.UserContext.TimeZoneID).ToString(); uclSearchBar.TitleItem.Text = qualityIssue.IssueID; uclSearchBar.TitleItem.Visible = lblIssueDate_out.Visible = true; tbDateDetected.Text = WebSiteCommon.FormatDateString(WebSiteCommon.LocalTime(qualityIssue.Incident.INCIDENT_DT, SessionManager.UserContext.TimeZoneID), false); tbIssueDesc.Text = qualityIssue.Incident.DESCRIPTION; SetListSelectedTextValue(ddlQualityIssueType, qualityIssue.IssueOccur.PROBLEM_TYPE); if (!string.IsNullOrEmpty(qualityIssue.IssueOccur.SOURCE)) { rblSource.SelectedValue = qualityIssue.IssueOccur.SOURCE; } BUSINESS_ORG orginBusOrg = SQMModelMgr.LookupBusOrg((decimal)qualityIssue.Incident.BUS_ORG_ID); if (orginBusOrg == null) { lblOriginator_out.Text = qualityIssue.Incident.CREATE_BY; } else { lblOriginator_out.Text = qualityIssue.Incident.CREATE_BY + " (" + orginBusOrg.ORG_NAME + ")"; } ddlPlant.SelectedValue = qualityIssue.Incident.PLANT_ID.ToString(); ddlPlantLine.SelectedValue = qualityIssue.Incident.PLANT_ID.ToString(); if (qualityIssue.Incident.PLANT_LINE_ID > -1) { ddlPlantLine.SelectedValue = qualityIssue.Incident.PLANT_LINE_ID.ToString(); } if (qualityIssue.IssueOccur.CUSTOMER_ID > 0) { ddlCustomer.SelectedValue = qualityIssue.IssueOccur.CUSTOMER_ID.ToString(); } if (qualityIssue.IssueOccur.CUSTOMER_PLANT_ID > 0) { ddlCustomerPlant.SelectedValue = qualityIssue.IssueOccur.CUSTOMER_PLANT_ID.ToString(); } tbNCLotNum.Text = qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().LOT_NUM; tbNCContainer.Text = qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().CONTAINER_NUM; tbNCTotalQty.Text = qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().TOTAL_QTY.ToString(); tbNCSampleQty.Text = qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().INSPECT_QTY.ToString(); tbNCNonConformQty.Text = qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().INSPECT_NC_QTY.ToString(); tbTotalEstNCQty.Text = qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().TOTAL_NC_QTY.ToString(); int nRow = -1; foreach (QI_OCCUR_SAMPLE sample in qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE) { GridViewRow row = gvQISamples.Rows[++nRow]; DropDownList ddl = (DropDownList)row.FindControl("ddlPrimaryNC"); SetListSelectedTextValue(ddl, qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().PROBLEM_PRIMARY); ddl = (DropDownList)row.FindControl("ddlSecondaryNC"); SetListSelectedTextValue(ddl, qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().PROBLEM_SECONDARY); TextBox tb = (TextBox)row.FindControl("tbNCCount"); tb.Text = Math.Max(1, Convert.ToDecimal(qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().PROBLEM_COUNT)).ToString(); } tbObservations.Text = qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().SAMPLE_COMMENTS; ddlDisposition.SelectedValue = qualityIssue.IssueOccur.DISPOSITION; if (!string.IsNullOrEmpty(qualityIssue.IssueOccur.RESPONSIBLE)) { rblResponsible.SelectedValue = qualityIssue.IssueOccur.RESPONSIBLE; } cbActionRequired.Checked = (bool)qualityIssue.IssueOccur.ACTION_REQD; tbComments.Text = qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().ITEM_COMMENTS; btnPrintLabel.OnClientClick = "Popup('../Problem/QualityIssue_Label.aspx?issue=" + qualityIssue.IssueOccur.QIO_ID.ToString() + "', 'newPage', 600, 450); return false;"; } }
protected void btnUploadFile_Click(object sender, EventArgs e) { byte[] fileContent; if (ddlDataType.SelectedValue.Equals("")) { SetStatusMessage("You must select a data type from the drop down list"); } else if (ddlPlantSelect.SelectedIndex == 0 && ddlDataType.SelectedValue.Equals("RECEIPT")) { SetStatusMessage("You must select a Receiving Location to upload a receipt record"); } else { // validate the date in the select control periodYear = 0; periodMonth = 0; List <SETTINGS> sets = SQMSettings.SelectSettingsGroup("FILE_UPLOAD", ""); // ABW 20140805 int primaryCompany = Convert.ToInt32(sets.Find(x => x.SETTING_CD == "CompanyID").VALUE); PSsqmEntities Entities = new PSsqmEntities(); BUSINESS_ORG busOrg = SQMModelMgr.LookupBusOrg(Entities, primaryCompany, "", true, false); string fileName = ""; lblSummaryList.Visible = false; if (flUpload.HasFile) { btnUpload.Enabled = false; selectedFile = tbFileSelected.Text = flUpload.FileName; int fileLen = flUpload.PostedFile.ContentLength; if (fileLen < 5) { SetStatusMessage("The file does not contain relevant data: " + flUpload.FileName); return; } fileDelimiter = sets.Find(x => x.SETTING_CD == "FileDelimiter1").VALUE.ToCharArray(); plantDataMultiplier = 1; fileName = ddlDataType.SelectedValue.ToString() + ".TXT"; try { string fileType = flUpload.PostedFile.ContentType; fileContent = new byte[Convert.ToInt32(fileLen)]; int nBytes = flUpload.PostedFile.InputStream.Read(fileContent, 0, Convert.ToInt32(fileLen)); } catch { SetStatusMessage("Error encountered opening or acquiring the file: " + flUpload.FileName); return; } //fileReader = new SQMFileReader().InitializeCSV(1, flUpload.PostedFile.FileName, fileContent, fileDelimiter, plantDataMultiplier); fileReader = new SQMFileReader().InitializeCSV(primaryCompany, fileName, fileContent, fileDelimiter, plantDataMultiplier, periodYear, periodMonth, busOrg.PREFERRED_CURRENCY_CODE); if (ddlDataType.SelectedValue.Equals("RECEIPT")) { fileReader.LocationCode = SQMModelMgr.LookupPlant(Convert.ToDecimal(ddlPlantSelect.SelectedValue)).DUNS_CODE; } if (fileReader.Status < 0) { SetStatusMessage("Error encountered loading the file: " + flUpload.FileName); return; } ProcessFile(); if (ddlDataType.SelectedValue.Equals("RECEIPT")) { dvPlantSelect.Style.Add("display", "inline"); } } else { SetStatusMessage("The selected file is empty: " + flUpload.FileName); } } }