Esempio n. 1
0
        private DataTable createTable()
        {
            DataTable table = new DataTable();

            DataColumn dc = new DataColumn("imagePath", typeof(string));

            table.Columns.Add(dc);

            dc = new DataColumn("note", typeof(string));
            table.Columns.Add(dc);

            dc = new DataColumn("money", typeof(float));
            table.Columns.Add(dc);

            dc = new DataColumn("postname", typeof(string));
            table.Columns.Add(dc);

            DataTable uk_trans = new PosCalculate().getPostWays("UK");

            for (int i = 0; i < uk_trans.Rows.Count; i++)
            {
                DataRow dr = table.NewRow();

                dr["imagePath"] = "../../image/image/" + uk_trans.Rows[i]["image_path"];
                dr["money"]     = 2.0;
                dr["note"]      = uk_trans.Rows[i]["note"];
                dr["postname"]  = uk_trans.Rows[i]["post_way"];

                table.Rows.Add(dr);
            }

            return(table);
        }
Esempio n. 2
0
        /// <summary>
        /// 产生数据绑定表
        /// </summary>
        /// <returns></returns>
        private DataTable createTable()
        {
            DataTable table = new DataTable();

            DataColumn dc = new DataColumn("postway", typeof(string));

            table.Columns.Add(dc);

            dc = new DataColumn("image", typeof(string));
            table.Columns.Add(dc);

            dc = new DataColumn("money", typeof(string));
            table.Columns.Add(dc);

            dc = new DataColumn("note", typeof(string));
            table.Columns.Add(dc);

            //tb_postways 里面存放了 postname、note信息
            DataTable tb_postways = new PosCalculate().getPostWays("UK");

            for (int i = 0; i < tb_postways.Rows.Count; i++)
            {
                DataRow dr = table.NewRow();
                dr["image"]   = "../../image/image/" + tb_postways.Rows[i]["image_path"];
                dr["postway"] = tb_postways.Rows[i]["post_way"];
                dr["money"]   = "&pound;" + 100.0;
                dr["note"]    = tb_postways.Rows[i]["note"];

                table.Rows.Add(dr);
            }


            for (int i = 0; i < 2; i++)
            {
            }

            return(table);
        }
Esempio n. 3
0
        /// <summary>
        /// 通过快件的起始国家、终止国家、重量、长度、宽度、高度 来查找数据库得到 邮费 然后创建 table
        /// </summary>
        /// <param name="startcountry">起始国家</param>
        /// <param name="endcountry">终止国家</param>
        /// <param name="weight">重量</param>
        /// <param name="length">长度</param>
        /// <param name="width">宽度</param>
        /// <param name="height">高度</param>
        /// <returns>将所需要的数据存放在 DataTable中</returns>
        private DataTable createDataTable(string name, string destination, ArrayList goods)
        {
            //计算总共的包裹数
            int package_count = 0;

            for (int i = 0; i < goods.Count; i++)
            {
                PackageMeasure temp_package = (PackageMeasure)goods[i];
                package_count += temp_package.Count;
            }

            DataTable dt = new DataTable("postway");
            //为表添加列
            DataColumn dc = new DataColumn("id", typeof(int));

            dc.AutoIncrement = true;
            dt.Columns.Add(dc);

            dc = new DataColumn("postname", typeof(string));
            dt.Columns.Add(dc);

            dc = new DataColumn("imagePath", typeof(string));
            dt.Columns.Add(dc);

            dc = new DataColumn("note", typeof(string));
            dt.Columns.Add(dc);

            dc = new DataColumn("money", typeof(string));
            dt.Columns.Add(dc);


            //tb_postways 里面存放了 postname、note信息
            DataTable tb_postways = new PosCalculate().getPostWays(destination);

            foreach (DataRow tempdr in tb_postways.Rows)
            {
                float total = 0;

                if (package_count <= 1)
                {
                    DataRow dr       = dt.NewRow();
                    string  post_way = tempdr["post_way"].ToString();
                    dr["postname"]  = post_way;
                    dr["imagePath"] = "../../image/image/" + tempdr["image_path"].ToString();
                    dr["note"]      = tempdr["note"].ToString();

                    for (int i = 0; i < goods.Count; i++)
                    {
                        PackageMeasure good = (PackageMeasure)goods[i];

                        total += good.Count * new InterFaceQuote().getQuote(name, destination, good.Weight, good.Length, good.Width, good.Height, post_way);
                    }

                    total = (int)(total * 100) / 100.0f;

                    dr["money"] = "£" + total.ToString();
                    dt.Rows.Add(dr);
                }
                else if (package_count <= 3)
                {
                    DataRow dr       = dt.NewRow();
                    string  post_way = tempdr["post_way"].ToString();

                    if (!post_way.Contains("PF-IPE"))
                    {
                        dr["postname"]  = post_way;
                        dr["imagePath"] = "../../image/image/" + tempdr["image_path"].ToString();
                        dr["note"]      = tempdr["note"].ToString();

                        for (int i = 0; i < goods.Count; i++)
                        {
                            PackageMeasure good = (PackageMeasure)goods[i];

                            total += good.Count * new InterFaceQuote().getQuote(destination, destination, good.Weight, good.Length, good.Width, good.Height, post_way);
                        }

                        total = (int)(total * 100) / 100.0f;

                        total = (float)Math.Round(total, 2);

                        dr["money"] = total;
                        dt.Rows.Add(dr);
                    }
                }
                else
                {
                    DataRow dr       = dt.NewRow();
                    string  post_way = tempdr["post_way"].ToString();

                    if (!post_way.Contains("PF-IPE") && !post_way.Contains("PF-GPR"))
                    {
                        dr["postname"]  = post_way;
                        dr["imagePath"] = "../../image/image/" + tempdr["image_path"].ToString();
                        dr["note"]      = tempdr["note"].ToString();

                        for (int i = 0; i < goods.Count; i++)
                        {
                            PackageMeasure good = (PackageMeasure)goods[i];

                            total += good.Count * new InterFaceQuote().getQuote(name, destination, good.Weight, good.Length, good.Width, good.Height, post_way);
                        }

                        total = (int)(total * 100) / 100.0f;

                        dr["money"] = total;
                        dt.Rows.Add(dr);
                    }
                }
            }

            return(dt);
        }