Ejemplo n.º 1
0
        public async Task<AddSubReportStatus> AddSubReportAsync(int reportId, SubReport subReport)
        {
            var report = await FindByIdAsync(reportId);
            if (report == null)
                return AddSubReportStatus.InvalidReportId;

            if (report.SubReports.Any(x => x.ForwardId == subReport.ForwardId))
                return AddSubReportStatus.DuplicatedForwardIdFound;

            if (subReport.LoadingTonnage < 1 || subReport.UnloadedTonnage < 1 ||
                subReport.UnloadedTonnage > subReport.LoadingTonnage)
                return AddSubReportStatus.InvalidTonnage;

            var path = await _pathService.FindByIdAsync(subReport.Path.Id);
            if (path?.ActiveState == false)
                return AddSubReportStatus.NotFoundActivePath;

            var driver = await _driverService.FindByIdAsync(subReport.Driver.Id);
            if (driver?.ActiveState == false)
                return AddSubReportStatus.NotFoundActiveDriver;

            var freight = await _freightService.FindByIdeAsync(subReport.Freight.Id);
            if (freight?.ActiveState == false)
                return AddSubReportStatus.NotFoundActiveFreight;

            subReport.Report = report;
            report.SubReports.Add(subReport);
            return AddSubReportStatus.Success;
        }
Ejemplo n.º 2
0
        private SubReport checkInputes()
        {
            errorProvider1.Clear();
            const string strError = "بدرستی تکمیل نشده است";
            if (_result.Path == null)
            {
                errorProvider1.SetError(pathCombo, strError);
                return null;
            }
            if (_result.Driver == null)
            {
                errorProvider1.SetError(driverCombo, strError);
                return null;
            }
            if (_result.Freight == null)
            {
                errorProvider1.SetError(freightCombo, strError);
                return null;
            }
            if (loadingTonnageNum.Value < 1)
            {
                errorProvider1.SetError(loadingTonnageNum, strError);
                return null;
            }
            if (unloadingTonnageNum.Value < 1)
            {
                errorProvider1.SetError(unloadingTonnageNum, strError);
                return null;
            }
            if (unloadingTonnageNum.Value > loadingTonnageNum.Value)
            {
                errorProvider1.SetError(unloadingTonnageNum, strError);
                return null;
            }

            int fId;
            if (!int.TryParse(forwardIdBox.Text, out fId))
            {
                errorProvider1.SetError(forwardIdBox, strError);
                return null;
            }

            var sr = new SubReport
            {
                Freight = _result.Freight,
                Path = _result.Path,
                Driver = _result.Driver,
                Report = _result.Report,
                DateTime = datePickerBox.Date,
                ForwardId = fId,
                LoadingTonnage = (int) loadingTonnageNum.Value,
                UnloadedTonnage = (int) unloadingTonnageNum.Value,
                Rent = rentNum.Value,
                TaxAndInsurmentMoney = taxNum.Value
            };
            var res = sr.CostPrice;
            costPriceLabel.Text = res.ToString("C0");
            costPriceWordLabel.Text = res.NumberToText(Language.Persian);
            return sr;
        }
Ejemplo n.º 3
0
        protected override DataGridViewRow FillRow(SubReport entity, DataGridViewRow rowToAdd)
        {
            rowToAdd.Height = 45;
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = entity.Path.SourceCity});
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = entity.Path.DestinationCity});
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = $"{entity.Driver.Name} {entity.Driver.Family}"});
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = entity.Driver.Plaque});
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = entity.ForwardId});
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = entity.Freight.Name});
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = entity.DateTime.ToPersianDateString()});
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = entity.LoadingTonnage});
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = entity.UnloadedTonnage});
            rowToAdd.Cells.Add(new DataGridViewButtonCell() {Value = (entity.Rent).ToString("##,###") });

            return rowToAdd;
        }
Ejemplo n.º 4
0
 public void DeleteSubReportAsync(SubReport subReport)
     => _subReports.Remove(subReport);