// GET: ProcurementResolve
        public ActionResult AuthorityToProceed(string TempId = null, string VendorId = null)
        {
            RFIRFPComboViewModel  response            = new RFIRFPComboViewModel();
            RFQSummaryDisplay     _response           = new RFQSummaryDisplay();
            VendorResponseBLL     _VendorResponse     = new VendorResponseBLL();
            ProcurementResolveBLL _ProcurementResolve = new ProcurementResolveBLL();
            decimal?ReqType;
            decimal _TempId = Convert.ToDecimal(TempId);

            if (TempId == null && VendorId == null)
            {
                return(RedirectToAction("Index", "Admin"));
            }
            else
            {
                _VendorResponse.TempNo       = TempId;
                _ProcurementResolve.TempID   = TempId;
                _VendorResponse.VendorId     = VendorId;
                _ProcurementResolve.VendorID = VendorId;
                _ProcurementResolve.Resolve  = "Authority To Proceed";
                _ProcurementResolve.UpdateVendorResolve();
                ViewBag.TempId   = TempId;
                ViewBag.VendorId = VendorId;
                decimal _vendorId = Convert.ToDecimal(VendorId);
                ReqType = NegotiateBLL.getRequestType(_TempId);
                if (ReqType == 2)
                {
                    response = _VendorResponse.GetRFPSummaryInfo();
                    if (response.Vendor.STATUS != "RESPONDED" && response.Vendor.STATUS != null)
                    {
                        ViewBag.Response = _VendorResponse.getNegotiatedPrice(response.Request.TEMP_ID, _vendorId);
                    }
                    return(View(response));
                }
                else
                {
                    _response = _VendorResponse.GetRFQQuotationSummaryAfter();
                    if (_response._Vendor.STATUS != "RESPONDED" && _response._Vendor.STATUS != null)
                    {
                        ViewBag.Response = _VendorResponse.getNegotiatedPrice(_response.Request.TEMP_NO, _vendorId);
                    }
                    return(View("AuthorityToProceedII", _response));
                }
            }
        }
        public ActionResult RegLetter(string TempId = null, string VendorId = null)
        {
            RFIRFPComboViewModel  response            = new RFIRFPComboViewModel();
            RFQSummaryDisplay     _response           = new RFQSummaryDisplay();
            LorVendorViewModel    _vend               = new LorVendorViewModel();
            VendorResponseBLL     _VendorResponse     = new VendorResponseBLL();
            ProcurementResolveBLL _ProcurementResolve = new ProcurementResolveBLL();
            decimal?ReqType;
            decimal _TempId = Convert.ToDecimal(TempId);

            if (TempId == null && VendorId == null)
            {
                return(RedirectToAction("Index", "Admin"));
            }
            else
            {
                _VendorResponse.TempNo       = TempId;
                _ProcurementResolve.TempID   = TempId;
                _VendorResponse.VendorId     = VendorId;
                _ProcurementResolve.VendorID = VendorId;
                _ProcurementResolve.Resolve  = "Letter of Rejection";
                _ProcurementResolve.UpdateVendorResolve();
                ViewBag.TempId   = TempId;
                ViewBag.VendorId = VendorId;
                ReqType          = NegotiateBLL.getRequestType(_TempId);
                if (ReqType == 2)
                {
                    response            = _VendorResponse.GetRFPSummaryInfo();
                    _vend.InitiatorName = response.Request.INITIATOR_NAME;
                    _vend.RefNum        = response.RefNum.REF_NO;
                    _vend.VendorName    = response.Vendor.VENDOR_NAME;
                }
                else
                {
                    _response           = _VendorResponse.GetRFQQuotationSummaryAfter();
                    _vend.InitiatorName = _response.Initiator.NAME;
                    _vend.RefNum        = _response.RefNum.REF_NO;
                    _vend.VendorName    = _response._Vendor.VENDOR_NAME;
                }
                return(View(_vend));
            }
        }
예제 #3
0
        //Retreive RFQ vendor response summary
        #region RFQ vendor response summary
        public RFQSummaryDisplay GetRFQQuotationSummaryAfter()
        {
            decimal                      _TempNo      = Convert.ToDecimal(this.TempNo);
            decimal                      VendorId     = Convert.ToDecimal(this.VendorId);
            RFQSummaryDisplay            Summary      = new RFQSummaryDisplay();
            ContactedVendorViewModel     _Vendors     = new ContactedVendorViewModel();
            List <RFQITEMViewModel>      _Item        = new List <RFQITEMViewModel>();
            List <QuotationViewModel>    Quotes       = new List <QuotationViewModel>();
            List <NegotiationsViewModel> Negotiations = new List <NegotiationsViewModel>();

            try
            {
                using (var context = new Entities())
                {
                    var getVendors = context.SOURCING_CONTACTEDVENDOR.Where(vend => vend.TEMP_NO == _TempNo && vend.VENDOR_ID == VendorId).FirstOrDefault();
                    if (getVendors != null)
                    {
                        _Vendors.VENDOR_ID              = getVendors.VENDOR_ID;
                        _Vendors.VENDOR_NAME            = getVendors.VENDOR_NAME;
                        _Vendors.AUTO_EMAIL             = getVendors.AUTO_EMAIL;
                        _Vendors.VAT                    = getVendors.VAT;
                        _Vendors.TOTALBFTAX             = getVendors.TOTALBFTAX;
                        _Vendors.GRANDTOTAL             = getVendors.GRANDTOTAL;
                        _Vendors.RESPONSE_DATE          = getVendors.RESPONSE_DATE;
                        _Vendors.ADDRESS                = getVendors.ADDRESS;
                        _Vendors.EMAIL                  = getVendors.EMAIL;
                        _Vendors.EXPECTED_DELIVERY_DATE = getVendors.EXPECTED_DELIVERY_DATE;
                        _Vendors.SUPPLIERS_QUOTE        = getVendors.SUPPLIERS_QUOTE;
                        _Vendors.PAYMENT_TERMS          = getVendors.PAYMENT_TERMS;
                        _Vendors.CONTACT_NAME           = getVendors.CONTACT_NAME;
                        _Vendors.STATUS                 = getVendors.STATUS;
                        _Vendors.NEG_STATUS             = getVendors.NEG_STATUS;
                        _Vendors.TELEPHONE              = getVendors.TELEPHONE;
                        _Vendors.VERDICT_ACCEPT_DATE    = getVendors.VERDICT_ACCEPT_DATE;
                        _Vendors.VERDICT_ISSUE_DATE     = getVendors.VERDICT_ISSUE_DATE;
                        Summary._Vendor                 = _Vendors;
                    }

                    IEnumerable <SOURCING_REQUEST_FILES> _queryFile = context.SOURCING_REQUEST_FILES.Where(f => f.SOURCE_REQ_ID == _TempNo && f.VENDORID == VendorId).ToList();
                    Summary._Files = _queryFile;

                    /*********************************************************************************************/
                    //get list from negotiation table, then iteriate items through the list.
                    var getItems = context.SOURCING_RFQ_ITEM.Where(it => it.TEMP_NO == _TempNo).ToList();
                    var getQuotesFromNegTable = context.SOURCING_NEGOTIATIONS.Where(m => m.TEMP_ID == _TempNo && m.VENDOR_ID == VendorId).OrderBy(m => m.NEG_NO).ToList();
                    foreach (var _quote in getQuotesFromNegTable)
                    {
                        if (getItems != null)
                        {
                            foreach (var singleItem in getItems)
                            {
                                var getQuotes = context.SOURCING_NEG_PRICE.Where(it => it.ITEM_NO == singleItem.ITEM_NO && it.NEG_NO == _quote.NEG_NO).FirstOrDefault();
                                if (getQuotes != null)
                                {
                                    _Item.Add(new RFQITEMViewModel
                                    {
                                        ID           = getQuotes.ID,
                                        QUANTITY     = singleItem.QUANTITY,
                                        UNIT_OF_MEAS = singleItem.UNIT_OF_MEAS,
                                        DESCRIPTION  = singleItem.DESCRIPTION,
                                        ITEM_NO      = singleItem.ITEM_NO,
                                        UNIT_PRICE   = getQuotes.UNIT_PRICE,
                                        TOTAL_PRICE  = getQuotes.TOTAL_PRICE,
                                        NegNum       = _quote.NEG_NO
                                    });
                                }
                            }
                        }

                        Negotiations.Add(new NegotiationsViewModel
                        {
                            TOTAL_AMT   = _quote.TOTAL_AMT,
                            GRANDTOTAL  = _quote.GRANDTOTAL,
                            VAT         = _quote.VAT,
                            VATVALUE    = _quote.VATVALUE,
                            NEG_NO      = _quote.NEG_NO,
                            NEGOTIATOR  = _quote.NEGOTIATOR,
                            RESPONSE_NO = _quote.RESPONSE_NO,
                            STATUS      = _quote.STATUS,
                            TEMP_ID     = _quote.TEMP_ID,
                            RES_DATE    = _quote.RES_DATE,
                            VENDOR_ID   = _quote.VENDOR_ID,
                            NegItems    = _Item
                        });
                    }

                    Summary._Negotiations = Negotiations;

                    /*********************************************************************************************/
                    //get items
                    //var getItems = context.SOURCING_RFQ_ITEM.Where(it => it.TEMP_NO == _TempNo).ToList();
                    //if (getItems != null)
                    //{
                    //    foreach (var singleItem in getItems)
                    //    {
                    //        var getQuotes = context.SOURCING_RFQ_QUOTATION.Where(it => it.ITEM_NO == singleItem.ITEM_NO && it.VENDOR_ID == VendorId).FirstOrDefault();
                    //        _Item.Add(new RFQITEMViewModel
                    //        {
                    //            QUANTITY = singleItem.QUANTITY,
                    //            UNIT_OF_MEAS = singleItem.UNIT_OF_MEAS,
                    //            DESCRIPTION = singleItem.DESCRIPTION,
                    //            ITEM_NO = singleItem.ITEM_NO,
                    //            UNIT_PRICE = getQuotes.UNIT_PRICE,
                    //            TOTAL_PRICE = getQuotes.TOTAL_PRICE
                    //        });
                    //    }
                    //    Summary.Items = _Item;
                    //}

                    var query = context.SOURCING_RFQ_REQ.Join(
                        context.SOURCING_USERS, rq => rq.INITIATOR_ID, user => user.USER_ID, (rq, user) => new { Req = rq, Users = user })
                                .Join(context.SOURCING_REF_TEMP_LINK, link => link.Req.TEMP_NO, temp => temp.TEMP_NO, (link, temp) => new { _link = link, _temp = temp })
                                .Where(reqID => reqID._link.Req.TEMP_NO == _TempNo).FirstOrDefault();
                    if (query != null)
                    {
                        Summary.Initiator.NAME           = query._link.Users.NAME;
                        Summary.Initiator.TELEPHONE      = query._link.Users.TELEPHONE;
                        Summary.Initiator.EMAIL          = query._link.Users.EMAIL;
                        Summary.Request.DELIVERY_ADDRESS = query._link.Req.DELIVERY_ADDRESS;
                        Summary.Request.RFQ_START_DATE   = query._link.Req.RFQ_START_DATE;
                        Summary.Request.RFQ_CLOSE_DATE   = query._link.Req.RFQ_CLOSE_DATE;
                        Summary.RefNum.REF_NO            = query._temp.REF_NO;
                        Summary.Request.TEMP_NO          = query._link.Req.TEMP_NO;
                        Summary.Request.NEGVATVALUE      = query._link.Req.NEGVATVALUE;
                        Summary.Request.NEGVAT           = query._link.Req.NEGVAT;
                        Summary.Request.NEGTOTALAMT      = query._link.Req.NEGTOTALAMT;
                        Summary.Request.NEGGRANDTOTAL    = query._link.Req.NEGGRANDTOTAL;
                    }
                    return(Summary);
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Error retrieving data for summary display. Error: " + ex.Message +
                           "------------------------------------------------" + ex.StackTrace,
                           "error");
                return(null);
            }
        }