private bool retrieveEntity() { token = (Token)Session["token"]; rfq = rfqCRUD.readById(token.SubjectKey); if (rfq != null) { supplier = supplierCRUD.readById(rfq.SupplierId); if (supplier != null) { SessionObject soSupplier = new SessionObject(); soSupplier.Content = supplier; soSupplier.Status = "forUpdate"; Session["supplierObject"] = soSupplier; List <RFQACR> rfqACR = rfqACRCRUD.readByParentID(rfq.Id); rfq.RfqAcr = rfqACR; List <RFQEAV> rfqEAVList = rfqEAVCRUD.readByParentID(rfq.Id); rfq.RfqEAV = rfqEAVList; foreach (RFQEAV rfqEAV in rfqEAVList) { System.Collections.Generic.List <RFQDetail> rfqDetail = rfqDetailCRUD.readByParentID(rfq.Id); rfqEAV.RfqDetail = rfqDetail; } SessionObject soRFQ = new SessionObject(); soRFQ.Content = rfq; soRFQ.Status = "forUpdate"; Session["rfqObject"] = soRFQ; return(true); } } return(false); }
private string getRFQbyID(long id) { RFQ rfq = rfq_CRUD.readById(id); rfq.User = user_CRUD.readById(rfq.CreatedBy); rfq.RfqAcr = rfqACR_CRUD.readByParentID(rfq.Id); rfq.RfqEAV = rfqEAV_CRUD.readByParentID(rfq.Id); foreach (RFQEAV rfqEAV in rfq.RfqEAV) { List <RFQDetail> rfqDetail = rfqDetail_CRUD.readByParentID(rfqEAV.Id); rfqEAV.RfqDetail = rfqDetail; } updateAttachmentsToBuyer(ref rfq); updateAttachmentsToVendor(ref rfq); return(JsonConvert.SerializeObject(rfq)); }
public string selectRFQ(long rfqHeaderKey, long eavKey, float newBomCost) { saveRFQSummary(); RfqCRUD rfqCRUD = new RfqCRUD(); RfqSummaryCRUD rfqSummaryCRUD = new RfqSummaryCRUD(); RFQ rfq = rfqCRUD.readById(rfqHeaderKey); //List<RFQSummary> rfqSummaryList = rfqSummaryCRUD.readByBOMDetailIDAndEAU(rfq.BomDetailId, rfqSummary.EstimatedAnnualVolume); List <RFQ> rfqList = rfqCRUD.readByBOMDetailKey(rfq.BomDetailId); RFQEAVCRUD rfqEAV_CRUD = new RFQEAVCRUD(); RFQEAV eavSelected = rfqEAV_CRUD.readById(eavKey); bomDetailCRUD bomDetailCRUD = new bomDetailCRUD(); BOMDetail bomDetail = bomDetailCRUD.readById(rfq.BomDetailId); ConnectionManager CM = new ConnectionManager(); Data_Base_MNG.SQL DM = CM.getDataManager(); List <RFQEAV> eavList = new List <RFQEAV>(); foreach (RFQ rfqObj in rfqList) { eavList.AddRange(rfqEAV_CRUD.readByParentID(rfqObj.Id)); } /*Begin Transaction*/ DM.Open_Connection("RFQ Selection"); foreach (RFQ rfqObj in rfqList) { foreach (RFQEAV eavCurrent in eavList) { if (eavCurrent.Id != eavKey && eavCurrent.RfqHeaderKey == rfqObj.Id) { eavCurrent.Status = "DISMISSED"; if (rfqObj.NoQuote == true) { eavCurrent.Status = "NO QUOTE"; } if (!rfqEAV_CRUD.update(eavCurrent, ref DM)) { return("ERROR:" + rfqEAV_CRUD.ErrorMessage); } } } if (rfqObj.Id != rfq.Id) { rfqObj.Status = "DISMISSED"; if (rfqObj.NoQuote == true) { rfqObj.Status = "NO QUOTE"; } if (!rfqCRUD.update(rfqObj, ref DM)) { return("ERROR:" + rfqCRUD.ErrorMessage); } } } if (rfq != null) { rfq.Status = "SELECTED"; if (!rfqCRUD.update(rfq, ref DM)) { return("ERROR:" + rfqCRUD.ErrorMessage); } if (eavSelected != null) { eavSelected.Status = "SELECTED"; if (!rfqEAV_CRUD.update(eavSelected, ref DM)) { return("ERROR:" + rfqEAV_CRUD.ErrorMessage); } if (bomDetail != null) { if (newBomCost > -1) { bomDetail.Cost = newBomCost; } bomDetail.Status = "Processed"; if (!bomDetailCRUD.update(bomDetail, ref DM)) { return("ERROR:" + bomDetailCRUD.ErrorMessage); } } else { DM.RollBack(); return("ERROR:There was an error retrieving BOM Detail for BomDetailKey = " + rfq.BomDetailId); } } else { DM.RollBack(); return("ERROR:There was an error retrieving EAV entity for eavKey = " + eavKey); } } else { DM.RollBack(); return("ERROR:Could not retrieve RFQ for ID = " + rfqHeaderKey); } DM.CommitTransaction(); DM.Close_Open_Connection(); if (DM.ErrorOccur) { return("ERROR:" + DM.Error_Mjs); } return(getRFQSummarybyBOMDetailID(rfq.BomDetailId)); }