コード例 #1
0
        protected void AddCard_Click(object sender, EventArgs e)
        {
            Card card = new Card();

            card.Card_Name1           = txtName.Text.Trim();
            card.Card_Cost1           = int.Parse(DropDownList_cost.SelectedItem.Text);
            card.Card_Rd1             = DropDownList_rd.SelectedItem.Text.ToString();
            card.Card_Ap1             = int.Parse(txtAp.Text.Trim());
            card.Card_Hp1             = int.Parse(txtHp.Text.Trim());
            card.Card_Characteristic1 = DropDownList_ch.SelectedItem.Text;
            card.Card_Race1           = DropDownList_Race.SelectedItem.Text;
            card.Card_Effect1         = txtEffect.Text.Trim();
            card.Card_Occupation1     = DropDownList3.SelectedItem.Text;
            card.Card_Off1            = DropDownList_off.SelectedItem.Text;
            card.Card_Img1            = @"~/Img_Card/" + FileUpload_img.PostedFile.FileName;
            try
            {
                if (CardBll.addcard(card) == 1)
                {
                    txtAp.Text     = "";
                    txtEffect.Text = "";
                    txtHp.Text     = "";
                    txtName.Text   = "";

                    Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('添加成功!');</script>");
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('添加失败!');</script>");
                }
            }
            catch (Exception ex)
            {
                Response.Write("错误原因:" + ex.Message);
            }
        }