Ejemplo n.º 1
0
        ////////////////////////////////////////////////////////////
        // Saves the Manifest and Cargo Pieces to external database
        // file. Closes out the form and opens Main
        private void btnSave_Click(object sender, EventArgs e)
        {
            var valid = _fieldValidation(txtBoxTCN.Text, cmbBoxDepo.Text, txtBoxDest.Text, cmbBoxAsset.Text, cmbBoxRecv.Text);

            if (valid && (_dt.Rows.Count >= 1))
            {
                foreach (RollingStock t in _rollingstock)
                {
                    CShipment cs = new CShipment(txtBoxTCN.Text, cmbBoxDepo.Text, cmbBoxAsset.Text, txtBoxDest.Text,
                                                 t.Tcn, cmbBoxRecv.Text);
                    _ridsDriver.CreateCargoShipment(cs);
                }
                foreach (Container t in _container)
                {
                    CShipment cs = new CShipment(txtBoxTCN.Text, cmbBoxDepo.Text, cmbBoxAsset.Text, txtBoxDest.Text,
                                                 t.Tcn, cmbBoxRecv.Text);
                    _ridsDriver.CreateCargoShipment(cs);
                }

                _ridsDriver.CreateCargoShipment(_rollingstock, _container);
                _ridsDriver.WriteCargoShipment();

                _dt.Clear();

                MessageBox.Show(@"Cargo manifest has been saved!");

                Close();
                Main m = new Main();
                m.Show();
            }
            else
            {
                MessageBox.Show(@"Please fill out required fields");
            }
        }
Ejemplo n.º 2
0
        //*****************************************************************************
        // CreateCargoShipment Function
        // This function creates a CargoShipment Object and returns it
        //*****************************************************************************
        public CShipment CreateCargoShipment(string tcn, string deposition,
                                             string asset, string destination, string ptcn, string recievedby)
        {
            CShipment cs = new CShipment(tcn, deposition, asset, destination,
                                         ptcn, recievedby);

            return(cs);
        }
Ejemplo n.º 3
0
        //*********************************************************************
        // Function that imports data from another RIDS file
        //*********************************************************************
        public void ImportData(string sourcefile)
        {
            try
            {
                StreamReader file  = new StreamReader(sourcefile);
                var          hline = file.ReadLine();
                if (hline != null)
                {
                    _manifestHeaders = hline.Split(',');
                }

                while (!file.EndOfStream)
                {
                    var line = file.ReadLine();
                    if (line != null)
                    {
                        string[]  row = line.Split(',');
                        CShipment cs  = new CShipment(row[0], row[4], row[16],
                                                      row[18], row[5], row[17]);
                        _tempcsList.Add(cs);
                        CargoPiece cp = new CargoPiece(row[5], row[6], row[1],
                                                       row[7], row[9], row[4],
                                                       RevertBool(row[11]), RevertBool(row[12]),
                                                       RevertBool(row[13]), RevertBool(row[14]),
                                                       row[19], Convert.ToDateTime(row[3]));
                        TempcpList.Add(cp);
                        if (row[6] == "Rolling Stock")
                        {
                            RollingStock rs = new RollingStock(row[5], row[6],
                                                               row[1], row[7], row[8],
                                                               RevertBool(row[10]), row[9], row[4],
                                                               RevertBool(row[11]), RevertBool(row[12]),
                                                               RevertBool(row[13]), RevertBool(row[14]),
                                                               row[19], Convert.ToDateTime(row[3]));
                            _tempRsList.Add(rs);
                        }
                        else
                        {
                            Container c = new Container(row[5], row[6], row[7],
                                                        row[1], row[9], row[4], row[8],
                                                        RevertBool(row[15]), RevertBool(row[11]),
                                                        RevertBool(row[12]), RevertBool(row[13]),
                                                        RevertBool(row[14]),
                                                        row[19], Convert.ToDateTime(row[3]));
                            _tempcList.Add(c);
                        }
                    }
                }
                file.Close();
                WriteCargoShipment();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex));
            }
        }
Ejemplo n.º 4
0
        //*********************************************************************
        // Function used to create cargo pieces
        //*********************************************************************
        public void AddCargoPiece(string tcn, string cargotype,
                                  string unitowner, string idNumber, string destination,
                                  string deposition, bool isSensitive, bool isDamaged,
                                  bool isHazmat, bool isHighVis, string comments, DateTime dateTime)
        {
            CShipment  cs = new CShipment();
            CargoPiece cp = cs.AddCargoPiece(idNumber, destination, cargotype,
                                             unitowner, deposition, tcn, comments,
                                             isSensitive, isDamaged, isHazmat, isHighVis, dateTime);

            TempcpList.Add(cp);
        }
Ejemplo n.º 5
0
        //*********************************************************************
        // Function Called to Create cargo shipment from Create manifest form
        //*********************************************************************
        public void CreateCargoShipment(CShipment cs)
        {
            User      u  = new User();
            CShipment CS = u.CreateCargoShipment(cs.Tcn, cs.Deposition,
                                                 cs.Asset, cs.Destination, cs.PieceTcn,
                                                 cs.RecievedBy);

            if (CS == null)
            {
                throw new ArgumentNullException(nameof(CS));
            }
            _tempcsList.Add(CS);
        }
Ejemplo n.º 6
0
        //*********************************************************************
        // Function used to load cargo information from Log File
        //*********************************************************************
        public void LoadCargoShipments()
        {
            try
            {
                if (File.Exists(@"AddCargoLog.csv"))
                {
                    StreamReader file  = new StreamReader(@"AddCargoLog.csv");
                    var          hline = file.ReadLine();
                    if (hline != null)
                    {
                        _manifestHeaders = hline.Split(',');
                    }

                    while (!file.EndOfStream)
                    {
                        var line = file.ReadLine();
                        if (line != null)
                        {
                            string[]  row = line.Split(',');
                            CShipment cs  = new CShipment(row[0], row[1], row[3]
                                                          , row[2], row[5], row[4]);
                            CsList.Add(cs);
                            CargoPiece cp = new CargoPiece(row[5], row[6],
                                                           row[9], row[7], row[11], row[10],
                                                           Convert.ToBoolean(row[14]),
                                                           Convert.ToBoolean(row[16]),
                                                           Convert.ToBoolean(row[13]),
                                                           Convert.ToBoolean(row[15]), row[18],
                                                           Convert.ToDateTime(row[19]));
                            CpList.Add(cp);
                            if (row[6] == "Rolling Stock")
                            {
                                RollingStock rs = new RollingStock(row[5],
                                                                   row[6], row[9], row[7], row[8],
                                                                   Convert.ToBoolean(row[12]), row[11],
                                                                   row[10], Convert.ToBoolean(row[14]),
                                                                   Convert.ToBoolean(row[16]),
                                                                   Convert.ToBoolean(row[13]),
                                                                   Convert.ToBoolean(row[15]),
                                                                   row[18], Convert.ToDateTime(row[19]));
                                RsList.Add(rs);
                            }
                            else
                            {
                                Container c = new Container(row[5], row[6],
                                                            row[7], row[9], row[11], row[10], row[8],
                                                            Convert.ToBoolean(row[17]),
                                                            Convert.ToBoolean(row[14]),
                                                            Convert.ToBoolean(row[16]),
                                                            Convert.ToBoolean(row[13]),
                                                            Convert.ToBoolean(row[15]),
                                                            row[18], Convert.ToDateTime(row[19]));
                                CList.Add(c);
                            }
                        }
                    }
                    file.Close();
                }
                else
                {
                    StreamWriter file = new StreamWriter(@"AddCargoLog.csv");
                    file.WriteLine("TCN" + "," + "Deposition" + "," +
                                   "Destination" + "," + "Asset" + "," + "Recieved By" +
                                   "," + "Piece TCN" + "," + "Cargo Type" + "," +
                                   "Piece ID" + "," + "Description" + "," + "Unit Owner" +
                                   "," + "Deposition" + "," + "Destination" + "," +
                                   "Drivable" + "," + "Hazmat" + "," + "Sensitive Item"
                                   + "," + "High Visabilty" + "," + "Damaged" + "," +
                                   "Trained Pallet" + "," + "Comments" + "," + "Date");
                    file.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex));
            }
        }