コード例 #1
0
ファイル: Account.aspx.cs プロジェクト: buibup/Assignment-1
    protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        IAccountService objAccountService = null;

        try
        {
            decimal     balance    = 0;
            GridViewRow row        = GridView1.Rows[e.RowIndex];
            string      accountNo  = (row.FindControl("txtAccountNo") as TextBox).Text;
            string      balanceStr = (row.FindControl("txtBalance") as TextBox).Text;
            decimal.TryParse(balanceStr, out balance);

            objAccountService = Builder.AccountService();
            objAccountService.UpdateAccount(accountNo, balance);
        }
        catch (Exception ex)
        {
            throw new UILException("OnRowUpdating event occurs an error.[" + ex.Message + "]", ex, true);
        }
        finally
        {
            GridView1.EditIndex = -1;
            this.BindGrid();
        }
    }
コード例 #2
0
ファイル: Account.aspx.cs プロジェクト: buibup/Assignment-1
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        IAccountService objAccountService = null;

        try
        {
            var     accountNo         = txtAccountNo.Text;
            var     balanceStr        = txtBalance.Text;
            int     accNo             = 0;
            decimal balance           = 0;
            var     validateAccountNo = int.TryParse(accountNo, out accNo);
            var     validateBalance   = decimal.TryParse(balanceStr, out balance);

            if (!(validateAccountNo && validateBalance))
            {
                return;
            }

            objAccountService = Builder.AccountService();
            if (!objAccountService.AddAccount(accountNo, balance))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Account Exist.');", true);
            }
        }
        catch (Exception ex)
        {
            throw new UILException("btnAdd_Click event occurs an error.[" + ex.Message + "]", ex, true);
        }
        finally
        {
            this.ClearTextBox();
            this.BindGrid();
        }
    }
コード例 #3
0
ファイル: Account.aspx.cs プロジェクト: buibup/Assignment-1
    protected void btnSearchOr_Click(object sender, EventArgs e)
    {
        IAccountService objAccountService = null;

        try
        {
            objAccountService = Builder.AccountService();
            AccountEntity[] arrAccountEntity = objAccountService.Search(this.txtSearch.Text);
            this.GridView1.DataSource = arrAccountEntity;
            this.GridView1.DataBind();
        }
        catch (Exception ex)
        {
            throw new UILException("btnSearchOr_Click event occurs an error.[" + ex.Message + "]", ex, true);
        }
    }
コード例 #4
0
ファイル: Account.aspx.cs プロジェクト: buibup/Assignment-1
    private void BindGrid()
    {
        IAccountService objAccountService = null;

        try
        {
            objAccountService = Builder.AccountService();
            AccountEntity[] arrAccountEntity = objAccountService.Search("");
            this.GridView1.DataSource = arrAccountEntity;
            this.GridView1.DataBind();
        }
        catch (Exception ex)
        {
            throw new UILException("BindGrid event occurs an error.[" + ex.Message + "]", ex, true);
        }
    }
コード例 #5
0
ファイル: Account.aspx.cs プロジェクト: buibup/Assignment-1
    protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        IAccountService accountService = null;

        try
        {
            var accountNo = Convert.ToString((GridView1.DataKeys[e.RowIndex].Values[0]));
            //GridViewRow row = GridView1.Rows[e.RowIndex];
            //var accountNo = (row.FindControl("txtAccountNo") as TextBox).Text;
            accountService = Builder.AccountService();
            accountService.DeleteAccount(accountNo);
        }
        catch (Exception ex)
        {
            throw new UILException("OnRowDeleting event occurs an error.[" + ex.Message + "]", ex, true);
        }
        finally
        {
            this.BindGrid();
        }
    }
コード例 #6
0
ファイル: Default.aspx.cs プロジェクト: buibup/Assignment-1
    protected void btnDeposit_Click(object sender, EventArgs e)
    {
        IAccountService objAccountService = null;

        try
        {
            objAccountService = Builder.AccountService();
            objAccountService.Deposit(this.txtAccountNo4.Text, Convert.ToDecimal(this.txtMoney4.Text));
        }
        catch (Exception ex)
        {
            throw new Exception(ErrorMessage.DecodeMessage(ex.Message));
        }
        finally
        {
            if (objAccountService != null)
            {
                objAccountService.Dispose();
            }
        }
    }
コード例 #7
0
ファイル: Default.aspx.cs プロジェクト: buibup/Assignment-1
    protected void btnClose_Click(object sender, EventArgs e)
    {
        IAccountService objAccountService = null;

        try
        {
            objAccountService = Builder.AccountService();
            objAccountService.CloseAccount(this.txtAccountNo3.Text);
        }
        catch (Exception ex)
        {
            throw new Exception(ErrorMessage.DecodeMessage(ex.Message));
        }
        finally
        {
            if (objAccountService != null)
            {
                objAccountService.Dispose();
            }
        }
    }
コード例 #8
0
ファイル: Default.aspx.cs プロジェクト: buibup/Assignment-1
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        IAccountService objAccountService = null;

        try
        {
            objAccountService = Builder.AccountService();
            AccountEntity[] arrAccountEntity = objAccountService.SearchAccount(this.txtAccountNo1.Text);
            this.grdResult.DataSource = arrAccountEntity;
            this.grdResult.DataBind();
        }
        catch (Exception ex)
        {
            throw new Exception(ErrorMessage.DecodeMessage(ex.Message));
        }
        finally
        {
            if (objAccountService != null)
            {
                objAccountService.Dispose();
            }
        }
    }