[ASP.NET C#] Xây dựng ứng dụng Cộng Trừ Nhân Chia

Thảo luận trong 'ASP.NET' bắt đầu bởi tranvcuong94, 15/9/16.

  1. tranvcuong94

    tranvcuong94 Moderator Moderator

    Tham gia ngày:
    9/4/16
    Bài viết:
    228
    Đã được thích:
    1
    Điểm thành tích:
    18
    Giới tính:
    Nam
    Nghề nghiệp:
    N/A
    Nơi ở:
    N/A
    Web:
    N/A

    tinh-cong-tru-nhan-chia.PNG

    CODE CS:
    CODE:
    Select All
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public 
    partial class _Default System.Web.UI.Page
    {
        protected 
    void Page_Load(object senderEventArgs e)
        {

        }
        protected 
    void btncong_Click(object senderEventArgs e)
        {
            
    int soThuNhat Convert.ToInt32(txtso1.Text);
            
    int soThuHai Convert.ToInt32(txtso2.Text);
           
            
    int Kq soThuNhat soThuHai;
            
    txtkq.Text Kq.ToString();
        }
        protected 
    void btntru_Click(object senderEventArgs e)
        {
            
    int soThuNhat Convert.ToInt32(txtso1.Text);
            
    int soThuHai Convert.ToInt32(txtso2.Text);
            
    int Kq soThuNhat soThuHai;
            
    txtkq.Text Kq.ToString();
        }
        protected 
    void btnnhan_Click(object senderEventArgs e)
        {
            
    int soThuNhat Convert.ToInt32(txtso1.Text);
            
    int soThuHai Convert.ToInt32(txtso2.Text);
            
    int Kq soThuNhat soThuHai;
            
    txtkq.Text Kq.ToString();
        }
        protected 
    void btnchia_Click(object senderEventArgs e)
        {
            
    float soThuNhat float.Parse(txtso1.Text);
            
    float soThuHai float.Parse(txtso2.Text);
            if (
    soThuHai == 0)
            {

            }
            else
            {
                
    float chia soThuNhat soThuHai;
                
    txtkq.Text chia.ToString();
            }
        }
    }
    CODE TRANG DEFAULT
    CODE:
    Select All
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!
    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <
    head runat="server">
        <
    title></title>
        <
    style type="text/css">
            .
    style1
            
    {
                
    width50%;
                
    text-align center;
            }
            .
    style3
            
    {
                
    width173px;
            }
            .
    style4
            
    {
                
    width133px;
            }
            .
    style5
            
    {
                
    width119px;
            }
            .
    style6
            
    {
                
    width100%;
            }
            .
    style7
            
    {
                
    width100%;
                
    height42px;
                
    text-aligncenter;
            }
            .
    style8
            
    {
                
    color#33CC33;
            
    }
        </
    style>
    </
    head>
    <
    body>
    <
    form id="form1" runat="server">
        <
    div>
       
            <
    table class="style1" style="border: thin solid #008000" width="50%"
                
    align="center">
                <
    tr>
                    <
    td colspan="4">
                        <
    table align="center" class="style6">
                            <
    tr>
                                <
    td class="style7">
                                    <
    strong><span class="style8">Tính Cộng Trừ Nhân Chia 2 Số</span><br />
                                    </
    strong>
                                </
    td>
                            </
    tr>
                        </
    table>
                        <
    br />
                        
    Số 1:
                        <
    asp:TextBox ID="txtso1" runat="server"></asp:TextBox>
                        <
    asp:RequiredFieldValidator ID="loi1" runat="server" ControlToValidate="txtso1"
                            
    ErrorMessage="* Bạn phải nhập vào giá trị"></asp:RequiredFieldValidator>
                    </
    td>
                </
    tr>
                <
    tr>
                    <
    td colspan="4">
                        
    Số 2:
                        <
    asp:TextBox ID="txtso2" runat="server"></asp:TextBox>
    &
    nbsp;<asp:RequiredFieldValidator ID="loi2" runat="server" ControlToValidate="txtso2"
                            
    ErrorMessage="*  Bạn phải nhập vào giá trị"></asp:RequiredFieldValidator>
                    </
    td>
                </
    tr>
                <
    tr>
                    <
    td class="style3">
                        <
    asp:Button ID="btncong" runat="server" onclick="btncong_Click"
                            
    style="margin-left: 80px" Text="Cộng" />
                    </
    td>
                    <
    td class="style5">
                        <
    asp:Button ID="btntru" runat="server" onclick="btntru_Click"
                            
    style="margin-left: 10px" Text="Trừ" />
                    </
    td>
                    <
    td class="style4">
                        <
    asp:Button ID="btnnhan" runat="server" onclick="btnnhan_Click"
                            
    style="margin-left: 0px" Text="Nhân" />
                    </
    td>
                    <
    td>
                        <
    asp:Button ID="btnchia" runat="server" onclick="btnchia_Click" Text="Chia" />
                    </
    td>
                </
    tr>
                <
    tr>
                    <
    td colspan="4">
                        <
    br />
                        
    Kết quả:&nbsp;
                        <
    asp:TextBox ID="txtkq" runat="server"></asp:TextBox>
                    </
    td>
                </
    tr>
            </
    table>
       
        </
    div>
        </
    form>
    </
    body>
    </
    html>
     

    Bình Luận Bằng Facebook

    data-href="https://cnttqn.com/threads/asp-net-c-xay-dung-ung-dung-cong-tru-nhan-chia.2548.html"