Пример #1
0
        public void Create()
        {
            var actual = VesselStatus.Create("p", ".1", "-5", "-3", "-2.0");

            Assert.AreEqual(HInclinationStatus.P, actual.HStatus);
            Assert.AreEqual(0.1m, actual.HValue);
            Assert.AreEqual(-5m, actual.AftDraft);
            Assert.AreEqual(-3m, actual.ForeDraft);
            Assert.AreEqual(-2m, actual.VValue);
        }
Пример #2
0
        public void GetReceiptHeader(Receipt receipt, bool validate = true)
        {
            if (validate)
            {
                var error = new[]
                {
                    this.txtReceiptNo.Text.ValidateNotEmpty(lblReceiptNo.Text, true),
                    this.txtVesselName.Text.ValidateNotEmpty(lblVesselName.Text, true),
                    this.txtTime.Text.ValidateDate(Strings.LabelTime),
                    (!this.rdoLoad.Checked && !this.rdoDischarge.Checked) ? String.Format(Strings.MsgValidationErrorCannotBeEmpty, Strings.LabelReceiptFor) : null,
                    this.txtPortOfShipment.Text.ValidateNotEmpty(lblPortOfShipment.Text, true),
                    this.txtPortOfDestination.Text.ValidateNotEmpty(lblPortOfDestination.Text, true),
                    this.cmbKindOfGoods.SelectedNode == null?String.Format(Strings.MsgValidationErrorCannotBeEmpty, lblKindOfGoods.Text) : null,
                        !VesselStatus.Validate(this.HStatus, this.txtHInclination.Text, this.txtAftDraft.Text, this.txtForeDraft.Text, this.txtVInclination.Text) ? String.Format(Strings.MsgValidationErrorInvalidVesselStatus, lblVesselStatus.Text) : null
                }
                .Where(e => e != null)
                .Aggregate(new StringBuilder(), (sb, e) => sb.AppendLine(e)).ToString();

                if (error.Length > 0)
                {
                    throw new ValidationException(error);
                }
            }

            var r = new Receipt();

            r.No                = this.txtReceiptNo.Text.Trim();
            r.VesselName        = this.txtVesselName.Text.Trim();
            r.Time              = this.txtTime.Text.Trim().TryToNullableDateTime();
            r.ReceiptFor        = this.rdoLoad.Checked ? "Load" : (this.rdoDischarge.Checked ? "Discharge" : String.Empty);
            r.PortOfShipment    = this.txtPortOfShipment.Text.Trim();
            r.PortOfDestination = this.txtPortOfDestination.Text.Trim();
            r.KindOfGoods       = this.cmbKindOfGoods.SelectedNode == null ? null : (KindOfGoods)this.cmbKindOfGoods.SelectedNode.Tag;
            try { r.VesselStatus = VesselStatus.Create(this.HStatus, this.txtHInclination.Text, this.txtAftDraft.Text, this.txtForeDraft.Text, this.txtVInclination.Text); } catch { }
            r.TotalOfVolumeOfPipes = this.TotalOfVolumeOfPipes;

            receipt.No                   = r.No;
            receipt.VesselName           = r.VesselName;
            receipt.Time                 = r.Time;
            receipt.ReceiptFor           = r.ReceiptFor;
            receipt.PortOfShipment       = r.PortOfShipment;
            receipt.PortOfDestination    = r.PortOfDestination;
            receipt.KindOfGoods          = r.KindOfGoods;
            receipt.VesselStatus         = r.VesselStatus;
            receipt.TotalOfVolumeOfPipes = r.TotalOfVolumeOfPipes;
        }