示例#1
0
        //Method takes active bids by CompanyId for supplier
        public IList<QuoteBidDTO> GetMyBids(int CompanyID)
        {
            IList<QuoteBid> bids = new List<QuoteBid>();
            IList<QuoteBidDTO> bidsToReturn = new List<QuoteBidDTO>();
            using (var context = new RFQEntities())
            {
                bids = (from bid in context.QuoteBids.Include("Quote").Include("Quote.Company").Include("Quote.Company.CompanyType")
                        where bid.QuoteParticipant.CompanyID == CompanyID && bid.Quote.Status==1
                        select bid).ToList();
                if (bids.Count > 0)
                {
                    foreach (var item in bids)
                    {
                        QuoteBidDTO bidRow = new QuoteBidDTO();
                        bidRow.QuoteBidID = item.QuoteBidID;
                        bidRow.QuoteID = item.QuoteID;
                        bidRow.QuoteParticipantID = item.QuoteParticipantID;
                        bidRow.CompanyID = item.Quote.Company.CompanyID;
                        bidRow.Amount = item.Amount;
                        bidRow.Notes = item.Notes;
                        bidRow.Name = item.Quote.Company.Name;
                        bidRow.Type = item.Quote.Company.CompanyType.Type;
                        bidsToReturn.Add(bidRow);
                    }
                }
            }

            return bidsToReturn;
        }
示例#2
0
        public bool setNewBid(QuoteBidDTO newBid, int companyId)
        {
            //bool result = false;
               QuoteParticipantService newParticipantSupplier = new QuoteParticipantService();
            newParticipantSupplier.CompanyID = companyId;
            newParticipantSupplier.QuoteID = newBid.QuoteID;
            newParticipantSupplier.SetNewParticipant(companyId, newBid.QuoteID);
            using (TransactionScope transaction = new TransactionScope())
            {

                try
                {

                    QuoteParticipant newQuoteParticipant = new QuoteParticipant();
                    QuoteParticipantBase newParticipant;
                    newParticipant = newParticipantSupplier.GetQuoteParticipant(companyId, newBid.QuoteID);
                    newQuoteParticipant.QuoteParticipantID = newParticipant.QuoteParticipantID;
                    QuoteBid newBidToCreate = new QuoteBid()
                    {
                    QuoteParticipantID = newQuoteParticipant.QuoteParticipantID,
                    QuoteID = newBid.QuoteID,
                    Amount = newBid.Amount,
                    Notes = newBid.Notes

                };
                  using (var context = new RFQEntities())
                    {

                        if (newBidToCreate.EntityState == EntityState.Detached)
                        {
                            context.QuoteBids.AddObject(newBidToCreate);
                        }

                        context.SaveChanges();

                    }

                }

                catch (Exception e)
                {
                    transaction.Dispose();
                    return false;

                }
                transaction.Complete();
                return true;

            }
        }
示例#3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool result = false;
            QuoteBidDTO objectToSend = new QuoteBidDTO();
            objectToSend.QuoteID = quoteId;
            result = Utility.InputAmountValidation(txtAmount.Text);
            if (result)
            {
                objectToSend.Amount = Convert.ToDecimal(txtAmount.Text);
            }
            else
            {
                lblAmount.ForeColor = Color.Red;
                txtAmount.Text = "";
                txtAmount.Focus();
                MessageBox.Show("You should enter a positive numerical amount");
                return;
            }
            result = Utility.InsertNewDataValidation(txtNotes.Text);
            if (result)
            {
                objectToSend.Notes = txtNotes.Text;
            }
            else
            {
                lblNotes.ForeColor = Color.Red;
                txtNotes.Focus();
                MessageBox.Show("You should enter some information");
                return;
            }

            BidService bidToCreate = new BidService();
            result = bidToCreate.setNewBid(objectToSend, companyId);
            if (result)
            {
                MessageBox.Show("The New Bid Has Just Been Successfully Created");
                this.Close();
            }
        }