Exemple #1
0
 public static int InsertData(ProductSize po)
 {
     if (po != null)
     {
         return(DataSource.ORMHelper.InsertModel <ProductSize>(po));
     }
     return(0);
 }
Exemple #2
0
        public static List <ProductSize> GetSizeById(List <int> id)
        {
            List <ProductSize> pslist = new List <ProductSize>();

            for (int i = 0; i < id.Count; i++)
            {
                ProductSize ps = GetSizeById(id[i]);
                if (ps != null)
                {
                    pslist.Add(ps);
                }
            }
            return(pslist);
        }
Exemple #3
0
        public static ProductSize GetSizeById(int id)
        {
            ProductSize ps = null;

            for (int i = 0; i < AllSize.Count; i++)
            {
                if (AllSize[i].Id == id)
                {
                    ps = AllSize[i];
                    break;
                }
            }
            return(ps);
        }
Exemple #4
0
        public static List <ProductSize> GetSizeKaidu(int kaidu)
        {
            List <ProductSize> pslist = new List <ProductSize>();

            for (int i = 0; i < AllSize.Count; i++)
            {
                if (AllSize[i].Kaidu == kaidu)
                {
                    ProductSize ps = (ProductSize)AllSize[i].MemberwiseClone();
                    pslist.Add(ps);
                }
            }
            if (pslist.Count > 0)
            {
                return(pslist);
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
        public Rectange(int id)
        {
            ProductSize ps = ProductSize.GetSizeById(id);
            int         l, h;

            l = ps.StandLength;
            h = ps.StandHeight;
            if (l > h)
            {
                Length = l;
                Width  = h;
            }
            else
            {
                Length = h;
                Width  = l;
            }
            Id    = id;
            Name  = ps.NickName;
            Kaidu = ps.Kaidu;
        }
Exemple #6
0
        public static List <ProductSize> GetSizeListByProductId(int ProductId)
        {
            List <ProductSize> Result = new List <ProductSize>();
            DataTable          dt     = DataSource.ORMHelper.GetDataTable <R_ProductSize>("ProductId='" + ProductId.ToString() + "'");
            List <int>         SizeId = new List <int>();

            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int id = int.Parse(dt.Rows[i][1].ToString());
                    SizeId.Add(id);
                }
                string where = Common.IntListToSql(SizeId);
                if (where.Length > 4)
                {
                    where = "Id " + where;
                    List <Model.ProductSize> ps = ProductSize.GetDataList("Id " + Common.IntListToSql(SizeId));
                    return(ps);
                }
            }
            return(null);
        }
Exemple #7
0
 public static int Update(ProductSize ps)
 {
     return(DataSource.ORMHelper.UpdateModelById <ProductSize>(ps));
 }
Exemple #8
0
        public static ProductSize GetLHSize(int L, int H)
        {
            int l, h;

            if (L < H)
            {
                l = H;
                h = L;
            }
            else
            {
                l = L;
                h = H;
            }
            List <ProductSize> pslist = new List <ProductSize>();

            foreach (ProductSize ps in AllSize)
            {
                if (ps.StandHeight == l && ps.StandLength == h)
                {
                    return(ps);
                }
                if (ps.StandHeight == h && ps.StandLength == l)
                {
                    return(ps);
                }
            }
            foreach (ProductSize ps in AllSize)
            {
                if ((ps.MaxHeight >= h && ps.MaxLength >= l) && (ps.MinHeight <= h && ps.MinLength <= l))
                {
                    pslist.Add(ps);
                }
                if ((ps.MaxHeight >= l && ps.MaxLength >= h) && (ps.MinHeight <= l && ps.MinLength <= h))
                {
                    pslist.Add(ps);
                }
            }

            if (pslist.Count > 0)
            {
                decimal     s1, s2;
                decimal     r      = 0;
                ProductSize result = null;
                foreach (ProductSize ps in pslist)
                {
                    s1 = l * h;
                    s2 = ps.StandHeight * ps.StandLength;
                    decimal r1 = s1 / s2;
                    if (r1 > r)
                    {
                        result = ps;
                        r      = r1;
                    }
                }
                return(result);
            }
            else
            {
                return(null);
            }
        }