Пример #1
0
    protected void save_Click(object sender, EventArgs e)
    {
        //表头
        T_Account item = new T_Account();

        item.AccountName = txt_account_name.Text.Trim();
        if (string.IsNullOrEmpty(item.AccountName))
        {
            Label1.Text = "账户名不能为空";
            return;
        }
        item.AccountId = txt_account_id.Text.Trim();
        if (string.IsNullOrEmpty(item.AccountId))
        {
            Label1.Text = "账号不能为空";
            return;
        }
        item.OpeningBank = txt_opening_bank.Text.Trim();
        if (string.IsNullOrEmpty(item.OpeningBank))
        {
            Label1.Text = "开户行不能为空";
            return;
        }
        item.CurrencyID = Int32.Parse(ddl_currency.SelectedValue);
        string amount = txt_amount.Text.Trim();

        if (string.IsNullOrEmpty(amount))
        {
            item.Amount = 0;
        }
        else
        {
            item.Amount = Decimal.Parse(amount);
        }


        try
        {
            AccountAdapter aa = new AccountAdapter();
            if (string.IsNullOrEmpty(HiddenField1.Value))
            {
                aa.insertAccount(item);
            }
            else
            {
                aa.update(item);
            }
            clean();
            GridView1.SelectedIndex = -1;
            show();
            Label1.Text = "哟,小伙子,不错,被你录入成功了";
        }
        catch (Exception ex)
        {
            Label1.Text = ex.Message;
        }
    }