Ejemplo n.º 1
0
 private void ManagerSubpulses_SystemDateChangedEvent(DateTime newDate)
 {
     HeaderText = TypeName + ": " + NetWeight.ToString() + " of " + MaxWeight.ToString() + " used, " + RemainingWeight.ToString() + " remaining";
     OnPropertyChanged(nameof(MaxWeight));
     OnPropertyChanged(nameof(NetWeight));
     OnPropertyChanged(nameof(RemainingWeight));
     //OnPropertyChanged(nameof(TypeStore));
 }
Ejemplo n.º 2
0
        public string Update()
        {
            NetWeight      = GrossWeight - (LessTear + LessSample + LessDamage);
            RatePerQuintal = RatePerMound * (decimal)2.6792;
            RatePerQuintal = Math.Round((decimal)RatePerQuintal, 2, MidpointRounding.AwayFromZero);
            Amount         = NetWeight * RatePerQuintal;
            if (Amount.HasValue)
            {
                Amount = Math.Round((decimal)Amount);
            }
            XDocument doc    = XDocument.Load(@"Transactions.xml");
            var       record = from r in doc.Descendants("Transaction")
                               where (int)r.Element("Serial") == Serial
                               select r;

            foreach (XElement r in record)
            {
                r.Element("Seller").Value          = Seller;
                r.Element("Bales").Value           = Bales.ToString();
                r.Element("Date").Value            = XmlConvert.ToString(Date, XmlDateTimeSerializationMode.RoundtripKind);
                r.Element("Station").Value         = Station;
                r.Element("Quality").Value         = Quality;
                r.Element("RatePerMound").Value    = RatePerMound.ToString();
                r.Element("Condition").Value       = Condition;
                r.Element("Broker").Value          = Broker;
                r.Element("BrokeragePaid").Value   = BrokeragePaid.ToString();
                r.Element("PaymentDate").Value     = PaymentDate.HasValue ? XmlConvert.ToString(PaymentDate.Value, XmlDateTimeSerializationMode.RoundtripKind) : "";
                r.Element("Buyer").Value           = Buyer;
                r.Element("PressSerialFrom").Value = PressSerialFrom;
                r.Element("PressSerialTo").Value   = PressSerialTo;
                r.Element("PressMark").Value       = PressMark;
                r.Element("PressDate").Value       = PressDate.HasValue ? XmlConvert.ToString(PressDate.Value, XmlDateTimeSerializationMode.RoundtripKind) : "";
                r.Element("GrossWeight").Value     = GrossWeight.ToString();
                r.Element("LessTear").Value        = LessTear.ToString();
                r.Element("LessSample").Value      = LessSample.ToString();
                r.Element("LessDamage").Value      = LessDamage.ToString();
                r.Element("DespatchDate").Value    = DespatchDate.HasValue ? XmlConvert.ToString(DespatchDate.Value, XmlDateTimeSerializationMode.RoundtripKind) : "";
                r.Element("NetWeight").Value       = NetWeight.ToString();
                r.Element("RatePerQuintal").Value  = RatePerQuintal.ToString();
                r.Element("Amount").Value          = Amount.ToString();
                r.Element("GRNo").Value            = GRNo;
                r.Element("LotNo").Value           = LotNo;
                r.Element("DueDate").Value         = DueDate.HasValue ? XmlConvert.ToString(DueDate.Value, XmlDateTimeSerializationMode.RoundtripKind) : "";
            }
            doc.Save(@"Transactions.xml");
            return("Record Updated Successfully");
        }
Ejemplo n.º 3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                if (svimaster.Connected == false)
                {
                    svimaster.UnitIdentifier    = 1;    // Not necessary since default slaveID = 1;
                    svimaster.Baudrate          = 9600; // Not necessary since default baudrate = 9600
                    svimaster.Parity            = System.IO.Ports.Parity.Even;
                    svimaster.StopBits          = System.IO.Ports.StopBits.One;
                    svimaster.ConnectionTimeout = 1000;
                    svimaster.Connect();
                    label1.BackColor = Color.YellowGreen;
                    label1.Text      = "Connect";
                }


                if (svimaster.Connected == true)
                {
                    int[] Weight;
                    float NetWeight;
                    Weight             = svimaster.ReadInputRegisters(25, 2);
                    NetWeight          = ModbusClient.ConvertRegistersToFloat(Weight);
                    textBoxWeight.Text = Convert.ToString(Convert.ToUInt64(NetWeight.ToString()) - Convert.ToUInt64(textBoxNumberOfPareSnag.Text));
                }
            }

            catch
            {
                svimaster.Disconnect();
                try
                {
                    svimaster.Connect();
                }
                catch
                {
                    textBoxWeight.Text = "99999999";
                }
            }
        }
Ejemplo n.º 4
0
        public void Initalise(CargoStorageDB storageDB, Guid storageTypeID)
        {
            _storageDB = storageDB;
            TypeID     = storageTypeID;

            CargoTypeSD cargoType = _dataStore.CargoTypes[TypeID];

            TypeName = cargoType.Name;
            foreach (var itemKVP in StorageSpaceProcessor.GetResourcesOfCargoType(storageDB, TypeID))
            {
                CargoItemVM cargoItem = new CargoItemVM(_gameVM, _storageDB, itemKVP.Key);
                TypeStore.Add(cargoItem);
            }
            if (_storageDB.StoredEntities.ContainsKey(TypeID))
            {
                InitEntities();
            }

            HeaderText = cargoType.Name + ": " + NetWeight.ToString() + " of " + MaxWeight.ToString() + " used, " + RemainingWeight.ToString() + " remaining";
            _storageDB.OwningEntity.Manager.ManagerSubpulses.SystemDateChangedEvent += ManagerSubpulses_SystemDateChangedEvent;
            _storageDB.MinsAndMatsByCargoType[TypeID].CollectionChanged             += _storageDB_CollectionChanged;
            _storageDB.StoredEntities.CollectionChanged += StoredEntities_CollectionChanged;
        }