コード例 #1
0
ファイル: Order.cs プロジェクト: Etheraex/LV1OOP
        public static Order ReadOrderFromFile(System.IO.StreamReader file)
        {
            try
            {
                String   skip         = file.ReadLine();        // Linija sa znakovima jednakosti za razdvajanje pojedinacnih ordera
                String   loadString   = file.ReadLine();
                String[] splitStrings = loadString.Split(' ');

                int idTmp;
                int tmp = CheckId(splitStrings[0]);
                if (tmp == 0)
                {
                    throw new Exception("Pogresna id vrednost");
                }
                else
                {
                    idTmp = tmp;
                }

                DateTime dateTmp    = DateTimeFromString(splitStrings[1]);
                DateTime dateReqTmp = DateTimeFromString(splitStrings[2]);

                if (dateTmp == DateTime.MinValue || dateReqTmp == DateTime.MinValue || dateReqTmp < dateTmp)
                {
                    throw new Exception("Pogresna vrednost datuma");
                }

                State statusTmp = Order.ConvertStringToState(splitStrings[3]);

                DateTime dateShipped;
                double   freightCostTmp;

                if (!DateTime.TryParseExact(file.ReadLine(), "d.M.yyyy", null, DateTimeStyles.None, out dateShipped))
                {
                    dateShipped = DateTime.MinValue;
                }

                String shipCompanyTmp = file.ReadLine();
                if (!double.TryParse(file.ReadLine(), out freightCostTmp))
                {
                    freightCostTmp = 0;
                }

                Customer    customerTmp = Customer.ReadFromFile(file);
                PackageList packagesTmp = PackageList.ReadFromFile(file);

                Order orderTmp = new Order(idTmp, dateTmp, dateReqTmp, statusTmp, customerTmp, packagesTmp, shipCompanyTmp, freightCostTmp, dateShipped);
                return(orderTmp);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Greska pri izvrsenju", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(null);
        }
コード例 #2
0
ファイル: Order.cs プロジェクト: Etheraex/LV1OOP
 public Order(int id, DateTime orderDate, DateTime requiredDate, State stat, Customer cust, PackageList packages, String shipCo, double freightCharges, DateTime shippedOn)
 {
     _orderId        = id;
     _purchasedOn    = orderDate;
     _status         = stat;
     _customerInfo   = cust;
     _packages       = packages;
     _requiredBefore = requiredDate;
     _freightCharges = freightCharges;
     _shippingCo     = shipCo;
     _shippedOn      = shippedOn;
 }