c#排列组合新手跪求指教!!!!!!

默萧笙故 2016-04-23 08:58:02
小生正在做一个运费功能,其中运费有一个计算运费的的功能描述大概是这样的:有西装、上衣、裤子、马甲、衬衫发往不同的国家,其中每样的运费都是不一样的。现在的关键就是如何确定发送的是那几样商品及组合方式,确定价格
 if (dr.Rows.Count == 3)
{
textOrderDetails.Text = dr.Rows[0]["OrderNo"].ToString() + "," + "\r\n" + dr.Rows[1]["OrderNo"].ToString() + "," + "\r\n" + dr.Rows[2]["OrderNo"].ToString();

string Country = dr.Rows[0]["Country"].ToString();
string ProductName1 = dr.Rows[0]["ProductName"].ToString();
string ProductName2 = dr.Rows[1]["ProductName"].ToString();
string ProductName3 = dr.Rows[2]["ProductName"].ToString();
double OrderStatus1 = double.Parse(dr.Rows[0]["OrderStatus"].ToString());
double OrderStatus2 = double.Parse(dr.Rows[1]["OrderStatus"].ToString());
double OrderStatus3 = double.Parse(dr.Rows[2]["OrderStatus"].ToString());
double amount1 = double.Parse(dr.Rows[0]["Amount"].ToString());
double amount2 = double.Parse(dr.Rows[1]["Amount"].ToString());
double amount3 = double.Parse(dr.Rows[2]["Amount"].ToString());

string[] str = new string[] { "Suits", "Coats", "Pants", "Vests", "Shirts" };
List<string> list = Route(str.Length, ref str);

if (OrderStatus1 >= 30 && OrderStatus2 >= 30 & OrderStatus3 >= 30)
{

//发送类型
#region
int Result;

//全部
#region
//全部西装
#region
if (ProductName1 == "Suits" && ProductName2 == "Suits" && ProductName3 == "Suits")
{
Result = 1;
if (this.cmbChannel.Text.Equals(DHL) && Result == 1 && (Country == "United States" || Country == "Canada" || Country == "Mexico"))
{
Freight = 30 * 3;
}

else if (this.cmbChannel.Text.Equals(DHL) && Result == 1 && (Country == "Australia" || Country == "New Zealand"))
{
Freight = 35 * 3;
}
else if (this.cmbChannel.Text.Equals(DHL) && Result == 1 && (Country == "France" || Country == "Belgium" || Country == "Luxembourg" || Country == "Ireland" || Country == "Portugal" || Country == "Sweden" || Country == "Italy" || Country == "Spain" || Country == "Switzerland" || Country == "Denmark" || Country == "Finland" || Country == "Austria" || Country == "Norway" || Country == "Iceland" || Country == "The Netherlands" || Country == "United Kingdom" || Country == "Germany" || Country == "Greece"))
{
Freight = 40 * 3;
}
else if (this.cmbChannel.Text.Equals(DHL) && Result == 1 && (Country == "Dominica" || Country == "Argentina" || Country == "Brazil" || Country == "Chile" || Country == "Colombia" || Country == "Costa Rica" || Country == "Monaco" || Country == "Peru" || Country == "Trinidad and Tobago" || Country == "Uruguay" || Country == "Venezuela" || Country == "Bangladesh" || Country == "Israe" || Country == "Kuwait" || Country == "Saudi Arabia" || Country == "the United Arab Emirates" || Country == "Qatar" || Country == "Iran" || Country == "Lebanon" || Country == "Jordan" || Country == "Oman" || Country == "Syria" || Country == "Yemen" || Country == "Bahrain" || Country == "Egypt" || Country == "South Africa" || Country == "Bulgaria" || Country == "Estonia" || Country == "Latvia" || Country == "Lithuania" || Country == "Slovenia" || Country == "Cyprus" || Country == "Hungary" || Country == "the Czech Republic" || Country == "Slovakia" || Country == "Poland" || Country == "Ukraine" || Country == "Brazil" || Country == "Belarus" || Country == "Côte d'Ivoire" || Country == "Angola" || Country == "Brazil" || Country == "Burkina Faso" || Country == "Angola" || Country == "the Democratic Republic of the Congo" || Country == "Cote d'Ivoire (Ivory Coast)" || Country == "Burkina Faso" || Country == "Central African Republic" || Country == "Guinea" || Country == "Liberia" || Country == "Mali" || Country == "Niger" || Country == "Sierra Leone" || Country == "Nigeria" || Country == "Albania" || Country == "Armenia" || Country == "Azerbaijan" || Country == "Belarus" || Country == "Bosnia and Herzegovina" || Country == "he Falkland Islands" || Country == "Georgia" || Country == "Kazakhstan" || Country == "Kosovo" || Country == "Kyrgyzstan " || Country == "Macedonia" || Country == "Moldova" || Country == "Montenegro" || Country == "Serbia" || Country == "Tajikistan" || Country == "Ukraine" || Country == "Germany" || Country == "Uzbekistan" || Country == "Libya" || Country == "Palestine" || Country == "Ethiopia" || Country == "Kenya" || Country == "Uganda" || Country == "India" || Country == "Algeria" || Country == "Benin" || Country == "Botswana" || Country == "Romania" || Country == "Burundi" || Country == "Cameroon" || Country == "Cape Verde" || Country == "Chad" || Country == "Comoros" || Country == "Republic of Congo" || Country == "Djibouti" || Country == "Equatorial Guinea" || Country == "Gabon" || Country == "Gambia" || Country == "Ghana" || Country == "Lesotho to Madagascar" || Country == "Malawi" || Country == "Mauritania" || Country == "Mauritius" || Country == "Mayotte" || Country == "Morocco" || Country == "Mozambique" || Country == "Namibia" || Country == "Reunion" || Country == "Rwanda" || Country == "Senegal" || Country == "Seychelles" || Country == "Somalia" || Country == "Somaliland" || Country == "Swaziland" || Country == "Tanzania" || Country == "Tunisia" || Country == "Zambia" || Country == "Zimbabwe" || Country == "Guinea-Bissau" || Country == "Antigua and Barbuda" || Country == "Aruba" || Country == "Bahamas" || Country == "Barbados" || Country == "Belize" || Country == "Bermuda" || Country == "Bolivia" || Country == "Cayman Islands" || Country == "Colombia" || Country == "Ecuador" || Country == "El Salvador" || Country == "French Guiana" || Country == "Grenada" || Country == "Guadeloupe" || Country == "Guatemala" || Country == "Guyana" || Country == "Haiti" || Country == "Martinique Virginia" || Country == "Mongolia" || Country == "Montserrat" || Country == "Nevis" || Country == "Nicaragua" || Country == "Turkey" || Country == "Puerto Rico" || Country == "Sri Lanka" || Country == "Maldives" || Country == "non Faroe Islands" || Country == "Greenland" || Country == "Belarus" || Country == "Croatia"))
{
Freight = 55 * 3;
}

//else if (this.cmbChannel.Text.Equals(KANGLI) && Result == 1 && (Country == "France" || Country == "Belgium" || Country == "Luxembourg" || Country == "Ireland" || Country == "Portugal" || Country == "Sweden" || Country == "Italy" || Country == "Spain" || Country == "Switzerland" || Country == "Denmark" || Country == "Finland" || Country == "Austria" || Country == "Norway" || Country == "Iceland" || Country == "The Netherlands" || Country == "United Kingdom" || Country == "Germany" || Country == "Greece"))
//{
// Freight = 35 * 3;
//}
}
#endregion
...全文
142 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
oliviaxv 2016-04-24
  • 打赏
  • 举报
回复
写思路,不要写代码,你的思路和实现过程拿上来分析下,基本就找到问题所在了
tanta 2016-04-24
  • 打赏
  • 举报
回复
这个跟你的策略有关系吧?可以选全部运费之和,可以按最高运费计算,可以按重量计算,还可以用别的,不知道你怎么算?
为轮子而生 2016-04-23
  • 打赏
  • 举报
回复
究竟是哪里不明白呢? 你这段代码贴上来跟没贴上来没什么不同,完全搞不明白各个部分都是做什么用的。 你所谓的“如何确定发送的是...” 在哪里发送?连个参数都没有,就搞了一大堆Row、Name、Text,考研回帖人的猜测能力吗?

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧