Exemplo n.º 1
0
    /// <summary>
    /// 保存事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ButtonSave_Click(object sender, EventArgs e)
    {
        try
        {
            WebBean bean  = WebBean.GetInstance();
            var     model = new UrlDataModel
            {
                GUID               = "add".Equals(AddOrUpdate) ? Guid.NewGuid().ToString() : UrlGuid,
                ParentGUID         = null,
                Url                = TextBoxUrl.Text.Trim(),
                UrlCode            = TextBoxUrlCode.Text.Trim(),
                UrlParams          = TextBoxParams.Text.Trim(),
                UrlName            = TextBoxUrlName.Text.Trim(),
                UserAuthentication = DropDownListAuthentication.SelectedValue == "0",
                Show               = DropDownListShow.SelectedValue == "0"
            };

            if ("add".Equals(AddOrUpdate))
            {
                bean.AddUrl(model);
            }
            else
            {
                bean.UpdateUrl(model);
            }
            Show(this.Page, "保存成功!");
        }
        catch (Exception ex)
        {
            Show(this.Page, "保存失败!");
            WriteLog.WriteExceptionLog(ex.ToString());
        }
    }
    /// <summary>
    /// 保存按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ButtonSave_Click(object sender, EventArgs e)
    {
        var selectedValue = string.Empty;

        foreach (RepeaterItem item in Repeater1.Items)
        {
            if (((RadioButton)item.FindControl("RadioButtonSelect")).Checked)
            {
                selectedValue = ((HiddenField)item.FindControl("HiddenFieldGUID")).Value.Trim();
                break;
            }
        }
        if (Request.QueryString["urlGuid"] == null)
        {
            return;
        }
        var urlGuid = Request.QueryString["urlGuid"];

        if (urlGuid != selectedValue.Trim())
        {
            WebBean bean    = WebBean.GetInstance();
            DataSet dataSet = bean.Select_Url_Data(urlGuid, string.Empty);
            if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0)
            {
                return;
            }
            UrlDataModel model = new UrlDataModel();
            foreach (DataRow row in dataSet.Tables[0].Rows)
            {
                model = new UrlDataModel
                {
                    GUID               = row["Url_GUID"].ToString(),
                    ParentGUID         = selectedValue,
                    Url                = row["Url"].ToString(),
                    UrlCode            = row["UrlCode"].ToString(),
                    UrlParams          = row["UrlParams"].ToString(),
                    UrlName            = row["UrlName"].ToString(),
                    UrlIndex           = int.Parse(row["UrlIndex"].ToString()),
                    UserAuthentication = (Boolean)row["UserAuthentication"],
                    Show               = (Boolean)row["Show"]
                };
            }
            try
            {
                bean.UpdateUrl(model);
            }
            catch (Exception)
            {
                throw;
            }
            if (!Page.ClientScript.IsStartupScriptRegistered("close"))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "close",
                                                        "<script language='javascript'>top.$.close('select');</script>");
            }
        }
    }