public void CreateChargeStandard(ChargeStandard cs)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@carrier_id", cs.CarrierId),
         SqlUtilities.GenerateInputIntParameter("@carrier_area_id", cs.CarrierAreaId),
         SqlUtilities.GenerateInputNVarcharParameter("@encode", 50, cs.Encode),
         SqlUtilities.GenerateInputParameter("@goods_type", SqlDbType.TinyInt, cs.GoodsType),
         SqlUtilities.GenerateInputParameter("@start_weight", SqlDbType.Decimal, cs.StartWeight),
         SqlUtilities.GenerateInputParameter("@end_weight", SqlDbType.Decimal, cs.EndWeight),
         SqlUtilities.GenerateInputParameter("@base_weight", SqlDbType.Decimal, cs.BaseWeight),
         SqlUtilities.GenerateInputParameter("@increase_weight", SqlDbType.Decimal, cs.IncreaseWeight),
         SqlUtilities.GenerateInputParameter("@normal_base_price", SqlDbType.Decimal, cs.NormalBasePrice),
         SqlUtilities.GenerateInputParameter("@normal_continue_price", SqlDbType.Decimal, cs.NormalContinuePrice),
         SqlUtilities.GenerateInputParameter("@normal_kg_price", SqlDbType.Decimal, cs.NormalKgPrice),
         SqlUtilities.GenerateInputParameter("@normal_disposal_cost", SqlDbType.Decimal, cs.NormalDisposalCost),
         SqlUtilities.GenerateInputParameter("@normal_register_cost", SqlDbType.Decimal, cs.NormalRegisterCost),
         SqlUtilities.GenerateInputParameter("@client_base_price", SqlDbType.Decimal, cs.ClientBasePrice),
         SqlUtilities.GenerateInputParameter("@client_continue_price", SqlDbType.Decimal, cs.ClientContinuePrice),
         SqlUtilities.GenerateInputParameter("@client_kg_price", SqlDbType.Decimal, cs.ClientKgPrice),
         SqlUtilities.GenerateInputParameter("@client_disposal_cost", SqlDbType.Decimal, cs.ClientDisposalCost),
         SqlUtilities.GenerateInputParameter("@client_register_cost", SqlDbType.Decimal, cs.ClientRegisterCost),
         SqlUtilities.GenerateInputParameter("@self_base_price", SqlDbType.Decimal, cs.SelfBasePrice),
         SqlUtilities.GenerateInputParameter("@self_continue_price", SqlDbType.Decimal, cs.SelfContinuePrice),
         SqlUtilities.GenerateInputParameter("@self_kg_price", SqlDbType.Decimal, cs.SelfKgPrice),
         SqlUtilities.GenerateInputParameter("@self_disposal_cost", SqlDbType.Decimal, cs.SelfDisposalCost),
         SqlUtilities.GenerateInputParameter("@self_register_cost", SqlDbType.Decimal, cs.SelfRegisterCost),
         SqlUtilities.GenerateInputParameter("@preferential_gram", SqlDbType.Decimal, cs.PreferentialGram)
     };
     string sql = "INSERT INTO charge_standards(carrier_id, carrier_area_id, encode, goods_type, start_weight, end_weight, base_weight, increase_weight, normal_base_price, normal_continue_price, normal_kg_price, normal_disposal_cost, normal_register_cost, client_base_price, client_continue_price, client_kg_price, client_disposal_cost, client_register_cost, self_base_price, self_continue_price, self_kg_price, self_disposal_cost, self_register_cost, preferential_gram) VALUES (@carrier_id, @carrier_area_id, @encode, @goods_type, @start_weight, @end_weight,     @base_weight, @increase_weight, @normal_base_price, @normal_continue_price, @normal_kg_price, @normal_disposal_cost, @normal_register_cost,          @client_base_price, @client_continue_price, @client_kg_price, @client_disposal_cost, @client_register_cost, @self_base_price, @self_continue_price, @self_kg_price, @self_disposal_cost, @self_register_cost, @preferential_gram)";
     SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
 }
 protected void btnCreate_Click(object sender, EventArgs e)
 {
     ChargeStandard cs = new ChargeStandard();
     cs.CarrierAreaId = ca.Id;
     cs.CarrierId = carrier.Id;
     cs.Encode = ChargeStandardOperation.GetNextEncode(ca.Id);
     cs.GoodsType = byte.Parse(ddlGoodsType.SelectedItem.Value);
     try
     {
         cs.StartWeight = decimal.Parse(txtStartWeight.Text);
         cs.EndWeight = decimal.Parse(txtEndWeight.Text);
         cs.BaseWeight = decimal.Parse(txtBaseWeight.Text);
         cs.IncreaseWeight = decimal.Parse(txtIncreaseWeight.Text);
         cs.NormalBasePrice = decimal.Parse(txtNormalBasePrice.Text);
         cs.NormalContinuePrice = decimal.Parse(txtNormalContinuePrice.Text);
         cs.NormalDisposalCost = decimal.Parse(txtNormalDisposalCost.Text);
         cs.NormalKgPrice = decimal.Parse(txtNormalKgPrice.Text);
         cs.NormalRegisterCost = decimal.Parse(txtNormalRegisterCost.Text);
         cs.ClientBasePrice = decimal.Parse(txtClientBasePrice.Text);
         cs.ClientContinuePrice = decimal.Parse(txtClientContinuePrice.Text);
         cs.ClientDisposalCost = decimal.Parse(txtClientDisposalCost.Text);
         cs.ClientKgPrice = decimal.Parse(txtClientKgPrice.Text);
         cs.ClientRegisterCost = decimal.Parse(txtClientRegisterCost.Text);
         cs.SelfBasePrice = decimal.Parse(txtSelfBasePrice.Text);
         cs.SelfContinuePrice = decimal.Parse(txtSelfContinuePrice.Text);
         cs.SelfDisposalCost = decimal.Parse(txtSelfDisposalCost.Text);
         cs.SelfKgPrice = decimal.Parse(txtSelfKgPrice.Text);
         cs.SelfRegisterCost = decimal.Parse(txtSelfRegisterCost.Text);
         cs.PreferentialGram = decimal.Parse(txtPreferentialGram.Text);
     }
     catch (Exception ex)
     {
         Response.Write("<script language='javascript' type='text/javascript'>alert('重量、价格、费用和让利克数都只能为数字!');</script>");
         return;
     }
     if ((cs.NormalBasePrice > 0 || cs.NormalContinuePrice > 0) && cs.NormalKgPrice > 0)
     {
         Response.Write("<script language='javascript' type='text/javascript'>alert('同一重量范围内只能按首、续重价 或 每KG价其中一种方式计算!');</script>");
         return;
     }
     if ((cs.ClientBasePrice > 0 || cs.ClientContinuePrice > 0) && cs.ClientKgPrice > 0)
     {
         Response.Write("<script language='javascript' type='text/javascript'>alert('同一重量范围内只能按首、续重价 或 每KG价其中一种方式计算!');</script>");
         return;
     }
     if ((cs.SelfBasePrice > 0 || cs.SelfContinuePrice > 0) && cs.SelfKgPrice > 0)
     {
         Response.Write("<script language='javascript' type='text/javascript'>alert('同一重量范围内只能按首、续重价 或 每KG价其中一种方式计算!');</script>");
         return;
     }
     ChargeStandardOperation.CreateChargeStandard(cs);
     lblMsg.Text = "添加成功!";
     RpChargeStandardDataBind();
 }
 public static void UpdateChargeStandard(ChargeStandard cs)
 {
     dal.UpdateChargeStandard(cs);
 }
 public static void CreateChargeStandard(ChargeStandard cs)
 {
     dal.CreateChargeStandard(cs);
 }
 public List<ChargeStandard> GetChargeStandardByCarrierAreaId(int carrierAreaId)
 {
     List<ChargeStandard> result = new List<ChargeStandard>();
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@carrier_area_id", carrierAreaId)
     };
     string sql = "SELECT carrier_id, carrier_area_id, encode, goods_type, start_weight, end_weight, base_weight, increase_weight, normal_base_price, normal_continue_price, normal_kg_price, normal_disposal_cost, normal_register_cost, client_base_price, client_continue_price, client_kg_price, client_disposal_cost, client_register_cost, self_base_price, self_continue_price, self_kg_price, self_disposal_cost, self_register_cost, id, preferential_gram FROM charge_standards WHERE carrier_area_id = @carrier_area_id";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             ChargeStandard cs = new ChargeStandard();
             cs.CarrierId = dr.GetInt32(0);
             cs.CarrierAreaId = dr.GetInt32(1);
             cs.Encode = dr.GetString(2);
             cs.GoodsType = dr.GetByte(3);
             cs.StartWeight = dr.GetDecimal(4);
             cs.EndWeight = dr.GetDecimal(5);
             cs.BaseWeight = dr.GetDecimal(6);
             cs.IncreaseWeight = dr.GetDecimal(7);
             cs.NormalBasePrice = dr.GetDecimal(8);
             cs.NormalContinuePrice = dr.GetDecimal(9);
             cs.NormalKgPrice = dr.GetDecimal(10);
             cs.NormalDisposalCost = dr.GetDecimal(11);
             cs.NormalRegisterCost = dr.GetDecimal(12);
             cs.ClientBasePrice = dr.GetDecimal(13);
             cs.ClientContinuePrice = dr.GetDecimal(14);
             cs.ClientKgPrice = dr.GetDecimal(15);
             cs.ClientDisposalCost = dr.GetDecimal(16);
             cs.ClientRegisterCost = dr.GetDecimal(17);
             cs.SelfBasePrice = dr.GetDecimal(18);
             cs.SelfContinuePrice = dr.GetDecimal(19);
             cs.SelfKgPrice = dr.GetDecimal(20);
             cs.SelfDisposalCost = dr.GetDecimal(21);
             cs.SelfRegisterCost = dr.GetDecimal(22);
             cs.Id = dr.GetInt32(23);
             cs.PreferentialGram = dr.GetDecimal(24);
             result.Add(cs);
         }
     }
     return result;
 }
 public void UpdateChargeStandard(ChargeStandard cs)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", cs.Id),
         SqlUtilities.GenerateInputParameter("@goods_type", SqlDbType.TinyInt, cs.GoodsType),
         SqlUtilities.GenerateInputParameter("@start_weight", SqlDbType.Decimal, cs.StartWeight),
         SqlUtilities.GenerateInputParameter("@end_weight", SqlDbType.Decimal, cs.EndWeight),
         SqlUtilities.GenerateInputParameter("@base_weight", SqlDbType.Decimal, cs.BaseWeight),
         SqlUtilities.GenerateInputParameter("@increase_weight", SqlDbType.Decimal, cs.IncreaseWeight),
         SqlUtilities.GenerateInputParameter("@normal_base_price", SqlDbType.Decimal, cs.NormalBasePrice),
         SqlUtilities.GenerateInputParameter("@normal_continue_price", SqlDbType.Decimal, cs.NormalContinuePrice),
         SqlUtilities.GenerateInputParameter("@normal_kg_price", SqlDbType.Decimal, cs.NormalKgPrice),
         SqlUtilities.GenerateInputParameter("@normal_disposal_cost", SqlDbType.Decimal, cs.NormalDisposalCost),
         SqlUtilities.GenerateInputParameter("@normal_register_cost", SqlDbType.Decimal, cs.NormalRegisterCost),
         SqlUtilities.GenerateInputParameter("@client_base_price", SqlDbType.Decimal, cs.ClientBasePrice),
         SqlUtilities.GenerateInputParameter("@client_continue_price", SqlDbType.Decimal, cs.ClientContinuePrice),
         SqlUtilities.GenerateInputParameter("@client_kg_price", SqlDbType.Decimal, cs.ClientKgPrice),
         SqlUtilities.GenerateInputParameter("@client_disposal_cost", SqlDbType.Decimal, cs.ClientDisposalCost),
         SqlUtilities.GenerateInputParameter("@client_register_cost", SqlDbType.Decimal, cs.ClientRegisterCost),
         SqlUtilities.GenerateInputParameter("@self_base_price", SqlDbType.Decimal, cs.SelfBasePrice),
         SqlUtilities.GenerateInputParameter("@self_continue_price", SqlDbType.Decimal, cs.SelfContinuePrice),
         SqlUtilities.GenerateInputParameter("@self_kg_price", SqlDbType.Decimal, cs.SelfKgPrice),
         SqlUtilities.GenerateInputParameter("@self_disposal_cost", SqlDbType.Decimal, cs.SelfDisposalCost),
         SqlUtilities.GenerateInputParameter("@self_register_cost", SqlDbType.Decimal, cs.SelfRegisterCost),
         SqlUtilities.GenerateInputParameter("@preferential_gram", SqlDbType.Decimal, cs.PreferentialGram)
     };
     string sql = "UPDATE charge_standards SET goods_type = @goods_type, start_weight = @start_weight, end_weight = @end_weight, base_weight = @base_weight, increase_weight = @increase_weight, normal_base_price = @normal_base_price, normal_continue_price = @normal_continue_price, normal_kg_price = @normal_kg_price, normal_disposal_cost = @normal_disposal_cost, normal_register_cost = @normal_register_cost, client_base_price =     @client_base_price, client_continue_price = @client_continue_price, client_kg_price = @client_kg_price, client_disposal_cost =                       @client_disposal_cost, client_register_cost = @client_register_cost, self_base_price = @self_base_price, self_continue_price =                       @self_continue_price, self_kg_price = @self_kg_price, self_disposal_cost = @self_disposal_cost, self_register_cost = @self_register_cost, preferential_gram = @preferential_gram WHERE id = @id";
     SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
 }