Exemplo n.º 1
0
        public IActionResult Index()
        {
            var AspVendorViewModel = new AspVendorViewModel();

            AspVendorViewModel.VendorList = from vendor in _MainSystemContext.AspNetVendor select vendor;

            return(View(AspVendorViewModel));
        }
Exemplo n.º 2
0
        public IActionResult ActivateVendor(AspVendorViewModel model)
        {
            var id = model.VendorDetail.Id;
            //get vendor with this id
            var getVendor = _MainSystemContext.AspNetVendor.FirstOrDefault(a => a.Id == id);

            if (getVendor == null)
            {
                return(RedirectToAction("Show", new RouteValueDictionary(
                                            new { Controller = "Vendors", Action = "Show", adhfliewgfblbksdfUEOfbiualbgfE1038RYHWEO = id }
                                            )));
            }

            //update vendor and activate
            getVendor.PaymentTerms       = model.VendorDetail.PaymentTerms;
            getVendor.VendorPostingGroup = model.VendorDetail.VendorPostingGroup;
            getVendor.GenBusPostingGroup = model.VendorDetail.GenBusPostingGroup;
            getVendor.VATBusPostingGroup = model.VendorDetail.VATBusPostingGroup;
            getVendor.LocationCode       = model.VendorDetail.LocationCode;
            getVendor.IsActive           = "Yes";

            _MainSystemContext.Update(getVendor);
            _MainSystemContext.SaveChanges();

            //Tambahkan Vendor baru di tabel BML
            if (getVendor.VendorNo == null || getVendor.VendorNo == "")
            {
                //Generate Vendor No new
                string Vnumbers = GeneratevendorNo();

                //lakukan Insert Ke db Vendors di BML Context
                var Vendors = new Vendors
                {
                    VendorNo             = Vnumbers,
                    VendorName           = getVendor.CompanyName,
                    VendorName2          = "",
                    VendorAddress        = getVendor.Address,
                    VendorAddress2       = "",
                    VendorCity           = getVendor.VendorCity,
                    VendorContact        = getVendor.ContactName,
                    VendorPhoneNo        = getVendor.Contact,
                    VendorFaxNo          = getVendor.VendorFaxNo,
                    VendorTelexNo        = "",
                    OurAccountNo         = "",
                    TerritoryCode        = "",
                    GlobalDimension1Code = "",
                    GlobalDimension2Code = "",
                    BudgetedAmount       = 0,
                    VendorPostingGroup   = model.VendorDetail.VendorPostingGroup,
                    CurrencyCode         = getVendor.Currency,
                    LanguageCode         = "",
                    StatisticsGroup      = 0,
                    PaymentTermsCode     = model.VendorDetail.PaymentTerms,
                    FinChargeTermsCode   = "",
                    PurchaserCode        = "",
                    ShipmentMethodCode   = "",
                    ShippingAgentCode    = "",
                    InvoiceDiscCode      = "",
                    Country            = getVendor.Country,
                    Blocked            = 0,
                    PaytoVendorNo      = "",
                    Priority           = 0,
                    PaymentMethodCode  = "",
                    ApplicationMethod  = 0,
                    PricesIncludingVat = 0,
                    TelexAnswerBack    = "",
                    VatregistrationNo  = "",
                    GenBusPostingGroup = model.VendorDetail.GenBusPostingGroup,
                    MobileNo           = getVendor.InvoiceContact,
                    PostCode           = "",
                    Email                 = getVendor.ContactEmail,
                    HomePage              = "",
                    NoSeries              = "",
                    TaxAreaCode           = "",
                    TaxLiable             = 0,
                    VatbusPostingGroup    = model.VendorDetail.VATBusPostingGroup,
                    BlockPaymentTolerance = 0,
                    IcpartnerCode         = "",
                    PrepaymentPercent     = 0,
                    PrimaryContactNo      = "",
                    ResponsibilityCenter  = "",
                    LocationCode          = model.VendorDetail.LocationCode,
                    LeadTimeCalculation   = "",
                    BaseCalendarCode      = "",
                    RtcfilterField        = 0,
                    BuyerGroupCode        = "",
                    BuyerId               = "",
                    RowStatus             = 0,
                    CreatedBy             = _userManager.GetUserName(User),
                    CreatedTime           = DateTime.Now,
                    Swiftcode             = getVendor.Swiftcode,
                };
                _bmlContext.Vendors.Add(Vendors);
                _bmlContext.SaveChanges();

                //isi vendors no di aspnetvendor tabel
                getVendor.VendorNo = Vnumbers;
                _MainSystemContext.AspNetVendor.Update(getVendor);
                _MainSystemContext.SaveChanges();
            }
            else
            {
                var getVendorsInBMLContext = _bmlContext.Vendors.FirstOrDefault(a => a.VendorNo == getVendor.VendorNo);
                //lakukan update
                getVendorsInBMLContext.VendorName         = getVendor.CompanyName;
                getVendorsInBMLContext.VendorAddress      = getVendor.Address;
                getVendorsInBMLContext.VendorCity         = getVendor.VendorCity;
                getVendorsInBMLContext.VendorContact      = getVendor.ContactName;
                getVendorsInBMLContext.VendorPhoneNo      = getVendor.Contact;
                getVendorsInBMLContext.VendorFaxNo        = getVendor.VendorFaxNo;
                getVendorsInBMLContext.VendorPostingGroup = model.VendorDetail.VendorPostingGroup;
                getVendorsInBMLContext.CurrencyCode       = getVendor.Currency;
                getVendorsInBMLContext.PaymentTermsCode   = model.VendorDetail.PaymentTerms;
                getVendorsInBMLContext.Country            = getVendor.Country;
                getVendorsInBMLContext.GenBusPostingGroup = model.VendorDetail.GenBusPostingGroup;
                getVendorsInBMLContext.MobileNo           = getVendor.InvoiceContact;
                getVendorsInBMLContext.Email = getVendor.ContactEmail;
                getVendorsInBMLContext.VatbusPostingGroup = model.VendorDetail.VATBusPostingGroup;
                getVendorsInBMLContext.LocationCode       = model.VendorDetail.LocationCode;
                getVendorsInBMLContext.Swiftcode          = getVendor.Swiftcode;
                getVendorsInBMLContext.LastModifiedBy     = _userManager.GetUserName(User);
                getVendorsInBMLContext.LastModifiedTime   = DateTime.Now;
                _bmlContext.Vendors.Update(getVendorsInBMLContext);
                _bmlContext.SaveChanges();
            }

            return(RedirectToAction("Show", new RouteValueDictionary(
                                        new { Controller = "Vendors", Action = "Show", adhfliewgfblbksdfUEOfbiualbgfE1038RYHWEO = id }
                                        )));
        }