Пример #1
0
        public async Task <IActionResult> Edit(string id, [Bind("MaSvc,MaHp,Diem")] Ketqua ketqua)
        {
            if (id != ketqua.MaSvc)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ketqua);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KetquaExists(ketqua.MaSvc))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaHp"]  = new SelectList(_context.Hocphan, "MaHp", "MaHp", ketqua.MaHp);
            ViewData["MaSvc"] = new SelectList(_context.Sinhvien, "MaSv", "MaSv", ketqua.MaSvc);
            return(View(ketqua));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("MaSvc,MaHp,Diem")] Ketqua ketqua)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ketqua);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaHp"]  = new SelectList(_context.Hocphan, "MaHp", "MaHp", ketqua.MaHp);
            ViewData["MaSvc"] = new SelectList(_context.Sinhvien, "MaSv", "MaSv", ketqua.MaSvc);
            return(View(ketqua));
        }
Пример #3
0
        public void Tinhtoan()
        {
            txtOutput.Text = double.Parse(txtOutput.Text).ToString();
            double Ketqua;

            if (!CoKetqua)
            {
                Sohang2 = double.Parse(txtOutput.Text);
            }
            if (Pheptinh == "+")
            {
                if (!CoKetqua)
                {
                    Ketqua = Sohang1 + Sohang2;
                }
                else
                {
                    Ketqua = double.Parse(txtOutput.Text) + Sohang2;
                }
                txtOutput.Text = Ketqua.ToString();
            }
            else
            if (Pheptinh == "-")
            {
                if (!CoKetqua)
                {
                    Ketqua = Sohang1 - Sohang2;
                }
                else
                {
                    Ketqua = double.Parse(txtOutput.Text) - Sohang2;
                }
                txtOutput.Text = Ketqua.ToString();
            }
            else
            if (Pheptinh == "*")
            {
                if (!CoKetqua)
                {
                    Ketqua = Sohang1 * Sohang2;
                }
                else
                {
                    Ketqua = double.Parse(txtOutput.Text) * Sohang2;
                }
                txtOutput.Text = Ketqua.ToString();
            }
            else
            if (Pheptinh == "/")
            {
                if (Sohang2 != 0)            //khác 0 mới chia
                {
                    if (!CoKetqua)
                    {
                        Ketqua = Sohang1 / Sohang2;
                    }
                    else
                    {
                        Ketqua = double.Parse(txtOutput.Text) / Sohang2;
                    }
                    txtOutput.Text = Ketqua.ToString();
                }
                else
                {
                    txtOutput.Text = "Không thể chia cho 0!";
                    CoTeliet       = true;      //bật thằng này lên để khỏi bấm phím ngoài CE và C
                }
            }
            CoKetqua   = true;
            CoPheptinh = false;
        }
Пример #4
0
        public void Tinhtoan()
        {
            txt_pheptinh.Text = double.Parse(txt_pheptinh.Text).ToString();
            double Ketqua;

            if (!CoKetqua)
            {
                Sohang2 = double.Parse(txt_pheptinh.Text);
            }
            if (Pheptinh == "+")
            {
                if (!CoKetqua)
                {
                    Ketqua = Sohang1 + Sohang2;
                }
                else
                {
                    Ketqua = double.Parse(txt_pheptinh.Text) + Sohang2;
                }
                txt_pheptinh.Text = Ketqua.ToString();
            }
            else
            if (Pheptinh == "-")
            {
                if (!CoKetqua)
                {
                    Ketqua = Sohang1 - Sohang2;
                }
                else
                {
                    Ketqua = double.Parse(txt_pheptinh.Text) - Sohang2;
                }
                txt_pheptinh.Text = Ketqua.ToString();
            }
            else
            if (Pheptinh == "*")
            {
                if (!CoKetqua)
                {
                    Ketqua = Sohang1 * Sohang2;
                }
                else
                {
                    Ketqua = double.Parse(txt_pheptinh.Text) * Sohang2;
                }
                txt_pheptinh.Text = Ketqua.ToString();
            }
            else
            if (Pheptinh == "/")
            {
                if (Sohang2 != 0)            //khác 0 mới thuc hien chia
                {
                    if (!CoKetqua)
                    {
                        Ketqua = Sohang1 / Sohang2;
                    }
                    else
                    {
                        Ketqua = double.Parse(txt_pheptinh.Text) / Sohang2;
                    }
                    txt_pheptinh.Text = Ketqua.ToString();
                }
                else
                {
                    txt_pheptinh.Text = "Không thể chia cho 0!";
                    kiemtra           = true;   // khỏi bấm phím ngoài CE và C
                }
            }
            CoKetqua   = true;
            CoPheptinh = false;
        }