Esempio n. 1
0
        private void shpDelete_Click(object sender, EventArgs e)
        {
            if (this.shpIdTxt.Text == "" || this.shpProTxt.Text == "" || this.comboBox2.Text == "")
            {
                MessageBox.Show("Insert the data");
            }

            else
            {
                int shipId = Convert.ToInt32(this.shpIdTxt.Text);

                ShipmentRepository sr = new ShipmentRepository();
                if (sr.Delete(shipId))
                {
                    List <ShipmentR> iList = sr.GetAllShipment();
                    this.dataGrid3.DataSource = iList;

                    this.shpIdTxt.Text  = "";
                    this.shpProTxt.Text = "";
                    this.comboBox2.Text = "";
                }
                else
                {
                    MessageBox.Show("Can Not Delete Shipment", "Delete Error");
                }
            }
        }
    public MyWpfObject()
    {
        ShipmentRepository  ShipmentRepository  = new ShipmentRepository();
        ContainerRepository ContainerRepository = new ContainerRepository();
        PackageRepository   PackageRepository   = new PackageRepository();

        ShipmentRepository.LoadingComplete  += Repository_LoadingComplete;
        ContainerRepository.LoadingComplete += Repository_LoadingComplete;
        PackageRepository.LoadingComplete   += Repository_LoadingComplete;
        Task[] loadingTasks = new Task[] {
            new Task(ShipmentRepository.Load),
            new Task(ContainerRepository.Load),
            new Task(PackageRepository.Load)
        };
        countdownEvent = new CountdownEvent(loadingTasks.Length);
        foreach (var task in loadingTasks)
        {
            task.Start();
        }
        // Wait till everything is loaded.
        countdownEvent.Wait();
        Console.WriteLine("Everything Loaded");

        //Wait till aditional tasks are completed.
        Task.WaitAll(loadingTasks);
        Console.WriteLine("Everything Completed");
        Console.ReadKey();
    }
Esempio n. 3
0
        public void GetSeller_FailCase()
        {
            var shipmentrepo = new ShipmentRepository(shipmentcontextmock.Object);
            var shipmentlist = shipmentrepo.GetShipment();

            Assert.AreNotEqual(2, shipmentlist.Count());
        }
 public ShipmentRepositoryTest()
 {
     warehouseDBConnectionString = "Server=memsqldw;Database=DWPROD;Trusted_Connection=True;User ID=Warehouse.APi.Prod;password=89=discover=STEEL=vermont;Trusted_Connection=False;Encrypt=True;TrustServerCertificate=True;connect timeout=100;";
     configurationFake           = Substitute.For <IConfiguration>();
     configurationFake.GetConnectionString("WarehouseDB").Returns(warehouseDBConnectionString);
     sut = new ShipmentRepository(configurationFake);
 }
        public ActionResult Index()
        {
            var repository = new ShipmentRepository();

            // users in Shipment Manager role can see all the shipments,
            // while others can see only its own shipments
            IEnumerable <Shipment> shipments;
            var organization = ClaimHelper.GetCurrentUserClaim(Fabrikam.ClaimTypes.Organization).Value;

            if (this.User.IsInRole(Fabrikam.Roles.ShipmentManager))
            {
                shipments = repository.GetShipmentsByOrganization(organization);
            }
            else
            {
                var userName = this.User.Identity.Name;
                shipments = repository.GetShipmentsByOrganizationAndUserName(organization, userName);
            }

            var model = new ShipmentListViewModel
            {
                Shipments = shipments
            };

            return(View(model));
        }
Esempio n. 6
0
        private void shpUpdate_Click(object sender, EventArgs e)
        {
            if (this.shpIdTxt.Text == "" || this.shpProTxt.Text == "" || this.comboBox2.Text == "")
            {
                MessageBox.Show("Insert the data");
            }
            else
            {
                ShipmentR i = new ShipmentR();

                i.ShipmentId       = Convert.ToInt32(this.shpIdTxt.Text);
                i.ShipmentProgress = Convert.ToInt32(this.shpProTxt.Text);
                i.Status           = this.comboBox2.GetItemText(this.comboBox2.SelectedItem);

                ShipmentRepository sr = new ShipmentRepository();
                if (sr.Update(i))
                {
                    List <ShipmentR> iList = sr.GetAllShipment();
                    this.dataGrid3.DataSource = iList;

                    this.shpIdTxt.Text  = "";
                    this.shpProTxt.Text = "";
                    this.comboBox2.Text = "";
                }
                else
                {
                    MessageBox.Show("Can Not Update Shipment", "Update Error");
                }
            }
        }
Esempio n. 7
0
        public void TestShipmentRepository()
        {
            var repo      = new ShipmentRepository();
            var shipments = repo.GetShipmentsByTranNoAsync("00038", 25).Result;

            Assert.IsNotNull(shipments.Count > 2);
        }
        public PlazaApiTests()
        {
            var plazaApiConfig = new PlazaApiConfig
            {
                RootEndPoint      = "https://test-plazaapi.bol.com",
                Namespace         = "https://plazaapi.bol.com/services/xsd/v2/plazaapi.xsd",
                OrdersUrl         = "/services/rest/orders/v2",
                OrderItemsUrl     = "/services/rest/order-items/v2",
                ShipmentsUrl      = "/services/rest/shipments/v2",
                ShippingLabelsUrl = "/services/rest/purchasable-shipping-labels/v2",
                TransportsUrl     = "/services/rest/transports/v2",
                ReturnItemsUrl    = "/services/rest/return-items/v2",
                ProcessStatusUrl  = "/services/rest/process-status/v2",
                PublicKey         = "[YOUR PUBLIC KEY]",
                PrivateKey        = "[YOUR PRIVATE KEY]"
            };


            var connector = new Connector(plazaApiConfig);

            var orderRepository         = new OrderRepository(connector, plazaApiConfig);
            var shipmentRepository      = new ShipmentRepository(connector, plazaApiConfig);
            var shippingLabelRepository = new ShippingLabelRepository(connector, plazaApiConfig);
            var returnItemRepository    = new ReturnItemRepository(connector, plazaApiConfig);
            var processStatusRepository = new ProcessStatusRepository(connector, plazaApiConfig);

            _plazaApi = new PlazaApiClient(orderRepository,
                                           shipmentRepository,
                                           shippingLabelRepository,
                                           returnItemRepository,
                                           processStatusRepository);
        }
Esempio n. 9
0
        public void GetShipment_PassCase()
        {
            var shipmentrepo = new ShipmentRepository(shipmentcontextmock.Object);
            var shipmentlist = shipmentrepo.GetShipment();

            Assert.AreEqual(3, shipmentlist.Count());
        }
Esempio n. 10
0
        private void shpSearch_Click(object sender, EventArgs e)
        {
            string             text  = this.shpSearchbox.Text;
            ShipmentRepository sr    = new ShipmentRepository();
            List <ShipmentR>   iList = sr.searchShipment(text);

            this.dataGrid3.DataSource = iList;
        }
Esempio n. 11
0
        /// <summary>
        /// 删除物流
        /// </summary>
        /// <param name="id"></param>
        public virtual async Task DeleteAsync(int id)
        {
            var logistics = await ShipmentRepository.FirstOrDefaultAsync(id);

            if (logistics != null)
            {
                await ShipmentRepository.DeleteAsync(logistics);
            }
        }
Esempio n. 12
0
        public ActionResult shipment(ParamModel param)
        {
            List <ShipmentModel> shipments = new List <ShipmentModel>();

            ShipmentRepository sr = new ShipmentRepository();

            shipments = sr.GetShipments(param.OrderIds);

            return(PartialView("/Views/Partials/_PartialShipments.cshtml", shipments));
        }
Esempio n. 13
0
 public UnitOfWork(StoreDBContext context)
 {
     _context = context;
     Product  = new ProductRepository(_context);
     Category = new CategoryRepository(_context);
     Cart     = new CartRepository(_context);
     Shipment = new ShipmentRepository(_context);
     Order    = new OrderRepository(_context);
     User     = new UserRepository(_context);
 }
Esempio n. 14
0
 /// <summary>
 /// 根据订单id查找物流
 /// </summary>
 /// <param name="orderId"></param>
 /// <param name="readOnly"></param>
 /// <returns></returns>
 public virtual IList <Shipment> FindByOrderId(long orderId, bool readOnly = false)
 {
     if (!readOnly)
     {
         return(ShipmentRepository.GetAllIncluding(s => s.Items).Where(s => s.OrderId == orderId).ToList());
     }
     else
     {
         return(Shipments.Include(s => s.Items).Where(s => s.OrderId == orderId).ToList());
     }
 }
Esempio n. 15
0
        private void dashBoardClicked(object sender, EventArgs e)
        {
            this.groupBox3.Visible = true;
            this.groupBox4.Visible = true;
            this.groupBox5.Visible = true;

            //get all the data
            // count the total order in groupBox3

            OrderRepository or = new OrderRepository();

            this.totalOrderLabel.Text  = "Total Order : " + Convert.ToString(or.countAllOrder());
            this.totalBikeLabel.Text   = "Bike : " + Convert.ToString(or.countOrder("Bike"));
            this.totalCarLabel.Text    = "Car : " + Convert.ToString(or.countOrder("Car"));
            this.totalAutoLabel.Text   = "Cng : " + Convert.ToString(or.countOrder("Cng"));
            this.totalMicroLabel.Text  = "Microbus : " + Convert.ToString(or.countOrder("Microbus"));
            this.totalPickupLabel.Text = "Pickup : " + Convert.ToString(or.countOrder("Pickup"));
            this.totalTruckLabel.Text  = "Truck : " + Convert.ToString(or.countOrder("Truck"));


            //count the total Inventory in groupBox4

            InventoryRepository ir = new InventoryRepository();

            this.totalInventoryLabel.Text = "Total Inventory : " + Convert.ToString(ir.countAllInventory());
            this.totalBikeILabel.Text     = "Bike :" + Convert.ToString(ir.countInventory("Bike"));
            this.totalCarILabel.Text      = "Car :" + Convert.ToString(ir.countInventory("Car"));
            this.totalAutoILabel.Text     = "Cng :" + Convert.ToString(ir.countInventory("Cng"));
            this.totalMicroILabel.Text    = "Microbus :" + Convert.ToString(ir.countInventory("Microbus"));
            this.totalPickupILabel.Text   = "Pickup :" + Convert.ToString(ir.countInventory("Pickup"));
            this.totalTruckILabel.Text    = "Truck :" + Convert.ToString(ir.countInventory("Truck"));


            //count all shipment

            ShipmentRepository sr = new ShipmentRepository();

            this.totalShipmentLabel.Text = "Total Shipment : " + Convert.ToString(sr.countAllShipment());
            this.atOriginLabel.Text      = "At Origin : " + Convert.ToString(sr.countShipment("At Origin"));
            this.onTheWayLabel.Text      = "On the Way : " + Convert.ToString(sr.countShipment("On the Way"));
            this.stuckedLabel.Text       = "Stucked : " + Convert.ToString(sr.countShipment("Stuked"));
            this.atDestinationLabel.Text = "At Destination : " + Convert.ToString(sr.countShipment("At Destination"));
            this.shippedLabel.Text       = "Shipped : " + Convert.ToString(sr.countShipment("Shipped"));



            this.dataGrid2.Visible = false;
            this.dataGrid3.Visible = false;
            this.dataGrid4.Visible = false;

            this.groupBox1.Visible = false;
            this.groupBox2.Visible = false;
        }
 public PlazaApiClient(OrderRepository orderRepository,
                       ShipmentRepository shipmentRepository,
                       ShippingLabelRepository shippingLabelRepository,
                       ReturnItemRepository returnItemRepository,
                       ProcessStatusRepository processStatusRepository)
 {
     OrderRepository         = orderRepository;
     ShipmentRepository      = shipmentRepository;
     ShippingLabelRepository = shippingLabelRepository;
     ReturnItemRepository    = returnItemRepository;
     ProcessStatusRepository = processStatusRepository;
 }
Esempio n. 17
0
        /// <summary>
        /// convert bol to list model
        /// </summary>
        /// <param name="bol"></param>
        /// <returns></returns>
        public BillOfLadingViewModel ConvertToListView(BillOfLading bol)
        {
            BillOfLadingViewModel model = new BillOfLadingViewModel();

            var _shipmentRepository        = new ShipmentRepository();
            var _foundryDynamicsRepository = new FoundryDynamicsRepository();
            var _vesselRepository          = new VesselRepository();
            var _portRepository            = new PortRepository();

            var shipment        = _shipmentRepository.GetShipment(bol.ShipmentId);
            var dynamicsFoundry = _foundryDynamicsRepository.GetFoundry(bol.FoundryId);
            var vessel          = _vesselRepository.GetVessel((shipment != null) ? shipment.VesselId : Guid.Empty);
            var port            = _portRepository.GetPort((shipment != null) ? shipment.PortId : Guid.Empty);

            model.BillOfLadingId    = bol.BillOfLadingId;
            model.ShipmentId        = bol.ShipmentId;
            model.BolNumber         = (!string.IsNullOrEmpty(bol.Number)) ? bol.Number : "N/A";
            model.FoundryName       = (dynamicsFoundry != null) ? dynamicsFoundry.VENDSHNM : "N/A";
            model.Description       = (!string.IsNullOrEmpty(bol.Description)) ? bol.Description : "N/A";
            model.VesselName        = (vessel != null && !string.IsNullOrEmpty(vessel.Name)) ? vessel.Name : "N/A";
            model.PortName          = (port != null && !string.IsNullOrEmpty(port.Name)) ? port.Name : "N/A";
            model.DepartureDate     = (shipment != null && shipment.DepartureDate != null) ? shipment.DepartureDate : DateTime.MinValue;
            model.DepartureDateStr  = (shipment != null) ? shipment.DepartureDate.ToShortDateString() : "N/A";
            model.EstArrivalDate    = (shipment != null && shipment.EstArrivalDate != null) ? shipment.EstArrivalDate : DateTime.MinValue;
            model.EstArrivalDateStr = (shipment != null) ? shipment.EstArrivalDate.Value.ToShortDateString() : "N/A";
            model.HasBeenAnalyzed   = bol.HasBeenAnalyzed;
            model.CreatedDate       = bol.CreatedDate;

            if (_shipmentRepository != null)
            {
                _shipmentRepository.Dispose();
                _shipmentRepository = null;
            }
            if (_foundryDynamicsRepository != null)
            {
                _foundryDynamicsRepository.Dispose();
                _foundryDynamicsRepository = null;
            }
            if (_vesselRepository != null)
            {
                _vesselRepository.Dispose();
                _vesselRepository = null;
            }
            if (_portRepository != null)
            {
                _portRepository.Dispose();
                _portRepository = null;
            }

            return(model);
        }
        public IHttpActionResult UploadBatteryForms()
        {
            try
            {
                var httpRequest = HttpContext.Current.Request;

                ShipmentRepository shipmentRepository = new ShipmentRepository();

                HttpFileCollection files = httpRequest.Files;
                int    ShipmentId        = Convert.ToInt32(httpRequest.Form["ShipmentId"].ToString());
                int    UserId            = Convert.ToInt32(httpRequest.Form["UserId"].ToString());
                var    docfiles          = new List <string>();
                string filePathToSave    = string.Format(FrayteTradelaneDocumentPath.ShipmentDocument, ShipmentId);
                string fileFullPath      = "";
                filePathToSave = HttpContext.Current.Server.MapPath(filePathToSave);

                if (!System.IO.Directory.Exists(filePathToSave))
                {
                    System.IO.Directory.CreateDirectory(filePathToSave);
                }

                //This code will execute only when user will upload the document
                if (files.Count > 0)
                {
                    HttpPostedFile file = files[0];
                    if (!string.IsNullOrEmpty(file.FileName))
                    {
                        if (!File.Exists(filePathToSave + file.FileName))
                        {
                            //Save in server folder
                            fileFullPath = filePathToSave + file.FileName;
                            file.SaveAs(fileFullPath);

                            //Save file name and other information in DB
                            FrayteResult result = new TradelaneBookingRepository().SaveShipmentDocument(ShipmentId, FrayteShipmentDocumentType.BatteryForm, file.FileName, UserId);
                            return(Ok(result));
                        }
                        else
                        {
                            return(BadRequest("BatteryForm"));
                        }
                    }
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
Esempio n. 19
0
        private void shipmentTab_Click(object sender, EventArgs e)
        {
            this.dataGrid2.Visible = false;
            this.dataGrid3.Visible = true;
            this.dataGrid4.Visible = false;

            this.groupBox1.Visible = false;
            this.groupBox2.Visible = true;

            this.groupBox3.Visible = false;
            this.groupBox4.Visible = false;
            this.groupBox5.Visible = false;


            ShipmentRepository shipment    = new ShipmentRepository();
            List <ShipmentR>   allShipment = shipment.GetAllShipment();

            this.dataGrid3.DataSource = allShipment;
        }
Esempio n. 20
0
        private bool LoadShipmentsByBoxId(BoxOutEntity boxEntity, DataGridView shipmentGrid)
        {
            ShipmentRepository _repositoryShipment = new ShipmentRepository();
            ShipmentExport     shipmentexport      = new ShipmentExport();

            try
            {
                if (boxEntity == null)
                {
                    shipmentGrid.DataSource = null;
                    return(false);
                }
                List <ShipmentExport> listShipment = _repositoryShipment.GetListShipmentByBoxId(boxEntity.Id);
                string       text    = "";
                DialogResult process = DialogResult.Yes;
                if (listShipment != null && listShipment.Count > 0)
                {
                    text   += "Tổng số đơn hàng: " + listShipment.Count;
                    text   += "\nXuất kho ngày " + boxEntity.DateCreated.ToString("dd/MM/yyyy");
                    text   += "\nBạn muốn mở không ?";
                    process = MessageBox.Show(text, boxEntity.BoxId, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                }
                if (process == DialogResult.Yes)
                {
                    if (listShipment != null)
                    {
                        AddShipmentListToGrid(listShipment, shipmentGrid);
                    }
                    return(true);
                }
                else
                {
                    shipmentGrid.DataSource = null;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Ultilities.FileHelper.WriteLog(Ultilities.ExceptionLevel.Function, "LoadShipmentsByBoxId", ex);
                return(false);
            }
        }
        public ActionResult Add()
        {
            // TODO: sanitize input and add AntiForgeryToken
            var userRepository = new UserRepository();

            User user = userRepository.GetUser(this.User.Identity.Name);

            this.ViewData.Add("UserFound", user != null);

            if (user == null)
            {
                return(this.View("New"));
            }
            EnrichUserWithClaims(user);
            var shipment = new Shipment
            {
                Id           = Guid.NewGuid(),
                ToAddress    = this.Request.Form["ShippingToAddress"],
                PickupDate   = DateTime.Parse(this.Request.Form["PickupDate"], CultureInfo.CurrentUICulture),
                ServiceType  = (ShipmentServiceType)Enum.Parse(typeof(ShipmentServiceType), this.Request.Form["ServiceType"]),
                Details      = this.Request.Form["Details"],
                Organization = user.Organization,
                Status       = ShipmentStatus.NotStarted,
                Sender       = user
            };

            shipment.CalculateFee();

            var repository = new ShipmentRepository();

            repository.SaveShipment(shipment);

            user.PreferredShippingServiceType = shipment.ServiceType;
            userRepository.UpdatePreferredShippingServiceType(user);

            return(this.RedirectToAction("Index"));
        }
Esempio n. 22
0
        public FrayteShipmentOriginatingAgentDetails GetOriginatingAgent(int shipmentId)
        {
            FrayteShipment shipment = new FrayteShipment();
            FrayteShipmentOriginatingAgentDetails newAgent = new FrayteShipmentOriginatingAgentDetails();
            FrayteAgent originatingAgent = new FrayteAgent();
            int?        agentId          = new AgentRepository().GetOriginatingId(shipmentId);

            if (agentId > 0)
            {
                originatingAgent = new AgentRepository().GetAgentDetail(agentId);
            }
            if (originatingAgent != null)
            {
                newAgent.DeliveryAddress = new FrayteAddress();
                newAgent.DeliveryAddress = originatingAgent.UserAddress;
            }

            shipment = new ShipmentRepository().GetShipmentDetail(shipmentId);
            if (shipment != null)
            {
                newAgent.ShipmentId = shipment.ShipmentId;
            }
            return(newAgent);
        }
        public ActionResult Cancel(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new InvalidOperationException("The value of id can not be null or empty.");
            }

            Guid shipmentId;

            try
            {
                shipmentId = new Guid(id);
            }
            catch (FormatException)
            {
                throw new InvalidOperationException("The value of id is incorrect.");
            }

            var repository = new ShipmentRepository();

            repository.DeleteShipment(shipmentId);

            return(this.RedirectToAction("Index"));
        }
        public AdminDashboard()
        {
            InitializeComponent();

            //marketing Info
            MarketingRepository mr = new MarketingRepository();

            //  this.totalCampaigns.Text = "Total Campaigns : " + Convert.ToString(mr.countAllCampaigns());

            // this.appCampaign.Text = "Approved Campaigns : " + Convert.ToString(mr.countAllApprovedCampaigns("Approved"));



            //Hr Info


            EmployeeRepository m = new EmployeeRepository();


            /*
             * EmployeeRepository m = new EmployeeRepository();
             * this.label123.Text += Convert.ToString(m.countAllEmployee());
             * this.label129.Text += Convert.ToString(m.countEmployee("Admin"));
             * this.label125.Text += Convert.ToString(m.countEmployee("Sales"));
             * this.label127.Text += Convert.ToString(m.countEmployee("Marketing"));
             * this.label124.Text += Convert.ToString(m.countEmployee("Human Resource"));
             * this.label126.Text += Convert.ToString(m.countEmployee("Accounting"));
             * this.label128.Text += Convert.ToString(m.countEmployee("Finance"));
             *
             * this.label120.Text += Convert.ToString(m.countAllStatus("Full Time"));
             * this.label119.Text += Convert.ToString(m.countAllStatus("Probationary"));
             * this.label118.Text += Convert.ToString(m.countAllStatus("Intern"));
             *
             *
             * this.label120.Text += Convert.ToString(m.countAllStatus("Full Time"));
             * this.label119.Text += Convert.ToString(m.countAllStatus("Probationary"));
             * this.label118.Text += Convert.ToString(m.countAllStatus("Intern"));*/

            this.hrGraph2.Visible = false;

            this.hrGraph.Series["emp"].Points.AddXY("Admin", m.countEmployee("Admin"));
            this.hrGraph.Series["emp"].Points.AddXY("Sales", m.countEmployee("Sales"));
            this.hrGraph.Series["emp"].Points.AddXY("HR", m.countEmployee("Human Resource"));
            this.hrGraph.Series["emp"].Points.AddXY("IT", m.countEmployee("IT"));
            this.hrGraph.Series["emp"].Points.AddXY("Accounts", m.countEmployee("Accounting"));
            this.hrGraph.Series["emp"].Points.AddXY("Finance", m.countEmployee("Finance"));
            this.hrGraph.Series["emp"].Points.AddXY("Marketing", m.countEmployee("Marketing"));

            this.hrGraph2.Series["Status"].Points.AddXY("Full Time", m.countAllStatus("Full Time"));
            this.hrGraph2.Series["Status"].Points.AddXY("Probationary", m.countAllStatus("Probationary"));
            this.hrGraph2.Series["Status"].Points.AddXY("Intern", m.countAllStatus("Intern"));

            //sales Info



            //get all the data
            // count the total order in groupBox3

            OrderRepository or = new OrderRepository();

            /*  this.label117.Text = "Total Order : " + Convert.ToString(or.countAllOrder());
             * this.label114.Text = "Bike : " + Convert.ToString(or.countOrder("Bike"));
             * this.label108.Text = "Car : " + Convert.ToString(or.countOrder("Car"));
             * this.label111.Text = "Cng : " + Convert.ToString(or.countOrder("Cng"));
             * this.label112.Text = "Microbus : " + Convert.ToString(or.countOrder("Microbus"));
             * this.label92.Text = "Pickup : " + Convert.ToString(or.countOrder("Pickup"));
             * this.label90.Text = "Truck : " + Convert.ToString(or.countOrder("Truck")); */


            /* this.orderGraph.Series["Order"].Points.AddXY("Bike:" + Convert.ToString(or.countOrder("Bike")), or.countOrder("Bike"));
             * this.orderGraph.Series["Order"].Points.AddXY("Car:" + Convert.ToString(or.countOrder("Car")), or.countOrder("Car") );
             * this.orderGraph.Series["Order"].Points.AddXY("Cng:" + Convert.ToString(or.countOrder("Cng")), or.countOrder("Cng"));
             * this.orderGraph.Series["Order"].Points.AddXY("Microbus:" + Convert.ToString(or.countOrder("Microbus")), or.countOrder("Microbus"));
             * this.orderGraph.Series["Order"].Points.AddXY("Pickup:" + Convert.ToString(or.countOrder("Pickup")), or.countOrder("Pickup"));
             * this.orderGraph.Series["Order"].Points.AddXY("Truck:"+ Convert.ToString(or.countOrder("Truck")), or.countOrder("Truck"));*/


            this.orderGraph.Series["Order"].Points.AddXY("Bike", or.countOrder("Bike"));
            this.orderGraph.Series["Order"].Points.AddXY("Car", or.countOrder("Car"));
            this.orderGraph.Series["Order"].Points.AddXY("Cng", or.countOrder("Cng"));
            this.orderGraph.Series["Order"].Points.AddXY("Microbus", or.countOrder("Microbus"));
            this.orderGraph.Series["Order"].Points.AddXY("Pickup", or.countOrder("Pickup"));
            this.orderGraph.Series["Order"].Points.AddXY("Truck", or.countOrder("Truck"));



            //count the total Inventory in groupBox4

            InventoryRepository ir = new InventoryRepository();

            /* this.label73.Text = "Total Inventory : " + Convert.ToString(ir.countAllInventory());
             * this.label138.Text = "Bike :" + Convert.ToString(ir.countInventory("Bike"));
             * this.label135.Text = "Car :" + Convert.ToString(ir.countInventory("Car"));
             * this.label136.Text = "Cng :" + Convert.ToString(ir.countInventory("Cng"));
             * this.label137.Text = "Microbus :" + Convert.ToString(ir.countInventory("Microbus"));
             * this.label134.Text = "Pickup :" + Convert.ToString(ir.countInventory("Pickup"));
             * this.label133.Text = "Truck :" + Convert.ToString(ir.countInventory("Truck")); */

            this.inventoryGraph.Series["Inventory"].Points.AddXY("Bike", ir.countInventory("Bike"));
            this.inventoryGraph.Series["Inventory"].Points.AddXY("Car", ir.countInventory("Car"));
            this.inventoryGraph.Series["Inventory"].Points.AddXY("Cng", ir.countInventory("Cng"));
            this.inventoryGraph.Series["Inventory"].Points.AddXY("Microbus", ir.countInventory("Microbus"));
            this.inventoryGraph.Series["Inventory"].Points.AddXY("Pickup", ir.countInventory("Pickup"));
            this.inventoryGraph.Series["Inventory"].Points.AddXY("Truck", ir.countInventory("Truck"));


            //count all shipment

            ShipmentRepository sr = new ShipmentRepository();

            /*  this.label52.Text = "Total Shipment : " + Convert.ToString(sr.countAllShipment());
             * this.label72.Text = "At Origin : " + Convert.ToString(sr.countShipment("At Origin"));
             * this.label66.Text = "On the Way : " + Convert.ToString(sr.countShipment("On the Way"));
             * this.label70.Text = "Stucked : " + Convert.ToString(sr.countShipment("Stuked"));
             * this.label71.Text = "At Destination : " + Convert.ToString(sr.countShipment("At Destination"));
             * this.label68.Text = "Shipped : " + Convert.ToString(sr.countShipment("Shipped")); */

            this.shipmentGraph.Series["Shipment"].Points.AddXY("At Origin", sr.countShipment("At Origin"));
            this.shipmentGraph.Series["Shipment"].Points.AddXY("On the Way", sr.countShipment("On the Way"));
            this.shipmentGraph.Series["Shipment"].Points.AddXY("Stucked", sr.countShipment("Stuked"));
            this.shipmentGraph.Series["Shipment"].Points.AddXY("At Destination", sr.countShipment("At Destination"));
            this.shipmentGraph.Series["Shipment"].Points.AddXY("Shipped", sr.countShipment("Shipped"));

            //accounting

            AccountingRepository ar = new AccountingRepository();
            //  this.totalCashLabel.Text = "totalCash : " + Convert.ToString(ar.countTotalCash());
        }
Esempio n. 25
0
        public NotificationResultViewModel SendUpcomingBoxNotifications()
        {
            try
            {
                int notificationsSent = 0;

                Stopwatch sw = new Stopwatch();
                sw.Start();

                using (ManBoxEntities ent = new ManBoxEntities())
                {
                    var upcomingDeliveries = from sd in ent.SubscriptionDeliveries
                                             where sd.DeliveryStateCV == CodeValues.DeliveryState.Pending &&
                                             sd.Subscription.GiftId == null &&
                                             sd.Subscription.SubscriptionStateCV == CodeValues.SubscriptionState.Subscribed &&
                                             EntityFunctions.AddDays(sd.DeliveryDate.Value, -daysBefore).Value < DateTime.Now &&
                                             !sd.SubscriptionDeliveryMessages.Any(m => m.DeliveryMessageTypeCV == CodeValues.DeliveryMessageType.Upcoming)
                                             select new
                    {
                        SubscriptionDelivery = sd,
                        Name       = sd.Subscription.User.FirstName,
                        Token      = sd.Subscription.Token,
                        Email      = sd.Subscription.User.Email,
                        LangIso    = sd.Subscription.User.Language.IsoCode,
                        CountryIso = sd.Subscription.User.Country.IsoCode,
                        Address    = sd.Subscription.Address,
                        Products   = from m in sd.SubscriptionDeliveryModels
                                     select new
                        {
                            ProductName = (from tt in ent.TranslationTexts where tt.TranslationId == m.Model.Product.TitleTrId && tt.LanguageId == sd.Subscription.User.LanguageId select tt.Text).FirstOrDefault(),
                            ModelName   = m.Model.Name,
                            Quantity    = m.Quantity,
                            Price       = m.Model.ShopPrice,
                            TotalPrice  = m.Model.ShopPrice * m.Quantity
                        }
                    };

                    var notificationMails = new List <UpcomingBoxNotificationMail>();

                    foreach (var del in upcomingDeliveries)
                    {
                        var itemsTotal   = Utilities.GetDeliveryTotal(del.SubscriptionDelivery);
                        var shippingFee  = Utilities.CalculateShippingFee(itemsTotal);
                        var couponAmount = Utilities.CalculateCouponAmount(itemsTotal, del.SubscriptionDelivery);
                        var total        = itemsTotal + shippingFee - couponAmount;
                        var couponLabel  = Utilities.GetCouponLabel(del.SubscriptionDelivery.Coupon);

                        var products         = new List <MailProduct>();
                        var notificationMail = new UpcomingBoxNotificationMail()
                        {
                            Name        = del.Name,
                            Email       = del.Email,
                            Token       = del.Token,
                            LanguageIso = del.LangIso,
                            CountryIso  = del.CountryIso,
                            Address     = new MailAddress()
                            {
                                City       = del.Address.City,
                                Street     = del.Address.Street,
                                Province   = del.Address.Province,
                                PostalCode = del.Address.PostalCode
                            },
                            SubTotal     = itemsTotal,
                            Total        = total,
                            ShippingFee  = shippingFee,
                            CouponAmount = couponAmount,
                            CouponLabel  = couponLabel
                        };

                        foreach (var prod in del.Products)
                        {
                            products.Add(new MailProduct()
                            {
                                ModelName   = prod.ModelName,
                                ProductName = prod.ProductName,
                                Price       = prod.Price,
                                Quantity    = prod.Quantity,
                                TotalPrice  = prod.TotalPrice
                            });
                        }

                        notificationMail.Products = products;

                        SendMail(notificationMail);
                        ShipmentRepository.StoreDeliveryMessage(del.SubscriptionDelivery, CodeValues.DeliveryMessageType.Upcoming);

                        notificationsSent++;
                    }

                    sw.Stop();
                    ent.SaveChanges();
                }

                return(new NotificationResultViewModel()
                {
                    NotificationsSent = notificationsSent,
                    EndedDateTime = DateTime.Now,
                    ElapsedTime = sw.Elapsed,
                    MessageType = CodeValues.DeliveryMessageType.Upcoming
                });
            }
            catch (Exception e)
            {
                logger.Log(e);
                throw;
            }
        }
Esempio n. 26
0
        public IHttpActionResult UploadOtherDocument()
        {
            try
            {
                int id          = 0;
                var httpRequest = HttpContext.Current.Request;
                ShipmentRepository shipmentRepository = new ShipmentRepository();
                HttpFileCollection files = httpRequest.Files;
                //This code will execute only when user will upload the document
                if (files.Count > 0)
                {
                    int ShipmentId = Convert.ToInt32(httpRequest.Form["ShipmentId"].ToString());
                    int CustomerId = Convert.ToInt32(httpRequest.Form["CustomerId"].ToString());
                    int UserId     = Convert.ToInt32(httpRequest.Form["UserId"].ToString());
                    int HubId      = Convert.ToInt32(httpRequest.Form["HubId"].ToString());

                    var docfiles = new List <string>();

                    // Entry in tradelane tables
                    id = new ExpressManifestRepository().TradelaneEntryFromManifest(ShipmentId, UserId, CustomerId, HubId);

                    string filePathToSave = string.Format(FrayteTradelaneDocumentPath.ShipmentDocument, id);
                    string fileFullPath   = "";
                    filePathToSave = HttpContext.Current.Server.MapPath(filePathToSave);

                    if (!System.IO.Directory.Exists(filePathToSave))
                    {
                        System.IO.Directory.CreateDirectory(filePathToSave);
                    }

                    HttpPostedFile file = files[0];
                    if (!string.IsNullOrEmpty(file.FileName))
                    {
                        if (!File.Exists(filePathToSave + file.FileName))
                        {
                            //Save in server folder
                            fileFullPath = filePathToSave + file.FileName;
                            file.SaveAs(fileFullPath);

                            //Save file name and other information in DB
                            FrayteResult result = new TradelaneBookingRepository().SaveShipmentDocument(id, FrayteShipmentDocumentType.OtherDocument, file.FileName, UserId);

                            if (result.Status)
                            {
                                return(Ok(id));
                            }
                            else
                            {
                                return(BadRequest("OtherDocument"));
                            }
                        }
                        else
                        {
                            return(BadRequest("OtherDocument"));
                        }
                    }
                }
                if (id > 0)
                {
                    return(Ok(id));
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
Esempio n. 27
0
        public Sales()
        {
            InitializeComponent();



            this.dataGrid2.Visible = false;
            this.dataGrid3.Visible = false;
            this.dataGrid4.Visible = false;

            this.groupBox1.Visible = false;
            this.groupBox2.Visible = false;

            //dashBoard text
            this.groupBox3.Visible = true;
            this.groupBox4.Visible = true;
            this.groupBox5.Visible = true;

            // init the ID from inventory table in this combobox
            InventoryRepository m     = new InventoryRepository();
            List <string>       allId = m.GetAllId();

            foreach (string id in allId)
            {
                this.comboBox1.Items.Add(id);
            }


            OrderRepository or = new OrderRepository();

            this.totalOrderLabel.Text  = "Total Order : " + Convert.ToString(or.countAllOrder());
            this.totalBikeLabel.Text   = "Bike : " + Convert.ToString(or.countOrder("Bike"));
            this.totalCarLabel.Text    = "Car : " + Convert.ToString(or.countOrder("Car"));
            this.totalAutoLabel.Text   = "Cng : " + Convert.ToString(or.countOrder("Cng"));
            this.totalMicroLabel.Text  = "Microbus : " + Convert.ToString(or.countOrder("Microbus"));
            this.totalPickupLabel.Text = "Pickup : " + Convert.ToString(or.countOrder("Pickup"));
            this.totalTruckLabel.Text  = "Truck : " + Convert.ToString(or.countOrder("Truck"));


            //count the total Inventory in groupBox4

            InventoryRepository ir = new InventoryRepository();

            this.totalInventoryLabel.Text = "Total Inventory : " + Convert.ToString(ir.countAllInventory());
            this.totalBikeILabel.Text     = "Bike :" + Convert.ToString(ir.countInventory("Bike"));
            this.totalCarILabel.Text      = "Car :" + Convert.ToString(ir.countInventory("Car"));
            this.totalAutoILabel.Text     = "Cng :" + Convert.ToString(ir.countInventory("Cng"));
            this.totalMicroILabel.Text    = "Microbus :" + Convert.ToString(ir.countInventory("Microbus"));
            this.totalPickupILabel.Text   = "Pickup :" + Convert.ToString(ir.countInventory("Pickup"));
            this.totalTruckILabel.Text    = "Truck :" + Convert.ToString(ir.countInventory("Truck"));


            //count all shipment

            ShipmentRepository sr = new ShipmentRepository();

            this.totalShipmentLabel.Text = "Total Shipment : " + Convert.ToString(sr.countAllShipment());
            this.atOriginLabel.Text      = "At Origin : " + Convert.ToString(sr.countShipment("At Origin"));
            this.onTheWayLabel.Text      = "On the Way : " + Convert.ToString(sr.countShipment("On the Way"));
            this.stuckedLabel.Text       = "Stucked : " + Convert.ToString(sr.countShipment("Stuked"));
            this.atDestinationLabel.Text = "At Destination : " + Convert.ToString(sr.countShipment("At Destination"));
            this.shippedLabel.Text       = "Shipped : " + Convert.ToString(sr.countShipment("Shipped"));
        }
Esempio n. 28
0
        public FrayteCustomerAddressBookExcel UploadAddressBookExcel(int CustomerId)
        {
            FrayteCustomerAddressBookExcel frayteAddressBookexcel = new FrayteCustomerAddressBookExcel();

            var httpRequest = HttpContext.Current.Request;

            if (httpRequest.Files.Count > 0)
            {
                HttpFileCollection files = httpRequest.Files;

                HttpPostedFile file = files[0];

                if (!string.IsNullOrEmpty(file.FileName))
                {
                    string connString = "";
                    string filename   = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss_") + file.FileName;
                    string filepath   = HttpContext.Current.Server.MapPath("~/UploadFiles/" + filename);

                    file.SaveAs(filepath);

                    connString = new ShipmentRepository().getExcelConnectionString(filename, filepath);
                    string fileExtension = new DirectShipmentRepository().getFileExtensionString(filename);

                    if (!string.IsNullOrEmpty(fileExtension))
                    {
                        OleDbConnection oledbConn = new OleDbConnection(connString);
                        try
                        {
                            DataSet ds = new DataSet();
                            if (fileExtension == FrayteFileExtension.CSV)
                            {
                                oledbConn.Open();
                                OleDbCommand     cmd   = new OleDbCommand("SELECT * FROM [" + Path.GetFileName(filename) + "]", oledbConn);
                                OleDbDataAdapter oleda = new OleDbDataAdapter();
                                oleda.SelectCommand = cmd;
                                oleda.Fill(ds, "AddressBook");
                            }
                            else
                            {
                                oledbConn.Open();
                                DataTable dbSchema       = oledbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                                string    firstSheetName = dbSchema.Rows[0]["TABLE_NAME"].ToString();
                                var       query          = "SELECT * FROM " + "[" + firstSheetName + "]";
                                using (var adapter = new OleDbDataAdapter(query, oledbConn))
                                {
                                    adapter.Fill(ds, "AddressBook");
                                }
                            }

                            var exceldata = ds.Tables[0];

                            string AddressBookColumn = "FirstName,LastName,CompanyName,Email,PhoneNo,Address1,Area,Address2,City,State,Zip,CountryName";
                            bool   IsExcelValid      = new CustomerRepository().CheckUploadExcelColumns(AddressBookColumn, exceldata);
                            if (!IsExcelValid)
                            {
                                frayteAddressBookexcel.Status    = false;
                                frayteAddressBookexcel.RowErrors = new List <string>();
                                frayteAddressBookexcel.RowErrors.Add("Columns are not matching with provided template columns. Please check the column names.");
                                return(frayteAddressBookexcel);
                            }
                            else
                            {
                                if (exceldata != null && exceldata.Rows.Count > 0)
                                {
                                    List <string> _errorrows = new List <string>();
                                    List <FrayteCustomerAddressBook> _addressbook = new CustomerRepository().GetAddressBookDetail(CustomerId, exceldata, ref _errorrows);
                                    if (_errorrows.Count > 0)
                                    {
                                        frayteAddressBookexcel.Status    = false;
                                        frayteAddressBookexcel.RowErrors = new List <string>();
                                        frayteAddressBookexcel.RowErrors = _errorrows;
                                        return(frayteAddressBookexcel);
                                    }
                                    else
                                    {
                                        List <string> _lengtherror = new CustomerRepository().ValidateAddressBookDataLength(_addressbook);
                                        if (_lengtherror.Count > 0)
                                        {
                                            frayteAddressBookexcel.Status    = false;
                                            frayteAddressBookexcel.RowErrors = new List <string>();
                                            frayteAddressBookexcel.RowErrors = _lengtherror;
                                            return(frayteAddressBookexcel);
                                        }
                                        else
                                        {
                                            bool IsInserted = new CustomerRepository().InsertCustomerAddressBook(_addressbook);
                                            if (!IsInserted)
                                            {
                                                frayteAddressBookexcel.Status    = false;
                                                frayteAddressBookexcel.RowErrors = new List <string>();
                                                frayteAddressBookexcel.RowErrors.Add("Address Book Can Not Save");
                                                return(frayteAddressBookexcel);
                                            }
                                            else
                                            {
                                                frayteAddressBookexcel.Status = true;
                                                return(frayteAddressBookexcel);
                                            }
                                        }
                                    }
                                }
                                oledbConn.Close();
                                if ((System.IO.File.Exists(filepath)))
                                {
                                    System.IO.File.Delete(filepath);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        finally
                        {
                            oledbConn.Close();
                            if ((System.IO.File.Exists(filepath)))
                            {
                                System.IO.File.Delete(filepath);
                            }
                        }
                    }
                }
            }
            return(frayteAddressBookexcel);
        }
Esempio n. 29
0
        public IHttpActionResult UploadCustomers()
        {
            List <FrayteCustomer> frayteCustomers = new List <FrayteCustomer>();

            var httpRequest = HttpContext.Current.Request;

            if (httpRequest.Files.Count > 0)
            {
                HttpFileCollection files = httpRequest.Files;

                HttpPostedFile file = files[0];

                if (!string.IsNullOrEmpty(file.FileName))
                {
                    string connString = "";
                    string filename   = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss_") + file.FileName;
                    string filepath   = HttpContext.Current.Server.MapPath("~/UploadFiles/" + filename);

                    file.SaveAs(filepath);

                    connString = new ShipmentRepository().getExcelConnectionString(filename, filepath);

                    OleDbConnection oledbConn = new OleDbConnection(connString);
                    try
                    {
                        oledbConn.Open();
                        OleDbCommand     cmd   = new OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
                        OleDbDataAdapter oleda = new OleDbDataAdapter();
                        oleda.SelectCommand = cmd;
                        DataSet ds = new DataSet();
                        oleda.Fill(ds, "Customers");

                        var exceldata = ds.Tables[0];

                        if (exceldata != null && exceldata.Rows.Count > 0)
                        {
                            if (new CustomerRepository().CheckValidExcel(exceldata))
                            {
                                frayteCustomers = new CustomerRepository().GetAllCustomers(exceldata);

                                foreach (var customer in frayteCustomers)
                                {
                                    FrayteResult result = new CustomerRepository().SaveCustomer(customer);
                                }
                            }
                            else
                            {
                                return(BadRequest("Excel file not valid"));
                            }
                        }
                        oledbConn.Close();
                        if ((System.IO.File.Exists(filepath)))
                        {
                            System.IO.File.Delete(filepath);
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        oledbConn.Close();
                        if ((System.IO.File.Exists(filepath)))
                        {
                            System.IO.File.Delete(filepath);
                        }
                    }
                }
            }

            return(Ok(frayteCustomers));
        }
Esempio n. 30
0
        private void ShipOrderbtn_Click(object sender, EventArgs e)
        {
            ShipmentR i = new ShipmentR();

            i.OrderId          = this.orderIdTxt.Text;
            i.ShipmentProgress = 0;
            i.Status           = "";
            ShipmentRepository shipRepo = new ShipmentRepository();

            //insert into shipment table if the product is sufficient in inventory
            if (Convert.ToInt32(this.quantityTxt.Text) <= Convert.ToInt32(this.textBox7.Text))
            {
                if (shipRepo.Insert(i))
                {
                    //---------------update the volume in inventory after successful shipment-----------------//

                    int latestVolume       = Convert.ToInt32(this.textBox7.Text) - Convert.ToInt32(this.quantityTxt.Text);
                    InventoryRepository ir = new InventoryRepository();
                    if (ir.updateInventory(this.productIdTxt.Text, latestVolume))
                    {
                        MessageBox.Show("One Row Updated in Inventory");
                    }
                    else
                    {
                        MessageBox.Show("Can't update inventory", "Update Error");
                    }

                    //---------------Update and hide From Order Tabel after Shipment-----------------//
                    OrderRepository or = new OrderRepository();

                    if (or.updateStatus(this.orderIdTxt.Text))
                    {
                        MessageBox.Show("Order Updated");
                    }
                    else
                    {
                        MessageBox.Show("unSuccessfull order update", "Update Error");
                    }

                    MessageBox.Show("Succsfull ", "Shipment");

                    //---------------refresh the order Grid-----------------//

                    List <OrderR> order = new List <OrderR>();
                    order = or.GetAllOrder();
                    this.dataGrid2.DataSource = order;

                    this.orderIdTxt.Text      = "";
                    this.productIdTxt.Text    = "";
                    this.productNameTxt.Text  = "";
                    this.quantityTxt.Text     = "";
                    this.addressTxt.Text      = "";
                    this.employeeNameTxt.Text = "";
                }
                else
                {
                    MessageBox.Show("Can Not Ship Order", "Ship Error");
                }
            }
            else
            {
                MessageBox.Show("Unsufficient amount of Product", "Available Error");
            }
        }