Ejemplo n.º 1
0
 protected override DataStatus OnDeleteAfter(DataSource ds)
 {
     try
     {
         foreach (FreightMapping map in FreightMapping.GetAllByTemplate(ds, Id))
         {
             if (map.Delete(ds) != DataStatus.Success)
             {
                 ds.Rollback();
                 return(DataStatus.Rollback);
             }
         }
     }
     catch (Exception) { ds.Rollback();  return(DataStatus.Rollback); }
     ds.Commit();
     return(DataStatus.Success);
 }
Ejemplo n.º 2
0
 public IList <FreightMapping> GetMapping(DataSource ds)
 {
     return(FreightMapping.GetAllByTemplate(ds, Id));
 }
Ejemplo n.º 3
0
        public static Money GetFreight(DataSource ds, long id, int provice, int city, int county, Money Total, int Count, int Volume, int Weight)
        {
            FreightTemplate tmp = GetById(ds, id);

            if (tmp != null)
            {
                if (tmp.Number <= 0)
                {
                    tmp.Number = 1;
                }
                FreightMapping map = FreightMapping.GetMapping(ds, tmp.Id, provice, city);
                if (map != null)
                {
                    if (map.Number <= 0)
                    {
                        map.Number = 1;
                    }
                    if (tmp.Type == ValuationType.ThePrece)
                    {
                        if (Count > map.Number && map.StepNumber > 0 && map.StepMoney > 0)
                        {
                            if ((Count - map.Number) % map.StepNumber == 0)
                            {
                                return((Count - map.Number) / map.StepNumber * map.StepMoney + map.Money);
                            }
                            else
                            {
                                return((((Count - map.Number) / map.StepNumber) + 1) * map.StepMoney + map.Money);
                            }
                        }
                        else
                        {
                            return(map.Money);
                        }
                    }
                    else if (tmp.Type == ValuationType.Volume)
                    {
                        int FVolumn = Count * Volume;
                        if (FVolumn > map.Number && map.StepNumber > 0 && map.StepMoney > 0)
                        {
                            if ((FVolumn - map.Number) % map.StepNumber == 0)
                            {
                                return((FVolumn - map.Number) / map.StepNumber * map.StepMoney + map.Money);
                            }
                            else
                            {
                                return((((FVolumn - map.Number) / map.StepNumber) + 1) * map.StepMoney + map.Money);
                            }
                        }
                        else
                        {
                            return(map.Money);
                        }
                    }
                    else if (tmp.Type == ValuationType.Weight)
                    {
                        int FVolumn = Count * Weight;
                        if (FVolumn > map.Number && map.StepNumber > 0 && map.StepMoney > 0)
                        {
                            if ((FVolumn - map.Number) % map.StepNumber == 0)
                            {
                                return((FVolumn - map.Number) / map.StepNumber * map.StepMoney + map.Money);
                            }
                            else
                            {
                                return((((FVolumn - map.Number) / map.StepNumber) + 1) * map.StepMoney + map.Money);
                            }
                        }
                        else
                        {
                            return(map.Money);
                        }
                    }
                }
                else
                {
                    if (tmp.Type == ValuationType.ThePrece)
                    {
                        if (Count > tmp.Number && tmp.StepNumber > 0 && map.StepMoney > 0)
                        {
                            if ((Count - tmp.Number) % tmp.StepNumber == 0)
                            {
                                return((Count - tmp.Number) / tmp.StepNumber * tmp.StepMoney + tmp.Money);
                            }
                            else
                            {
                                return((((Count - tmp.Number) / tmp.StepNumber) + 1) * tmp.StepMoney + tmp.Money);
                            }
                        }
                        else
                        {
                            return(tmp.Money);
                        }
                    }
                    else if (tmp.Type == ValuationType.Volume)
                    {
                        int FVolumn = Count * Volume;
                        if (FVolumn > tmp.Number && tmp.StepNumber > 0 && map.StepMoney > 0)
                        {
                            if ((FVolumn - tmp.Number) % tmp.StepNumber == 0)
                            {
                                return((FVolumn - tmp.Number) / tmp.StepNumber * tmp.StepMoney + tmp.Money);
                            }
                            else
                            {
                                return((((FVolumn - tmp.Number) / tmp.StepNumber) + 1) * tmp.StepMoney + tmp.Money);
                            }
                        }
                        else
                        {
                            return(tmp.Money);
                        }
                    }
                    else if (tmp.Type == ValuationType.Weight)
                    {
                        int FVolumn = Count * Weight;
                        if (FVolumn > tmp.Number && tmp.StepNumber > 0 && map.StepMoney > 0)
                        {
                            if ((FVolumn - tmp.Number) % tmp.StepNumber == 0)
                            {
                                return((FVolumn - tmp.Number) / tmp.StepNumber * tmp.StepMoney + tmp.Money);
                            }
                            else
                            {
                                return((((FVolumn - tmp.Number) / tmp.StepNumber) + 1) * tmp.StepMoney + tmp.Money);
                            }
                        }
                        else
                        {
                            return(tmp.Money);
                        }
                    }
                }
            }
            return(0);
        }