Exemple #1
0
        private void AllocateButton_Click(object sender, EventArgs e)
        {
            if (getSelectedShipmentIds().Count > 0)
            {
                if (AssignUnassignButton.Text == "Assign")
                {
                    ShipmentAllocator shpAllocator = new ShipmentAllocator(podDbConn);
                    shpAllocator.PopulateEmployees();

                    DialogResult shpAllocatorReturn = shpAllocator.ShowDialog();
                    long         employeeId         = shpAllocator.SelectedContact;

                    if (shpAllocatorReturn == DialogResult.OK && (employeeId != 0))
                    {
                        ShipmentManager shpMgr    = new ShipmentManager(_companyCode, _userCode);
                        string          strErrors = "";
                        shpMgr.assignShipments(getSelectedShipmentIds(), employeeId, false, strErrors);
                    }

                    //remove all that were selected
                    removeSelectedShipmentIds();
                }
                else if (AssignUnassignButton.Text == "Un-Assign")
                {
                    ShipmentManager shpMgr = new ShipmentManager(_companyCode, _userCode);
                    shpMgr.unassignShipments(podDbConn, getSelectedShipmentIds());

                    //remove all that were selected
                    removeSelectedShipmentIds();
                }
            }
            return;
        }
Exemple #2
0
        private void PopulateShipmentGrid(ShipmentManager.ASSIGNMENT_STATUS shipmentAsignmentStatus)
        {
            try
            {
                podDbConn.Open();
                PODManager.ShipmentManager shpMgr = new ShipmentManager(_companyCode, _userCode);
                shpMgr.DBConnection = podDbConn;

                Dictionary <long, Shipment> shpments = new Dictionary <long, Shipment>();

                shpments = shpMgr.getShipmentsByStatus(shipmentAsignmentStatus);
                if (shpments.Count > 0)
                {
                    System.Console.WriteLine("shipment from DB by status = " + shpments[21].toXML(true).InnerXml);
                }

                Shipment shp21 = shpMgr.getShipmentByID(21);
                System.Console.WriteLine("shipment from DB by ID = " + shp21.toXML(true).InnerXml);


                Dictionary <long, Shipment> shpments2 = shpMgr.getShipmentsByStatusTest();
                System.Console.WriteLine("Test shipment = " + shpments2[1001].toXML(true).InnerXml);

                Dictionary <long, Contact> employees = shpMgr.getEmployeesForAssignment();

                if (employees.Count > 0)
                {
                    System.Console.WriteLine("Employee from DB, Full Name = " + employees[82].FullName
                                             + ", Phone Number = " + employees[82].PhoneNumber);
                }

                if (podDbConn.State == ConnectionState.Open)
                {
                    podDbConn.Close();
                }


                // Test Assignments
                List <ShipmentVersion> shipmentVersions = new List <ShipmentVersion>(5);
                ShipmentVersion        shpVrsn1         = new ShipmentVersion(5, 21);
                ShipmentVersion        shpVrsn2         = new ShipmentVersion(6, 23);
                ShipmentVersion        shpVrsn3         = new ShipmentVersion(7, 24);

                shipmentVersions.Add(shpVrsn1);
                shipmentVersions.Add(shpVrsn2);
                shipmentVersions.Add(shpVrsn3);

                Contact empForAssignment = new Contact(5, 82, Contact.CONTACT_TYPE.EMPLOYEE);

                String strRetErrors         = "";
                bool   bAssignmentSucceeded = shpMgr.assignShipments(shipmentVersions, empForAssignment, false, strRetErrors);


                DataTable  UndeliverredShipmentsTable = new DataTable("UnDeliveredShipments");
                DataColumn colShipmentId           = new DataColumn("Shipment ID", typeof(long));
                DataColumn colShipmentSrc          = new DataColumn("Shipment Source", typeof(String));
                DataColumn colShipmentSrcRef       = new DataColumn("Shipment Ref", typeof(String));
                DataColumn colShipmentIsDeliverred = new DataColumn("Deliver To", typeof(String));


                UndeliverredShipmentsTable.Columns.Add(colShipmentId);
                UndeliverredShipmentsTable.Columns.Add(colShipmentSrc);
                UndeliverredShipmentsTable.Columns.Add(colShipmentSrcRef);
                UndeliverredShipmentsTable.Columns.Add(colShipmentIsDeliverred);

                if (shipmentAsignmentStatus == ShipmentManager.ASSIGNMENT_STATUS.ASSIGNED)
                {
                    DataColumn colShipmentAllocatedTo = new DataColumn("Allocated To", typeof(String));
                    UndeliverredShipmentsTable.Columns.Add(colShipmentAllocatedTo);
                }

                Dictionary <long, Shipment> .Enumerator shipEnum = shpments.GetEnumerator();
                while (shipEnum.MoveNext())
                {
                    PODBusinessObjects.Shipment currShipment = shipEnum.Current.Value;
                    DataRow currRow = UndeliverredShipmentsTable.NewRow();
                    currRow[0] = currShipment.ShipmentId;
                    currRow[1] = currShipment.ShipmentSrc;
                    currRow[2] = currShipment.ShipmentRef;
                    currRow[3] = currShipment.DeliverToAddress;
                    if (shipmentAsignmentStatus == ShipmentManager.ASSIGNMENT_STATUS.ASSIGNED)
                    {
                        currRow[4] = currShipment.getAssignedTo();
                    }

                    UndeliverredShipmentsTable.Rows.Add(currRow);
                }

                ShipmentDataGridView.DataSource = UndeliverredShipmentsTable;
            }
            catch (SqlException sqlExp)
            {
                System.Console.WriteLine("Exception : " + sqlExp.ToString());
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception : " + ex.ToString());
            }

            finally
            {
                podDbConn.Close();
            }
        }