Exemplo n.º 1
0
 protected void rptypelist_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
     {
         Repeater                   repeater            = e.Item.FindControl("ListShipper") as Repeater;
         FreightTemplate            dataItem            = (FreightTemplate)e.Item.DataItem;
         IList <SpecifyRegionGroup> specifyRegionGroups = SettingsHelper.GetSpecifyRegionGroups(Convert.ToInt32(dataItem.TemplateId));
         if (specifyRegionGroups.Count < 1)
         {
             SpecifyRegionGroup item = new SpecifyRegionGroup
             {
                 RegionIds   = "",
                 ModeId      = 1,
                 FristNumber = 1M,
                 FristPrice  = 0M,
                 AddNumber   = 1M,
                 AddPrice    = 0M,
                 IsDefault   = true
             };
             specifyRegionGroups.Add(item);
         }
         repeater.DataSource = specifyRegionGroups;
         repeater.DataBind();
     }
 }
        private FreightTemplate ReadPostData(NameValueCollection Form)
        {
            string          str      = "";
            FreightTemplate template = new FreightTemplate();

            try
            {
                this.TaskMsg.msg    = "";
                template.Name       = Form["Name"];
                template.TemplateId = int.Parse(Form["TemplateId"]);
                if (!string.IsNullOrEmpty(template.Name))
                {
                    template.MUnit = int.Parse(Form["MUnit"]);
                    if (int.Parse(Form["FreeShip"]) == 0)
                    {
                        template.FreeShip = false;
                    }
                    else
                    {
                        template.FreeShip = true;
                    }
                    if (!template.FreeShip)
                    {
                        ValidationResults results;
                        if (int.Parse(Form["HasFree"]) == 0)
                        {
                            template.HasFree = false;
                        }
                        else
                        {
                            template.HasFree = true;
                            int num = 0;
                            template.FreeShippings = new List <FreeShipping>();
                            while (!string.IsNullOrEmpty(Form["freeShippings[" + num + "][ModelId]"]) && (this.TaskMsg.msg == ""))
                            {
                                FreeShipping target = new FreeShipping
                                {
                                    ModeId          = int.Parse(Form["freeShippings[" + num + "][ModelId]"]),
                                    ConditionType   = int.Parse(Form["freeShippings[" + num + "][ConditionType]"]),
                                    ConditionNumber = Form["freeShippings[" + num + "][ConditionNumber]"]
                                };
                                string str2 = Form["freeShippings[" + num + "][FreeRegions]"];
                                if (!string.IsNullOrEmpty(str2))
                                {
                                    string[] strArray = str2.Split(new char[] { ',' });
                                    if (strArray.Length > 0)
                                    {
                                        target.FreeShippingRegions = new List <FreeShippingRegion>();
                                        foreach (string str3 in strArray)
                                        {
                                            int num2 = 0;
                                            if (int.TryParse(str3, out num2) && (num2 != 0))
                                            {
                                                FreeShippingRegion item = new FreeShippingRegion
                                                {
                                                    RegionId = num2
                                                };
                                                target.FreeShippingRegions.Add(item);
                                            }
                                        }
                                    }
                                }
                                results = Hishop.Components.Validation.Validation.Validate <FreeShipping>(target, new string[] { "ValFree" });
                                str     = "";
                                if (!results.IsValid)
                                {
                                    foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                                    {
                                        str = str + result.Message;
                                    }
                                    this.TaskMsg.msg = str;
                                }
                                template.FreeShippings.Add(target);
                                num++;
                            }
                        }
                        int num3 = 0;
                        if (!string.IsNullOrEmpty(Form["shipperSelect[" + num3 + "][ModelId]"]) && (this.TaskMsg.msg == ""))
                        {
                            template.SpecifyRegionGroups = new List <SpecifyRegionGroup>();
                            while (!string.IsNullOrEmpty(Form["shipperSelect[" + num3 + "][ModelId]"]) && (this.TaskMsg.msg == ""))
                            {
                                SpecifyRegionGroup group = new SpecifyRegionGroup
                                {
                                    ModeId      = int.Parse(Form["shipperSelect[" + num3 + "][ModelId]"]),
                                    FristPrice  = decimal.Parse(Form["shipperSelect[" + num3 + "][FristPrice]"]),
                                    AddNumber   = decimal.Parse(Form["shipperSelect[" + num3 + "][AddNumber]"]),
                                    FristNumber = decimal.Parse(Form["shipperSelect[" + num3 + "][FristNumber]"]),
                                    AddPrice    = decimal.Parse(Form["shipperSelect[" + num3 + "][AddPrice]"]),
                                    IsDefault   = false
                                };
                                if (int.Parse(Form["shipperSelect[" + num3 + "][IsDefault]"]) == 1)
                                {
                                    group.IsDefault = true;
                                }
                                string str4 = Form["shipperSelect[" + num3 + "][SpecifyRegions]"];
                                if (!string.IsNullOrEmpty(str4))
                                {
                                    string[] strArray2 = str4.Split(new char[] { ',' });
                                    if (strArray2.Length > 0)
                                    {
                                        group.SpecifyRegions = new List <SpecifyRegion>();
                                        foreach (string str5 in strArray2)
                                        {
                                            int num4 = 0;
                                            if (int.TryParse(str5, out num4) && (num4 != 0))
                                            {
                                                SpecifyRegion region2 = new SpecifyRegion
                                                {
                                                    RegionId = num4
                                                };
                                                group.SpecifyRegions.Add(region2);
                                            }
                                        }
                                    }
                                }
                                results = Hishop.Components.Validation.Validation.Validate <SpecifyRegionGroup>(group, new string[] { "ValRegionGroup" });
                                str     = "";
                                if (!results.IsValid)
                                {
                                    foreach (ValidationResult result2 in (IEnumerable <ValidationResult>)results)
                                    {
                                        str = str + result2.Message;
                                    }
                                    this.TaskMsg.msg = str;
                                }
                                template.SpecifyRegionGroups.Add(group);
                                num3++;
                            }
                        }
                        else
                        {
                            this.TaskMsg.msg = "没有运送方式选择";
                        }
                    }
                    else
                    {
                        template.HasFree = false;
                    }
                }
                else
                {
                    this.TaskMsg.msg = "模板名称不能为空";
                }
                if (this.TaskMsg.msg == "")
                {
                    this.TaskMsg.state = "success";
                    return(template);
                }
                this.TaskMsg.state = "faild";
            }
            catch (Exception exception)
            {
                this.TaskMsg.msg = "参数异常:" + exception.Message.ToString();
            }
            return(template);
        }
Exemplo n.º 3
0
        public FreightTemplate GetFreightTemplate(int templateId, bool includeDetail)
        {
            FreightTemplate freightTemplate = new FreightTemplate();

            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand(" SELECT * FROM Hishop_FreightTemplate_Templates Where TemplateId =@TemplateId");
            if (includeDetail)
            {
                System.Data.Common.DbCommand expr_24 = sqlStringCommand;
                expr_24.CommandText += " SELECT * FROM Hishop_FreightTemplate_FreeShipping g,vw_Hishop_FreightTemplate_FreeShippingRegions r Where g.FreeId=r.FreeId and TemplateId =@TemplateId";
                System.Data.Common.DbCommand expr_3B = sqlStringCommand;
                expr_3B.CommandText += " SELECT g.*,r.RegionIds FROM Hishop_FreightTemplate_SpecifyRegionGroups g  LEFT JOIN  vw_Hishop_FreightTemplate_SpecifyRegions r on (g.GroupId=r.GroupId) where  g.TemplateId =@TemplateId";
            }
            this.database.AddInParameter(sqlStringCommand, "TemplateId", System.Data.DbType.Int32, templateId);
            using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    if (dataReader["TemplateId"] != DBNull.Value)
                    {
                        freightTemplate.TemplateId = (int)dataReader["TemplateId"];
                    }
                    freightTemplate.Name     = (string)dataReader["Name"];
                    freightTemplate.FreeShip = (bool)dataReader["FreeShip"];
                    freightTemplate.HasFree  = (bool)dataReader["HasFree"];
                    freightTemplate.MUnit    = (int)((byte)dataReader["MUnit"]);
                }
                if (includeDetail)
                {
                    dataReader.NextResult();
                    freightTemplate.FreeShippings = new List <FreeShipping>();
                    while (dataReader.Read())
                    {
                        FreeShipping freeShipping = new FreeShipping();
                        freeShipping.TemplateId      = (int)dataReader["TemplateId"];
                        freeShipping.ModeId          = (int)((byte)dataReader["ModeId"]);
                        freeShipping.FreeId          = (int)((decimal)dataReader["FreeId"]);
                        freeShipping.ConditionNumber = (string)dataReader["ConditionNumber"];
                        freeShipping.ConditionType   = (int)((byte)dataReader["ConditionType"]);
                        freeShipping.RegionIds       = (string)dataReader["RegionIds"];
                        freightTemplate.FreeShippings.Add(freeShipping);
                    }
                    dataReader.NextResult();
                    freightTemplate.SpecifyRegionGroups = new List <SpecifyRegionGroup>();
                    while (dataReader.Read())
                    {
                        SpecifyRegionGroup specifyRegionGroup = new SpecifyRegionGroup();
                        specifyRegionGroup.TemplateId  = (int)dataReader["TemplateId"];
                        specifyRegionGroup.GroupId     = (int)dataReader["GroupId"];
                        specifyRegionGroup.FristNumber = (decimal)dataReader["FristNumber"];
                        specifyRegionGroup.FristPrice  = (decimal)dataReader["FristPrice"];
                        specifyRegionGroup.AddNumber   = (decimal)dataReader["AddNumber"];
                        specifyRegionGroup.AddPrice    = (decimal)dataReader["AddPrice"];
                        specifyRegionGroup.ModeId      = (int)((byte)dataReader["ModeId"]);
                        specifyRegionGroup.IsDefault   = (bool)dataReader["IsDefault"];
                        string regionIds = "";
                        if (DBNull.Value != dataReader["RegionIds"])
                        {
                            regionIds = (string)dataReader["RegionIds"];
                        }
                        specifyRegionGroup.RegionIds = regionIds;
                        freightTemplate.SpecifyRegionGroups.Add(specifyRegionGroup);
                    }
                }
            }
            return(freightTemplate);
        }
Exemplo n.º 4
0
        private FreightTemplate ReadPostData(System.Collections.Specialized.NameValueCollection Form)
        {
            string          text            = "";
            FreightTemplate freightTemplate = new FreightTemplate();

            try
            {
                this.TaskMsg.msg           = "";
                freightTemplate.Name       = Form["Name"];
                freightTemplate.TemplateId = int.Parse(Form["TemplateId"]);
                if (!string.IsNullOrEmpty(freightTemplate.Name))
                {
                    freightTemplate.MUnit = int.Parse(Form["MUnit"]);
                    if (int.Parse(Form["FreeShip"]) == 0)
                    {
                        freightTemplate.FreeShip = false;
                    }
                    else
                    {
                        freightTemplate.FreeShip = true;
                    }
                    if (!freightTemplate.FreeShip)
                    {
                        if (int.Parse(Form["HasFree"]) == 0)
                        {
                            freightTemplate.HasFree = false;
                        }
                        else
                        {
                            freightTemplate.HasFree = true;
                            int num = 0;
                            freightTemplate.FreeShippings = new System.Collections.Generic.List <FreeShipping>();
                            while (!string.IsNullOrEmpty(Form["freeShippings[" + num + "][ModelId]"]) && this.TaskMsg.msg == "")
                            {
                                FreeShipping freeShipping = new FreeShipping();
                                freeShipping.ModeId          = int.Parse(Form["freeShippings[" + num + "][ModelId]"]);
                                freeShipping.ConditionType   = int.Parse(Form["freeShippings[" + num + "][ConditionType]"]);
                                freeShipping.ConditionNumber = Form["freeShippings[" + num + "][ConditionNumber]"];
                                string text2 = Form["freeShippings[" + num + "][FreeRegions]"];
                                if (!string.IsNullOrEmpty(text2))
                                {
                                    string[] array = text2.Split(new char[]
                                    {
                                        ','
                                    });
                                    if (array.Length > 0)
                                    {
                                        freeShipping.FreeShippingRegions = new System.Collections.Generic.List <FreeShippingRegion>();
                                        string[] array2 = array;
                                        for (int i = 0; i < array2.Length; i++)
                                        {
                                            string s    = array2[i];
                                            int    num2 = 0;
                                            if (int.TryParse(s, out num2) && num2 != 0)
                                            {
                                                FreeShippingRegion freeShippingRegion = new FreeShippingRegion();
                                                freeShippingRegion.RegionId = num2;
                                                freeShipping.FreeShippingRegions.Add(freeShippingRegion);
                                            }
                                        }
                                    }
                                }
                                ValidationResults validationResults = Validation.Validate <FreeShipping>(freeShipping, new string[]
                                {
                                    "ValFree"
                                });
                                text = "";
                                if (!validationResults.IsValid)
                                {
                                    foreach (ValidationResult current in ((System.Collections.Generic.IEnumerable <ValidationResult>)validationResults))
                                    {
                                        text += current.Message;
                                    }
                                    this.TaskMsg.msg = text;
                                }
                                freightTemplate.FreeShippings.Add(freeShipping);
                                num++;
                            }
                        }
                        int num3 = 0;
                        if (!string.IsNullOrEmpty(Form["shipperSelect[" + num3 + "][ModelId]"]) && this.TaskMsg.msg == "")
                        {
                            freightTemplate.SpecifyRegionGroups = new System.Collections.Generic.List <SpecifyRegionGroup>();
                            while (!string.IsNullOrEmpty(Form["shipperSelect[" + num3 + "][ModelId]"]))
                            {
                                if (!(this.TaskMsg.msg == ""))
                                {
                                    break;
                                }
                                SpecifyRegionGroup specifyRegionGroup = new SpecifyRegionGroup();
                                specifyRegionGroup.ModeId      = int.Parse(Form["shipperSelect[" + num3 + "][ModelId]"]);
                                specifyRegionGroup.FristPrice  = decimal.Parse(Form["shipperSelect[" + num3 + "][FristPrice]"]);
                                specifyRegionGroup.AddNumber   = decimal.Parse(Form["shipperSelect[" + num3 + "][AddNumber]"]);
                                specifyRegionGroup.FristNumber = decimal.Parse(Form["shipperSelect[" + num3 + "][FristNumber]"]);
                                specifyRegionGroup.AddPrice    = decimal.Parse(Form["shipperSelect[" + num3 + "][AddPrice]"]);
                                specifyRegionGroup.IsDefault   = false;
                                if (int.Parse(Form["shipperSelect[" + num3 + "][IsDefault]"]) == 1)
                                {
                                    specifyRegionGroup.IsDefault = true;
                                }
                                string text3 = Form["shipperSelect[" + num3 + "][SpecifyRegions]"];
                                if (!string.IsNullOrEmpty(text3))
                                {
                                    string[] array3 = text3.Split(new char[]
                                    {
                                        ','
                                    });
                                    if (array3.Length > 0)
                                    {
                                        specifyRegionGroup.SpecifyRegions = new System.Collections.Generic.List <SpecifyRegion>();
                                        string[] array4 = array3;
                                        for (int j = 0; j < array4.Length; j++)
                                        {
                                            string s2   = array4[j];
                                            int    num4 = 0;
                                            if (int.TryParse(s2, out num4) && num4 != 0)
                                            {
                                                SpecifyRegion specifyRegion = new SpecifyRegion();
                                                specifyRegion.RegionId = num4;
                                                specifyRegionGroup.SpecifyRegions.Add(specifyRegion);
                                            }
                                        }
                                    }
                                }
                                ValidationResults validationResults = Validation.Validate <SpecifyRegionGroup>(specifyRegionGroup, new string[]
                                {
                                    "ValRegionGroup"
                                });
                                text = "";
                                if (!validationResults.IsValid)
                                {
                                    foreach (ValidationResult current2 in ((System.Collections.Generic.IEnumerable <ValidationResult>)validationResults))
                                    {
                                        text += current2.Message;
                                    }
                                    this.TaskMsg.msg = text;
                                }
                                freightTemplate.SpecifyRegionGroups.Add(specifyRegionGroup);
                                num3++;
                            }
                        }
                        else
                        {
                            this.TaskMsg.msg = "没有运送方式选择";
                        }
                    }
                    else
                    {
                        freightTemplate.HasFree = false;
                    }
                }
                else
                {
                    this.TaskMsg.msg = "模板名称不能为空";
                }
                if (this.TaskMsg.msg == "")
                {
                    this.TaskMsg.state = "success";
                }
                else
                {
                    this.TaskMsg.state = "faild";
                }
            }
            catch (System.Exception ex)
            {
                this.TaskMsg.msg = "参数异常:" + ex.Message.ToString();
            }
            return(freightTemplate);
        }
Exemplo n.º 5
0
        public FreightTemplate GetFreightTemplate(int templateId, bool includeDetail)
        {
            FreightTemplate template         = new FreightTemplate();
            DbCommand       sqlStringCommand = this.database.GetSqlStringCommand(" SELECT * FROM Hishop_FreightTemplate_Templates Where TemplateId =@TemplateId");

            if (includeDetail)
            {
                sqlStringCommand.CommandText = sqlStringCommand.CommandText + " SELECT * FROM Hishop_FreightTemplate_FreeShipping g,vw_Hishop_FreightTemplate_FreeShippingRegions r Where g.FreeId=r.FreeId and TemplateId =@TemplateId";
                sqlStringCommand.CommandText = sqlStringCommand.CommandText + " SELECT g.*,r.RegionIds FROM Hishop_FreightTemplate_SpecifyRegionGroups g  LEFT JOIN  vw_Hishop_FreightTemplate_SpecifyRegions r on (g.GroupId=r.GroupId) where  g.TemplateId =@TemplateId";
            }
            this.database.AddInParameter(sqlStringCommand, "TemplateId", DbType.Int32, templateId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    if (reader["TemplateId"] != DBNull.Value)
                    {
                        template.TemplateId = (int)reader["TemplateId"];
                    }
                    template.Name     = (string)reader["Name"];
                    template.FreeShip = (bool)reader["FreeShip"];
                    template.HasFree  = (bool)reader["HasFree"];
                    template.MUnit    = (byte)reader["MUnit"];
                }
                if (!includeDetail)
                {
                    return(template);
                }
                reader.NextResult();
                template.FreeShippings = new List <FreeShipping>();
                while (reader.Read())
                {
                    FreeShipping item = new FreeShipping {
                        TemplateId      = (int)reader["TemplateId"],
                        ModeId          = (byte)reader["ModeId"],
                        FreeId          = (int)((decimal)reader["FreeId"]),
                        ConditionNumber = (string)reader["ConditionNumber"],
                        ConditionType   = (byte)reader["ConditionType"],
                        RegionIds       = (string)reader["RegionIds"]
                    };
                    template.FreeShippings.Add(item);
                }
                reader.NextResult();
                template.SpecifyRegionGroups = new List <SpecifyRegionGroup>();
                while (reader.Read())
                {
                    SpecifyRegionGroup group = new SpecifyRegionGroup {
                        TemplateId  = (int)reader["TemplateId"],
                        GroupId     = (int)reader["GroupId"],
                        FristNumber = (int)reader["FristNumber"],
                        FristPrice  = (decimal)reader["FristPrice"],
                        AddNumber   = (int)reader["AddNumber"],
                        AddPrice    = (decimal)reader["AddPrice"],
                        ModeId      = (byte)reader["ModeId"],
                        IsDefault   = (bool)reader["IsDefault"]
                    };
                    string str = "";
                    if (DBNull.Value != reader["RegionIds"])
                    {
                        str = (string)reader["RegionIds"];
                    }
                    group.RegionIds = str;
                    template.SpecifyRegionGroups.Add(group);
                }
            }
            return(template);
        }