示例#1
0
        protected void BtnAddRegion_Click(object sender, EventArgs e)
        {
            var region = new Region();

            region.RegionName = RegionNamebox.Text.ToString().Trim();
            var regionService = new RegionService();
            int count         = regionService.ExperimentalRegion(region);

            // if(DDLCountry.Text=="")
            if (DDLCountry.Text == "-请选择-")
            {
                Response.Write("<script>alert('请选择国家')</script>");
            }
            else if (count <= 0)
            {
                region.CountryId = Convert.ToInt32(DDLCountry.SelectedValue);//get Id value
                if (!string.IsNullOrWhiteSpace(region.RegionName))
                {
                    var result = regionService.AddRegion(region);
                    if (result == 1)
                    {
                        BindCountry();
                        Response.Write("<script>alert('添加成功')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('添加失败')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('请填写地区')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('已经存在,换一个试试')</script>");
            }
        }