示例#1
0
 protected void btnCreate_Click(object sender, EventArgs e)
 {
     ShippingModeInfo target = new ShippingModeInfo();
     target.Name = Globals.HtmlEncode(txtModeName.Text.Trim());
     target.Description = fck.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
     if (shippingTemplatesDropDownList.SelectedValue.HasValue)
     {
         target.TemplateId = shippingTemplatesDropDownList.SelectedValue.Value;
     }
     else
     {
         ShowMsg("请选择配送模板", false);
         return;
     }
     foreach (ListItem item in expressCheckBoxList.Items)
     {
         if (item.Selected)
         {
             ExpressCompanyInfo expressCompanyInfo = new ExpressCompanyInfo();
             expressCompanyInfo.ExpressCompanyName = item.Text;
             expressCompanyInfo.ExpressCompanyAbb = item.Value;
             target.ExpressCompany.Add(expressCompanyInfo);
         }
     }
     if (target.ExpressCompany.Count == 0)
     {
         ShowMsg("至少要选择一个配送公司", false);
     }
     else
     {
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<ShippingModeInfo>(target, new string[] { "ValShippingModeInfo" });
         string msg = string.Empty;
         if (!results.IsValid)
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             ShowMsg(msg, false);
         }
         else if (SalesHelper.CreateShippingMode(target))
         {
             ClearControlValue();
             ShowMsg("成功添加了一个配送方式", true);
         }
         else
         {
             ShowMsg("添加失败,请确定填写了所有必填项", false);
         }
     }
 }
示例#2
0
 public static ExpressCompanyInfo FindNodeByCode(string code)
 {
     ExpressCompanyInfo info = null;
     XmlDocument xmlNode = GetXmlNode();
     string xpath = string.Format("//company[@TaobaoCode='{0}']", code);
     XmlNode node = xmlNode.SelectSingleNode(xpath);
     if (node != null)
     {
         info = new ExpressCompanyInfo {
             Name = node.Attributes["name"].Value,
             Kuaidi100Code = node.Attributes["Kuaidi100Code"].Value,
             TaobaoCode = code
         };
     }
     return info;
 }
示例#3
0
 public static IList<ExpressCompanyInfo> GetAllExpress()
 {
     IList<ExpressCompanyInfo> list = new List<ExpressCompanyInfo>();
     XmlNode node = GetXmlNode().SelectSingleNode("companys");
     foreach (XmlNode node2 in node.ChildNodes)
     {
         ExpressCompanyInfo item = new ExpressCompanyInfo {
             Name = node2.Attributes["name"].Value,
             Kuaidi100Code = node2.Attributes["Kuaidi100Code"].Value,
             TaobaoCode = node2.Attributes["TaobaoCode"].Value
         };
         list.Add(item);
     }
     return list;
 }
示例#4
0
 private void btnUpDate_Click(object sender, EventArgs e)
 {
     ShippingModeInfo info3 = new ShippingModeInfo();
     info3.Name = Globals.HtmlEncode(txtModeName.Text.Trim());
     info3.ModeId = modeId;
     info3.Description = fck.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
     ShippingModeInfo target = info3;
     if (shippingTemplatesDropDownList.SelectedValue.HasValue)
     {
         target.TemplateId = shippingTemplatesDropDownList.SelectedValue.Value;
     }
     else
     {
         ShowMsg("请选择配送模板", false);
         return;
     }
     foreach (ListItem item in expressCheckBoxList.Items)
     {
         if (item.Selected)
         {
             ExpressCompanyInfo info2 = new ExpressCompanyInfo();
             info2.ExpressCompanyName = item.Text;
             info2.ExpressCompanyAbb = item.Value;
             target.ExpressCompany.Add(info2);
         }
     }
     if (target.ExpressCompany.Count == 0)
     {
         ShowMsg("至少要选择一个配送公司", false);
     }
     else
     {
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<ShippingModeInfo>(target, new string[] { "ValShippingModeInfo" });
         string msg = string.Empty;
         if (!results.IsValid)
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             ShowMsg(msg, false);
         }
         else if (SalesHelper.UpdateShippMode(target))
         {
             Page.Response.Redirect("EditShippingType.aspx?modeId=" + target.ModeId + "&isUpdate=true");
         }
         else
         {
             ShowMsg("更新失败", false);
         }
     }
 }
示例#5
0
 public override ShippingModeInfo GetShippingMode(int modeId, bool includeDetail)
 {
     ShippingModeInfo info = null;
     StringBuilder builder = new StringBuilder();
     builder.Append("SELECT * FROM Hishop_ShippingTypes st INNER JOIN Hishop_ShippingTemplates temp ON st.TemplateId=temp.TemplateId Where ModeId =@ModeId;");
     if (includeDetail)
     {
         builder.Append("SELECT GroupId,TemplateId,Price,AddPrice FROM Hishop_ShippingTypeGroups Where TemplateId IN (SELECT TemplateId FROM Hishop_ShippingTypes WHERE ModeId =@ModeId);");
         builder.Append("SELECT TemplateId,GroupId,RegionId FROM Hishop_ShippingRegions Where TemplateId IN (SELECT TemplateId FROM Hishop_ShippingTypes Where ModeId =@ModeId);");
         builder.Append(" SELECT * FROM Hishop_TemplateRelatedShipping Where ModeId =@ModeId");
     }
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     this.database.AddInParameter(sqlStringCommand, "ModeId", DbType.Int32, modeId);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateShippingMode(reader);
         }
         if (!includeDetail)
         {
             return info;
         }
         reader.NextResult();
         while (reader.Read())
         {
             info.ModeGroup.Add(DataMapper.PopulateShippingModeGroup(reader));
         }
         reader.NextResult();
         while (reader.Read())
         {
             foreach (ShippingModeGroupInfo info2 in info.ModeGroup)
             {
                 if (info2.GroupId == ((int) reader["GroupId"]))
                 {
                     info2.ModeRegions.Add(DataMapper.PopulateShippingRegion(reader));
                 }
             }
         }
         reader.NextResult();
         while (reader.Read())
         {
             ExpressCompanyInfo item = new ExpressCompanyInfo();
             if (reader["ExpressCompanyName"] != DBNull.Value)
             {
                 item.ExpressCompanyName = (string) reader["ExpressCompanyName"];
             }
             if (reader["ExpressCompanyAbb"] != DBNull.Value)
             {
                 item.ExpressCompanyAbb = (string) reader["ExpressCompanyAbb"];
             }
             info.ExpressCompany.Add(item);
         }
     }
     return info;
 }
示例#6
0
 public override IList<ExpressCompanyInfo> GetExpressCompanysByMode(int modeId)
 {
     IList<ExpressCompanyInfo> list = new List<ExpressCompanyInfo>();
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_TemplateRelatedShipping Where ModeId =@ModeId");
     this.database.AddInParameter(sqlStringCommand, "ModeId", DbType.Int32, modeId);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         while (reader.Read())
         {
             ExpressCompanyInfo item = new ExpressCompanyInfo();
             if (reader["ExpressCompanyName"] != DBNull.Value)
             {
                 item.ExpressCompanyName = (string) reader["ExpressCompanyName"];
             }
             if (reader["ExpressCompanyAbb"] != DBNull.Value)
             {
                 item.ExpressCompanyAbb = (string) reader["ExpressCompanyAbb"];
             }
             list.Add(item);
         }
     }
     return list;
 }
示例#7
0
 public override ShippingModeInfo GetShippingMode(int modeId, bool includeDetail)
 {
     ShippingModeInfo info = null;
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_ShippingTypes st INNER JOIN Hishop_ShippingTemplates temp ON st.TemplateId=temp.TemplateId Where ModeId =@ModeId");
     if (includeDetail)
     {
         sqlStringCommand.CommandText = sqlStringCommand.CommandText + " SELECT * FROM Hishop_TemplateRelatedShipping Where ModeId =@ModeId";
     }
     database.AddInParameter(sqlStringCommand, "ModeId", DbType.Int32, modeId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateShippingMode(reader);
         }
         if (!includeDetail)
         {
             return info;
         }
         reader.NextResult();
         while (reader.Read())
         {
             ExpressCompanyInfo item = new ExpressCompanyInfo();
             if (reader["ExpressCompanyName"] != DBNull.Value)
             {
                 item.ExpressCompanyName = (string)reader["ExpressCompanyName"];
             }
             if (reader["ExpressCompanyAbb"] != DBNull.Value)
             {
                 item.ExpressCompanyAbb = (string)reader["ExpressCompanyAbb"];
             }
             info.ExpressCompany.Add(item);
         }
     }
     return info;
 }
 private IList<ExpressCompanyInfo> GetDataSource()
 {
     IList<ExpressCompanyInfo> list = null;
     XmlDocument xmlNode = GetXmlNode();
     XmlNode node = null;
     if (xmlNode != null)
     {
         XmlNode node2 = xmlNode.SelectSingleNode("expressapi");
         if (node2 == null)
         {
             return list;
         }
         XmlNode node3 = node2.SelectSingleNode("kuaidi100");
         if (node3 != null)
         {
             node = node3.SelectSingleNode("companys");
         }
         if ((node == null) || (node.ChildNodes.Count <= 0))
         {
             return list;
         }
         list = new List<ExpressCompanyInfo>();
         foreach (XmlNode node4 in node.ChildNodes)
         {
             string str = node4["name"].InnerText.ToString();
             string str2 = node4["abb"].InnerText.ToString();
             if (!(string.IsNullOrEmpty(str) || string.IsNullOrEmpty(str2)))
             {
                 ExpressCompanyInfo item = new ExpressCompanyInfo();
                 item.ExpressCompanyAbb = str2;
                 item.ExpressCompanyName = str;
                 list.Add(item);
             }
         }
     }
     return list;
 }