예제 #1
0
        public static string InsertNegotiationForRequest(RFIRFPComboViewModel inputs, FormCollection collection)
        {
            NegotiationsViewModel model = new NegotiationsViewModel();
            //SOURCING_RFQ_QUOTATION query = new SOURCING_RFQ_QUOTATION();
            SOURCING_NEGOTIATIONS _negotiations = new SOURCING_NEGOTIATIONS();
            SOURCING_NEG_PRICE    query         = new SOURCING_NEG_PRICE();

            try
            {
                decimal ResponseNumber = Convert.ToDecimal(collection["NegNumber"].ToString());
                var     context        = new Entities();
                foreach (var vendor in inputs.Vendors)
                {
                    decimal _negNo = Common.GetSequenceB();
                    model.VAT        = inputs.Request.NEGVAT;
                    model.VATVALUE   = inputs.Request.NEGVATVALUE;
                    model.TOTAL_AMT  = inputs.Request.NEGTOTALAMT;
                    model.GRANDTOTAL = inputs.Request.NEGGRANDTOTAL;
                    model.TEMP_ID    = inputs.Request.TEMP_ID;
                    model.RES_DATE   = DateTime.Now;

                    _negotiations.NEG_NO      = _negNo;
                    _negotiations.RESPONSE_NO = ResponseNumber;
                    _negotiations.GRANDTOTAL  = model.GRANDTOTAL;
                    _negotiations.TOTAL_AMT   = model.TOTAL_AMT;
                    _negotiations.VAT         = model.VAT;
                    _negotiations.VATVALUE    = model.VATVALUE;
                    _negotiations.RES_DATE    = model.RES_DATE;
                    _negotiations.VENDOR_ID   = vendor.VENDOR_ID;
                    _negotiations.NEGOTIATOR  = "BUYER";
                    _negotiations.TEMP_ID     = model.TEMP_ID;
                    _negotiations.STATUS      = "";
                    context.SOURCING_NEGOTIATIONS.Add(_negotiations);
                    context.SaveChanges();
                    foreach (var item in inputs.Item)
                    {
                        InsertNegPrice(item, inputs.Request.TEMP_ID, _negNo);
                    }

                    UpdateVendorStatus((decimal)vendor.VENDOR_ID, inputs.Request.TEMP_ID, ResponseNumber);
                    NotifyVendor((decimal)vendor.VENDOR_ID, inputs.Request.TEMP_ID);
                }
                return("success");
            }
            catch (Exception ex)
            {
                Logger.Log("An error occurred, Error: " + ex.Message +
                           "------------------------------------------------" + ex.StackTrace,
                           "error");
                return("error");
            }
        }
예제 #2
0
        public static void InsertNegPrice(RFQITEMViewModel item, decimal?tempId, decimal NegotiationNumber)
        {
            SOURCING_NEG_PRICE neg = new SOURCING_NEG_PRICE();

            using (var context = new Entities())
            {
                neg.ITEM_NO     = item.ITEM_NO;
                neg.NEG_NO      = NegotiationNumber;
                neg.UNIT_PRICE  = item.UNIT_PRICE;
                neg.TOTAL_PRICE = item.TOTAL_PRICE;
                context.SOURCING_NEG_PRICE.Add(neg);
                context.SaveChanges();
            }
        }