Пример #1
0
    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));
    }
Пример #2
0
    private string updateRFQ()
    {
        String s   = new StreamReader(Request.InputStream).ReadToEnd();
        RFQ    rfq = JsonConvert.DeserializeObject <RFQ>(s);

        if (rfq.Status == "COMPLETED")
        {
            if (rfq.NoQuote)
            {
                rfq.Status = "NO QUOTE";
            }
        }

        /*Begin Transaction*/
        ConnectionManager CM = new ConnectionManager();

        Data_Base_MNG.SQL DM = CM.getDataManager();

        DM.Open_Connection("RFQ Update");
        if (!rfq_CRUD.update(rfq, ref DM))
        {
            return("ERROR:" + rfq_CRUD.ErrorMessage);
        }

        foreach (RFQEAV rfqEAVLocal in rfq.RfqEAV)
        {
            if (!rfqEAV_CRUD.update(rfqEAVLocal, ref DM))
            {
                return("ERROR:" + rfqEAV_CRUD.ErrorMessage);
            }

            if (!rfqDetail_CRUD.deleteByParentID(rfqEAVLocal.Id, ref DM))
            {
                return("ERROR:" + rfqDetail_CRUD.ErrorMessage);
            }

            foreach (RFQDetail rfqDetailCurrent in rfqEAVLocal.RfqDetail)
            {
                rfqDetailCurrent.RfqEAVKey = rfqEAVLocal.Id;
                if (!rfqDetail_CRUD.create(rfqDetailCurrent, ref DM))
                {
                    return("ERROR:" + rfqDetail_CRUD.ErrorMessage);
                }
            }
        }
        if (!rfqACR_CRUD.deleteByParentID(rfq.Id, ref DM))
        {
            return("ERROR:" + rfqACR_CRUD.ErrorMessage);
        }
        foreach (RFQACR currentACR in rfq.RfqAcr)
        {
            currentACR.RfqHeaderKey = rfq.Id;
            if (!rfqACR_CRUD.create(currentACR, ref DM))
            {
                return("ERROR:" + rfqACR_CRUD.ErrorMessage);
            }
        }

        DM.CommitTransaction();
        DM.Close_Open_Connection();

        if (DM.ErrorOccur)
        {
            return("ERROR:" + DM.Error_Mjs);
        }

        return(getRFQbyID(rfq.Id));
    }
Пример #3
0
    public bool saveRFQ()
    {
        RFQ rfq = new RFQ();
        //lblPartNumber.Text

        //if(rfq.NoQuote)
        //     rfq.ReasonNoQuote = txtReasonNoQuote.Text;
        // else
        //     rfq.ReasonNoQuote = "";

        //rfq.BomDetailId = long.Parse(lblBOMDetailID.Text);
        //rfq.SupplierId = long.Parse(hiddenSupplierID.Value);
        //rfq.RfqNumber = lblRFQNumber.Text;
        //rfq.MarketSectorID = (long)ViewState["MarketSectoryID"];

        //rfq.CreatedBy = hiddenCreatedBy.Value;


        //rfq.SentAttachmentsFolder = hiddenSentAttachmentsFolder.Value;

        //rfq.SentToVendor = (DateTime)ViewState["SentToVendor"];

        string folderVendorAttachments = (string)Session["RFQATTACHMENTSFOLDERINBOX"];

        if (folderVendorAttachments != null)
        {
            rfq.InboxAttachmentsFolder = folderVendorAttachments;
        }
        else
        {
            rfq.InboxAttachmentsFolder = hiddenInboxAttachments.Value;
        }
        Session.Remove("RFQATTACHMENTSFOLDERINBOX");

        //List<RFQACR> rfqACRList = uscRfqACR.getEntity();

        ConnectionManager CM = new ConnectionManager();

        Data_Base_MNG.SQL DM = CM.getDataManager();

        /*Begin Transaction*/
        DM.Open_Connection("RFQ Save");


        rfq.Status = "IN PROGRESS";
        rfq.Id     = this.rfq.Id;
        if (!rfqCRUD.update(rfq, ref DM))
        {
            Navigator.goToPage("~/Error.aspx", "ERROR:" + rfqCRUD.ErrorMessage);
            return(false);
        }

        foreach (RFQEAV rfqEAVLocal in rfq.RfqEAV)
        {
            if (rfqEAV_CRUD.update(rfqEAVLocal, ref DM))
            {
                Navigator.goToPage("~/Error.aspx", "ERROR:" + rfqDetailCRUD.ErrorMessage);
                return(false);
            }
            //if (txtSGAProfit.Text.Trim() != "") rfq.SgAProfit = float.Parse(txtSGAProfit.Text);
            //if (txtPackingCostUnit.Text.Trim() != "") rfq.PackingPerUnit = float.Parse(txtPackingCostUnit.Text);
            //if (txtAssemblyCostUnit.Text.Trim() != "") rfq.AssemblyCostPerUnit = float.Parse(txtAssemblyCostUnit.Text);

            if (!rfqDetailCRUD.deleteByParentID(rfqEAVLocal.Id, ref DM))
            {
                Navigator.goToPage("~/Error.aspx", "ERROR:" + rfqDetailCRUD.ErrorMessage);
                return(false);
            }
        }
        if (!rfqACRCRUD.deleteByParentID(rfq.Id, ref DM))
        {
            Navigator.goToPage("~/Error.aspx", "ERROR:" + rfqACRCRUD.ErrorMessage);
            return(false);
        }

        foreach (RFQEAV rfqEAVLocal in rfq.RfqEAV)
        {
            foreach (RFQDetail detail in rfqEAVLocal.RfqDetail)
            {
                detail.RfqEAVKey = rfqEAVLocal.Id;
                if (!rfqDetailCRUD.create(detail, ref DM))
                {
                    Navigator.goToPage("~/Error.aspx", "ERROR:" + rfqDetailCRUD.ErrorMessage);
                    return(false);
                }
            }
        }
        //foreach (RFQACR detail in rfqACRList)
        //{
        //    detail.RfqHeaderKey = this.rfq.Id;
        //    if (!rfqACRCRUD.create(detail, ref DM))
        //    {
        //        Navigator.goToPage("~/Error.aspx", "ERROR:" + rfqACRCRUD.ErrorMessage);
        //        return false;
        //    }
        //}

        DM.CommitTransaction();
        DM.Close_Open_Connection();

        if (DM.ErrorOccur)
        {
            Navigator.goToPage("~/Error.aspx", "ERROR:" + DM.Error_Mjs);
            return(false);
        }

        return(true);
    }