예제 #1
0
        public JsonResult DoesThisVendorExist()
        {
            VendorViewModel ViewModle   = new VendorViewModel();
            var             vendorCount = 0;

            try
            {
                var resolveRequest = HttpContext.Request;
                resolveRequest.InputStream.Seek(0, System.IO.SeekOrigin.Begin);
                string jsonString = new System.IO.StreamReader(resolveRequest.InputStream).ReadToEnd();
                //deserialse
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string vendorName = serializer.Deserialize <string>(jsonString);
                using (VendorViewModel presentaion = new VendorViewModel())
                {
                    vendorCount = presentaion.GetData()
                                  .Where(x => x.VendorName.ToUpper().Equals(vendorName.ToUpper())).Count();
                    return(new JsonResult
                    {
                        Data = new { Data = vendorCount, Success = true, ErrorMessage = "" },
                        ContentEncoding = System.Text.Encoding.UTF8,
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            catch (Exception ex)
            {
                return(new JsonResult
                {
                    Data = new { Data = vendorCount, Success = false, ErrorMessage = ex.Message },
                    ContentEncoding = System.Text.Encoding.UTF8,
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
예제 #2
0
        public async Task EditVendorAsync(VendorViewModel input)
        {
            var vendor = this.context.Vendors.Include(x => x.Address).FirstOrDefault(x => x.Id == input.Id);

            this.mapper.Map <VendorViewModel, Vendor>(input, vendor);
            await this.context.SaveChangesAsync();
        }
예제 #3
0
        public ActionResult Delete(long Id)
        {
            var vendorObj        = _repVendor.GetVendorList().Where(x => x.Id == Id).SingleOrDefault();
            var vendorContactObj = _repVendor.GetVendorContact(Id);

            var vvm = new VendorViewModel()
            {
                VendorName      = (vendorObj != null) ? vendorObj.Name : "",
                VendorAddress   = (vendorObj != null) ? vendorObj.Address : "",
                VendorEmailId   = (vendorObj != null) ? vendorObj.EmailId : "",
                ContactPerson   = (vendorObj != null) ? vendorObj.ContactPerson : "",
                VendorPAN       = (vendorObj != null) ? vendorObj.PAN : "",
                VendorVAT       = (vendorObj != null) ? vendorObj.VAT : "",
                VendorStatus    = (vendorObj != null) ? vendorObj.Status : 0,
                VendorContactNo = (vendorContactObj != null) ? String.Join(",", vendorContactObj.Where(x => x.ContactType == "Landline").ToList()) : "",
                VendorCellNo    = (vendorContactObj != null) ? String.Join(",", vendorContactObj.Where(x => x.ContactType == "Cell").ToList()) : "",
                UserId          = SessionHelper.UserId,
                Username        = SessionHelper.Username
            };

            var deleteMessage = _repVendor.DeleteVendor(Id, vvm);

            if (deleteMessage != "")
            {
                //Unsuccessful delete
                FlashMessage.Danger(deleteMessage);
                return(RedirectToAction("Index"));
            }
            else
            {
                //Successful delete
                FlashMessage.Confirmation("Vendor " + vvm.VendorName + " has been deleted successfully.");
                return(RedirectToAction("Index"));
            }
        }
예제 #4
0
        public async Task <VendorViewModel> UpdateVendorAsync(VendorViewModel vendorViewModel)
        {
            var vendor = await _vendorRepository.GetByIdAsync(vendorViewModel.VendorId);

            var pointOfSales = _mapper.Map <PointOfSale[]>(vendorViewModel.PointOfSales);

            var resultPointOfSales = await _pointOfSaleService.GetPointOfSalesAndCreateIfNotExistAsync(pointOfSales);

            vendor.PointOfSales?.Clear();

            vendor.Name         = vendorViewModel.VendorName;
            vendor.Phone        = vendorViewModel.Phone;
            vendor.SocialLinks  = vendorViewModel.SocialLinks;
            vendor.Email        = vendorViewModel.Email;
            vendor.Address      = vendorViewModel.Address;
            vendor.Description  = vendorViewModel.Description;
            vendor.PointOfSales = resultPointOfSales;

            await _vendorRepository.SaveChangesAsync();

            var createVendorViewModel = _mapper.Map <VendorViewModel>(vendor);

            createVendorViewModel.PointOfSales = _mapper.Map <PointOfSaleViewModel[]>(resultPointOfSales);

            return(createVendorViewModel);
        }
예제 #5
0
        public ActionResult DeleteConfirmed(VendorViewModel vendorViewModel)
        {
            vendorViewModel.operationType = OperationType.Delete;
            if (ModelState.IsValid)
            {
                if (vendorViewModel == null)
                {
                    return(HttpNotFound("Vendor not found to delete!"));
                }

                string _vendorName = vendorViewModel.vendorModel.Name;

                _vendorModelFactory.deleteVendor(vendorViewModel);

                ///---if error deleting product
                if (vendorViewModel.operationStatus == OperationStatus.Error)
                {
                    TempData["errorMessage"] = string.Format("Error deleting vendor \"{0}\"!, {1}", vendorViewModel.vendorModel.Name, vendorViewModel.OperationMessage);
                    return(View("VendorForm", vendorViewModel));
                }
                TempData["message"] = string.Format("Vendor \"{0}\" has been deleted!", _vendorName);
                return(RedirectToAction("List"));
            }
            else
            {
                return(View("VendorForm", vendorViewModel));
            }
        }
예제 #6
0
        public ActionResult Insert_Vendor(VendorViewModel vViewModel)
        {
            try
            { vViewModel.Vendor.CreatedBy = ((UserInfo)Session["User"]).UserId;

              vViewModel.Vendor.UpdatedBy = ((UserInfo)Session["User"]).UserId;

              vViewModel.Vendor.CreatedOn = DateTime.Now;

              vViewModel.Vendor.UpdatedOn = DateTime.Now;

              vViewModel.Attribute_Code.Attribute_Code_Name = vViewModel.Vendor.Vendor_Name;

              vViewModel.Vendor.Vendor_Id = _vendorMan.Insert_Vendor(vViewModel.Vendor);

              vViewModel.Attribute_Code.Attribute_Id = Convert.ToInt32(AttributeName.Supplier);

              if (vViewModel.Vendor.Material_Category_Entity.Material_Category_Name == "YarnCategory")
              {
                  vViewModel.Attribute_Code.Status = true;

                  vViewModel.Attribute_Code.Attribute_Code_Id = _vendorMan.Insert_Attribute_Code(vViewModel.Attribute_Code);
              }

              vViewModel.Friendly_Message.Add(MessageStore.Get("V011")); }
            catch (Exception ex)
            {
                vViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Vendor Controller - Insert " + ex.ToString());
            }

            return(Json(vViewModel));
        }
        public ActionResult AddOrEditDetails(VendorViewModel vendorViewModel)
        {
            if (!ModelState.IsValid)
            {
                var viewmodelobject = new VendorViewModel()
                {
                    Vendor = vendorViewModel.Vendor,
                };
                return(View("VendorDetails", viewmodelobject));
            }


            var vendortobeedited = _context.Vendor.Single(c => c.VendorId == vendorViewModel.Vendor.VendorId);

            vendortobeedited.VendorName = vendorViewModel.Vendor.VendorName;
            vendortobeedited.VendorId   = vendorViewModel.Vendor.VendorId;
            vendortobeedited.EmailId    = vendorViewModel.Vendor.EmailId;
            vendortobeedited.ContactNum = vendorViewModel.Vendor.ContactNum;
            vendortobeedited.Address    = vendorViewModel.Vendor.Address;

            _context.SaveChanges();

            var vendorsInDb = _context.Vendor.ToList();

            var vendorviewmodel = new VendorViewModel()
            {
                VendorList = vendorsInDb,
            };

            return(View("VendorDetails", vendorviewmodel));
        }
        public VendorViewModel Add(VendorViewModel model)
        {
            var dc = new eprocdbDataContext();
            var md = new MSVENDOR();

            md.VENDORNAME = model.VENDORNAME;
            md.STREET     = model.STREET;
            md.DISTRIC    = model.DISTRIC;
            md.CITY       = model.CITY;
            md.TELEPHONE  = model.TELEPHONE;
            md.POSTALCODE = model.POSTALCODE;
            md.EMAIL      = model.EMAIL;
            md.EMAIL2     = model.EMAIL2;
            md.EMAIL3     = model.EMAIL3;
            md.EMAIL4     = model.EMAIL4;
            md.EMAIL5     = model.EMAIL5;
            md.EMAIL6     = model.EMAIL6;
            md.EMAIL7     = model.EMAIL7;
            md.EMAIL8     = model.EMAIL8;
            md.PLANTIDTSO = model.PLANTIDTSO;
            md.B2B        = model.B2Bs == true ? '1' : '0';
            dc.MSVENDORs.InsertOnSubmit(md);
            dc.SubmitChanges();
            return(model);
        }
        public VendorViewModel Getdata(string vendorId)
        {
            var dc    = new eprocdbDataContext();
            var model = (from c in dc.MSVENDORs where c.VENDORID == vendorId select c).SingleOrDefault();
            var md    = new VendorViewModel();

            md.VENDORNAME = model.VENDORNAME;
            md.STREET     = model.STREET;
            md.DISTRIC    = model.DISTRIC;
            md.CITY       = model.CITY;
            md.TELEPHONE  = model.TELEPHONE;
            md.POSTALCODE = model.POSTALCODE;
            md.EMAIL      = model.EMAIL;
            md.EMAIL2     = model.EMAIL2;
            md.EMAIL3     = model.EMAIL3;
            md.EMAIL4     = model.EMAIL4;
            md.EMAIL5     = model.EMAIL5;
            md.EMAIL6     = model.EMAIL6;
            md.EMAIL7     = model.EMAIL7;
            md.EMAIL8     = model.EMAIL8;
            md.PLANTIDTSO = model.PLANTIDTSO;
            md.B2B        = model.B2B;
            md.B2Bs       = model.B2B == '1' ? true : false;
            return(md);
        }
예제 #10
0
 public ActionResult AddVendor(VendorViewModel vendorViewModel)
 {
     if (ModelState.IsValid)
     {
         VendorService.VendorServiceClient    vendorServiceClient = new VendorService.VendorServiceClient();
         OrgService.OrganizationServiceClient organizationClient  = new OrgService.OrganizationServiceClient();
         vendorViewModel.vendor.OrgCompanyID = vendorViewModel.CompanyID;
         vendorViewModel.vendor.IsActive     = true;
         vendorViewModel.vendor.IsDelete     = false;
         vendorViewModel.vendor.UserID       = 1;
         int id = Convert.ToInt32(vendorServiceClient.insertVendor(vendorViewModel.vendor));
         vendorViewModel.vendor.VendorID = id;
         if (id != 0)
         {
             Session["VendorName"] = vendorViewModel.vendor.VendorName;
             Session["VendorID"]   = vendorViewModel.vendor.VendorID;
             Session["CompanyID"]  = vendorViewModel.vendor.OrgCompanyID;
             return(RedirectToAction("AboutVendor"));
         }
         else
         {
             return(View("View"));
         }
     }
     else
     {
         return(View("_Vendor"));
     }
 }
예제 #11
0
        public ActionResult GetVendorByLocation(int?pageNo)
        {
            string TextBox = Request.Form["location"].ToLower();
            var    Users   = context.Roles.Where(x => x.Id == "2").FirstOrDefault();
            List <VendorViewModel> UserList = new List <VendorViewModel>();
            var UserUsers = Users.Users;

            foreach (var UserUser in UserUsers)
            {
                var user = context.Users.Where(x => x.Id == UserUser.UserId && x.Town.ToLower() == TextBox).FirstOrDefault();
                if (user != null)
                {
                    VendorViewModel User = new VendorViewModel()
                    {
                        VendorName = user.UserName,
                        Email      = user.Email,
                        Address    = user.Address,
                        City       = user.City
                    };
                    UserList.Add(User);
                }
            }

            return(View(UserList.ToPagedList(pageNo ?? 1, 3)));
        }
예제 #12
0
        public ActionResult AddOrEditVendor(Guid?id)
        {
            try
            {
                VendorViewModel model = new VendorViewModel();

                if (id.HasValue)
                {
                    var vendor = _vendorService.GetById(id.Value);
                    model.Id          = vendor.Id;
                    model.Name        = vendor.Name;
                    model.Address     = vendor.Address;
                    model.Email       = vendor.Email;
                    model.PhoneNumber = vendor.PhoneNumber;
                    model.UpdateDate  = vendor.UpdatedDate;
                    model.CreateDate  = vendor.CreatedDate;
                    model.IsActive    = vendor.IsActive;
                    return(View(model));
                }
                else
                {
                    return(View(model));
                }
            }
            catch { return(RedirectToAction("Erorr500", "HomdeAdmin")); }
        }
예제 #13
0
        public ActionResult AddOrEditVendor(Guid?id, VendorViewModel model, HttpPostedFileBase logo)
        {
            try
            {
                bool isNew = !id.HasValue;

                // isNew = true update UpdatedDate of product
                // isNew = false get it by id
                var vendor = isNew ? new Vendor
                {
                    UpdatedDate = DateTime.Now
                } : _vendorService.GetById(id.Value);

                vendor.Name        = model.Name;
                vendor.Address     = model.Address;
                vendor.Email       = model.Email;
                vendor.PhoneNumber = model.PhoneNumber;
                vendor.IsActive    = true;

                if (isNew)
                {
                    vendor.CreatedDate = DateTime.Now;
                    vendor.Id          = Guid.NewGuid();
                    _vendorService.Insert(vendor);
                }
                else
                {
                    _vendorService.Update(vendor);
                }
                return(RedirectToAction("Index"));
            }
            catch { return(RedirectToAction("Erorr500", "HomdeAdmin")); }
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id, CustomerId, VendorCode, VendorName, , ContactPerson, Telephone, MobileNo, EmailAddress, Website, Address1, Address2, UpdatedBy, DateUpdated, CreatedBy, DateCreated, IsActive")] VendorViewModel vendorViewModel)
        {
            vendorViewModel.UpdatedBy = CookieHelper.EmailAddress;

            var url      = "api/vendor/update";
            var response = await HttpClientHelper.ApiCall(url, Method.PUT, vendorViewModel);

            if (response.StatusCode == HttpStatusCode.Forbidden)
            {
                TempData["Message"]      = vendorViewModel.VendorCode + " is already exist! Please check and try again.";
                TempData["MessageAlert"] = "warning";
            }

            if (response.IsSuccessful)
            {
                TempData["Message"]      = vendorViewModel.VendorName + " successfully updated!";
                TempData["MessageAlert"] = "success";
                //Log.Error(string.Format(Type.GetType(typeof(VendorController).Name) + "||Update||Vendor ID::{0}||API Response::{1}", vendorViewModel.Id, response));
                //return RedirectToAction("Index");
            }
            else
            {
                Error("An error has occurred");
                Log.Error(string.Format(Type.GetType(typeof(VendorController).Name) + "||Update||Vendor ID::{0}||API Response::{1}", vendorViewModel.Id, response));
                return(PartialView(vendorViewModel));
            }

            return(RedirectToAction("Index", "Vendor"));
        }
예제 #15
0
        public async Task <ActionResult> ViewAllVendors()
        {
            var vendorsList = new List <VendorViewModel>();

            int _companyId = Convert.ToInt32(User.Identity.GetUserId());

            if (_companyId > 0)
            {
                try
                {
                    EMSDbContext db      = new EMSDbContext();
                    var          vendors = _vendorService.GetAllVendors(_companyId);
                    foreach (var obj in vendors.vendors)
                    {
                        var vendor = new VendorViewModel();
                        var user   = db.Users.Where(x => x.Id == obj.Id).FirstOrDefault();
                        vendor.FullName    = obj.FirstName + " " + obj.LastName;
                        vendor.DateOfBirth = obj.DateOfBirth;
                        vendor.Gender      = obj.Gender;
                        vendor.DateOfJoin  = obj.DateOfJoin;
                        vendor.DateOfBirth = obj.DateOfBirth;
                        vendor.Email       = user.Email;
                        vendor.PhoneNumber = user.PhoneNumber;
                        vendor.VendorType  = _vendortypeService.GetVendorTypeById(obj.VendorTypeId).Type;

                        vendorsList.Add(vendor);
                    }
                }
                catch (Exception ex) { }
            }
            return(View(vendorsList));
        }
예제 #16
0
        public VendorListPage()
        {
            InitializeComponent();
            BindingContext = viewModel = new VendorViewModel();

            VendorListView.ItemsSource = viewModel.Vendors;
        }
예제 #17
0
        public PartialViewResult Printable_Vendor(int vendor_Id)
        {
            ViewBag.Title = "KPCL ERP :: Print";

            VendorViewModel vViewModel = new VendorViewModel();

            vViewModel.Vendor.Vendor_Id = vendor_Id;

            PaginationInfo pager = new PaginationInfo();

            try
            {
                vViewModel.Vendor = _vendorMan.Get_Vendor_By_Id(vViewModel.Vendor.Vendor_Id);

                MaterialManager _materialMan = new MaterialManager();

                vViewModel.Materials = _materialMan.Get_Materials_By_Vendor_Id(vViewModel.Vendor.Vendor_Id, ref pager);
            }
            catch (Exception ex)
            {
                vViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Vendor Controller - Printable_Vendor " + ex.ToString());
            }

            return(PartialView("_PrintableView", vViewModel));
        }
예제 #18
0
        public async Task <ActionResult <VendorViewModel> > AddVendor(VendorViewModel model)
        {
            model.UserId = _userId;
            var user = await _userService.AddVendor(model);

            return(Ok(user));
        }
예제 #19
0
        // azure link: http://productssample.azurewebsites.net/api/products
        //Product prodList;

        // GET: Products
        public ActionResult Index()
        {
            IEnumerable <Vendor> vendList;

            WebClient client = new WebClient();

            string output = client.DownloadString(dashboardUrlBase);

            vendList = JsonConvert.DeserializeObject <List <Vendor> >(output);

            VendorListViewModel    vendorList = new VendorListViewModel();
            List <VendorViewModel> vendVMs    = new List <VendorViewModel>();

            foreach (Vendor v in vendList)
            {
                VendorViewModel vvm = new VendorViewModel();

                vvm.VendorName = v.VendorName;
                vvm.VendorCode = v.VendorCode;
                vvm.ValidFrom  = v.ValidFrom;
                vvm.ValidThru  = v.ValidThru;
                vendVMs.Add(vvm);
            }
            ;
            vendorList.Vendors = vendVMs;

            return(View("Index", vendorList));
        }
예제 #20
0
        public async Task <IActionResult> UpdateVendor(VendorViewModel model)
        {
            model.UserId = _userId;
            await _userService.UpdateVendor(model);

            return(Ok());
        }
        public ActionResult AddVendor(VendorViewModel vendorViewModel)
        {
            if (!ModelState.IsValid)
            {
                var viewmodelobject = new VendorViewModel()
                {
                    Vendor     = vendorViewModel.Vendor,
                    VendorList = _context.Vendor.ToList(),
                };
                return(View("VendorDetails", viewmodelobject));
            }

            var vendor = new Vendor();

            vendor.VendorId   = vendorViewModel.Vendor.VendorId;
            vendor.VendorName = vendorViewModel.Vendor.VendorName;
            vendor.ContactNum = vendorViewModel.Vendor.ContactNum;
            vendor.EmailId    = vendorViewModel.Vendor.EmailId;
            vendor.DateAdded  = DateTime.Today;
            vendor.Address    = vendorViewModel.Vendor.Address;

            _context.Vendor.Add(vendor);

            _context.SaveChanges();
            var viewmodel = new VendorViewModel()
            {
                VendorList = _context.Vendor.ToList(),
            };

            return(View("VendorDetails", viewmodel));
        }
예제 #22
0
        public VendorViewModel saveVendor(VendorViewModel vendorViewModel)
        {
            VendorDTO vendorDTO = new VendorDTO();

            var vendorMapper = new ecvMapper <VendorModel, VendorDTO>();

            vendorDTO = vendorMapper.CreateMappedObject(vendorViewModel.vendorModel);

            var _vendorServiceStatus = _vendorService.SaveVendor(vendorDTO);

            if (_vendorServiceStatus.operationStatus == OperationStatus.Error)
            {
                vendorViewModel.operationStatus = OperationStatus.Error;
                if (!string.IsNullOrEmpty(_vendorServiceStatus.OperationMessage))
                {
                    vendorViewModel.OperationMessage = _vendorServiceStatus.OperationMessage;
                }

                vendorViewModel.ecvRuleViolation = _vendorServiceStatus.ecvRuleViolation;
            }
            else
            {
                vendorViewModel.operationStatus = OperationStatus.Success;
                if (!string.IsNullOrEmpty(_vendorServiceStatus.OperationMessage))
                {
                    vendorViewModel.OperationMessage = _vendorServiceStatus.OperationMessage;
                }
                vendorViewModel.ecvRuleViolation = _vendorServiceStatus.ecvRuleViolation;
            }

            return(vendorViewModel);
        }
예제 #23
0
        public ActionResult SaveEdit(VendorViewModel vendorViewModel)
        {
            vendorViewModel.operationType = OperationType.Edit;
            if (ModelState.IsValid)
            {
                _vendorModelFactory.saveVendor(vendorViewModel);
                if (vendorViewModel.operationStatus == OperationStatus.Error)
                {
                    if (vendorViewModel.ecvRuleViolation != null && vendorViewModel.ecvRuleViolation.Count() > 0) //if business and validation rules violations
                    {
                        foreach (var _propertyError in vendorViewModel.ecvRuleViolation)
                        {
                            //--Add error property level
                            ModelState.AddModelError("vendorModel." + _propertyError._propertyName, _propertyError._errorMessage);
                        }
                    }
                    else // else only single error
                    {
                        ModelState.AddModelError("", vendorViewModel.OperationMessage);
                    }

                    return(View("VendorForm", vendorViewModel));
                }
                TempData["message"] = string.Format("Vendor \"{0}\" has been updated.", vendorViewModel.vendorModel.Name);
                return(RedirectToAction("List"));
            }
            else
            {
                return(View("VendorForm", vendorViewModel));
            }
        }
예제 #24
0
        public VendorViewModel deleteVendor(VendorViewModel vendorViewModel)
        {
            var _vendorServiceStatus = _vendorService.DeleteVendor(vendorViewModel.vendorModel.Id);

            if (_vendorServiceStatus.operationStatus == OperationStatus.Error)
            {
                vendorViewModel.operationStatus = OperationStatus.Error;
                if (!string.IsNullOrEmpty(_vendorServiceStatus.OperationMessage))
                {
                    vendorViewModel.OperationMessage = _vendorServiceStatus.OperationMessage;
                }

                vendorViewModel.ecvRuleViolation = _vendorServiceStatus.ecvRuleViolation;
            }
            else
            {
                vendorViewModel.operationStatus = OperationStatus.Success;
                if (!string.IsNullOrEmpty(_vendorServiceStatus.OperationMessage))
                {
                    vendorViewModel.OperationMessage = _vendorServiceStatus.OperationMessage;
                }
                vendorViewModel.ecvRuleViolation = _vendorServiceStatus.ecvRuleViolation;
            }

            return(vendorViewModel);
        }
        public async Task <IActionResult> Edit(string id, VendorViewModel viewModel)
        {
            try
            {
                log.LogInformation($"Vendor edit requested [{viewModel.Vendor.Id}]");
                var response = await service.UpsertAsync(viewModel.Vendor);

                if (response.Success)
                {
                    log.LogInformation($"Vendor edit completed [{viewModel.Vendor.Id}]");
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    log.LogWarning($"Vendor edit could not be completed [{viewModel.Vendor.Id }]");
                    viewModel.Vendor   = response.Model;
                    viewModel.Response = new ResponseCore {
                        Message = response.Message, Success = response.Success
                    };
                    return(View(viewModel));
                }
            }
            catch (Exception ex)
            {
                log.LogError(ex, $"Error editing vendor [{JsonConvert.SerializeObject(viewModel.Vendor)}]");
                return(View("Error", ex));
            }
        }
예제 #26
0
        // GET: Vendor
        public ActionResult List(int page = 1)
        {
            VendorViewModel viewModel = new VendorViewModel();

            try
            {
                viewModel.PagingInfo = new PagingInfo
                {
                    TotalRecordsCount = vendorService.TotalRecordsCount(),
                    RecordsPerPage    = RecordsPerPage,
                    CurentPageNo      = page
                };

                if (viewModel.PagingInfo.TotalRecordsCount > 0)
                {
                    viewModel.Vendors = GetVendors(page);
                }
                else
                {
                    DisplayWarningMessage("There are no Vendors to display");
                }
            }
            catch (Exception exp)
            {
                DisplayLoadErrorMessage(exp);
            }

            return(View(viewModel));
        }
예제 #27
0
        public JsonResult VendorRead([DataSourceRequest] DataSourceRequest request)
        {
            var vendorList = _repVendor.GetVendorList();

            var currentAnnualBudgetId = new BaseController(_repAnnualBudget).budgetList;

            var lstVendorDetail = new List <VendorViewModel>();

            for (int i = 0; i < vendorList.Count; i++)
            {
                var vvm = new VendorViewModel();
                vvm.Id            = vendorList[i].Id;
                vvm.VendorName    = vendorList[i].Name;
                vvm.VendorAddress = vendorList[i].Address;
                vvm.VendorEmailId = vendorList[i].EmailId;
                vvm.ContactPerson = vendorList[i].ContactPerson;

                var cellArr = _repVendor.GetVendorContact(vendorList[i].Id).Where(x => x.ContactType == "Cell").Select(x => x.ContactNo).ToList();
                vvm.VendorCellNo = String.Join(", ", cellArr);

                var landlineArr = _repVendor.GetVendorContact(vendorList[i].Id).Where(x => x.ContactType == "Landline").Select(x => x.ContactNo).ToList();
                vvm.VendorContactNo = String.Join(", ", landlineArr);

                vvm.VendorPAN                 = vendorList[i].PAN;
                vvm.VendorVAT                 = vendorList[i].VAT;
                vvm.TotalPendingAmount        = _repVendor.VendorRemainingAmount(vendorList[i].Id, currentAnnualBudgetId);
                vvm.TotalVendorPurchase       = _repVendor.GetTotalVendorPurchase(vendorList[i].Id, currentAnnualBudgetId);
                vvm.TotalVendorPurchaseReturn = _repVendor.GetTotalVendorPurchaseReturn(vendorList[i].Id, currentAnnualBudgetId);
                lstVendorDetail.Add(vvm);
            }

            return(Json(lstVendorDetail.ToDataSourceResult(request)));
        }
 protected void DeleteOrder_Click(object sender, EventArgs e)
 {
     if (int.Parse(VendorDropDown.SelectedValue) == 0)
     {
         MessageUserControl.ShowInfo("", "Error: you must select a vendor");
     }
     else
     {
         MessageUserControl.TryRun(() =>
         {
             PurchasingController sysmgr = new PurchasingController();
             List <OrderDetailsViewModel> orderDetails = GetOrderDetailsFromGridview();
             string comment       = Comments.Text;
             int orderId          = int.Parse(OrderID.Text);
             OrderViewModel order = new OrderViewModel
             {
                 Comment  = Comments.Text,
                 SubTotal = decimal.Parse(SubTotal.Text),
                 Tax      = decimal.Parse(Tax.Text),
                 Total    = decimal.Parse(Total.Text),
                 OrderID  = int.Parse(OrderID.Text)
             };
             sysmgr.DeletePurchaseOrder(int.Parse(VendorDropDown.SelectedValue), order, orderDetails);
         }, "", "SUCCESS: Order Deleted");
         VendorDropDown.SelectedIndex = 0;
         List <OrderDetailsViewModel> resetOrderDetails = new List <OrderDetailsViewModel>();
         VendorViewModel info = new VendorViewModel();
         SetVendor(info.VendorName, info.Contact, info.Phone, info.VendorID);
         OrderViewModel resetOrder = new OrderViewModel();
         SetOrder(resetOrder.Comment, resetOrder.SubTotal, resetOrder.Tax, resetOrder.Total, resetOrder.OrderID);
         OrderDetailsGrid.DataSource = resetOrderDetails;
         OrderDetailsGrid.DataBind();
     }
 }
예제 #29
0
        public ActionResult DatosPersonales(VendorViewModel vmUser)
        {
            modelContext.SaveChanges();
            ApplicationUser user = modelContext.Users.Where(x => x.Id == vmUser.Id).FirstOrDefault();

            user.FirstName = vmUser.FirstName;
            user.LastName  = vmUser.LastName;
            //old_user.Email = user.Email;

            Company company = modelContext.Companies.Where(x => x.Id == user.CompanyId).FirstOrDefault();

            company.CompanyName            = vmUser.CompanyName;
            company.CompanyDescription     = vmUser.CompanyDescription;
            company.CompanyWebSite         = vmUser.CompanyWebSite;
            company.CompanyPeopleInCompany = vmUser.CompanyPeopleInCompany;
            company.CompanyCity            = vmUser.CompanyCity;
            company.CompanyAddress         = vmUser.CompanyAddress;
            company.CompanyPostalCode      = vmUser.CompanyPostalCode;
            company.CompanyBranchOfficesIn = vmUser.CompanyBranchOfficesIn;
            company.CompanyFiscalStartDate = vmUser.CompanyFiscalStartDate;
            company.CompanyFiscalEndDate   = vmUser.CompanyFiscalEndDate;
            modelContext.SaveChanges();

            ApplicationUser updated_user    = modelContext.Users.Where(x => x.Id == user.Id).FirstOrDefault();
            VendorViewModel vm_updated_User = ApplicationUsertoVendorViewModelMap(updated_user);

            ViewBag.Msg = "Datos actualizados";
            return(View(vm_updated_User));
        }
예제 #30
0
 /// <summary>
 /// Provides a deterministic way to create the Vendors property.
 /// </summary>
 public static void CreateVendors()
 {
     if (_vendors == null)
     {
         _vendors = new VendorViewModel();
     }
 }