コード例 #1
0
ファイル: SetCountryOrArea.aspx.cs プロジェクト: 892182825/SP
    /// <summary>
    /// 添加国家
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAddNewCountry_Click(object sender, EventArgs e)
    {
        ///通过国家名称获取行数
        int getCount = SetRateBLL.GetCountryCountByCountryName(CountryBLL.GetCountryName(DropDownList1.SelectedValue));

        if (getCount > 0)
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002142", "国家名称已经存在!")));
            return;
        }

        getCount = SetRateBLL.GetCountryCountByRateID(Convert.ToInt32(this.DropNewCurrency.SelectedValue));

        if (txtCountryCode.Value.Trim() == "")
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002144", "对不起,国家编码不能为空!")));
            return;
        }

        else
        {
            int ccCount = SetRateBLL.CountryCodeIsExist(txtCountryCode.Value.Trim());
            if (ccCount > 0)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002145", "对不起,该国家编码已经存在!")));
                return;
            }
        }

        ///实例化国家模型
        CountryModel countryModel = new CountryModel();

        countryModel.CountryCode     = txtCountryCode.Value.Trim();
        countryModel.CountryForShort = CountryBLL.GetCountryShortName(DropDownList1.SelectedValue);
        countryModel.Name            = CountryBLL.GetCountryName(DropDownList1.SelectedValue);
        countryModel.RateID          = Convert.ToInt32(DropNewCurrency.SelectedItem.Value);
        ///向国家表中插入相关记录
        int addCount = SetRateBLL.AddCountry(countryModel);

        if (addCount > 0)
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002146", "添加国家成功!")));
            ResetValue();
        }

        else
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002149", "添加国家失败,请联系管理员!")));
            return;
        }

        GetAllCurrencyIDName();
        GetCountryInfo();
    }