Пример #1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMaGiong.Text.Trim() == "")
            {
                MessageBox.Show("Mã giống không được bỏ trống!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtTenGiong.Text.Trim() == "")
            {
                MessageBox.Show("Tên giống không được bỏ trống!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                GiongInfo giong = new GiongInfo();
                giong.MaGiong  = txtMaGiong.Text.Trim();
                giong.TenGiong = txtTenGiong.Text.Trim();
                giong.CaoTB    = (txtCaoTB.Text.Trim() != "") ? double.Parse(txtCaoTB.Text.Trim()) : 0;
                giong.NangTB   = (txtNangTB.Text.Trim() != "") ? double.Parse(txtNangTB.Text.Trim()) : 0;

                if (isThem)
                {
                    giongBus.Them(giong);
                }
                else
                {
                    giong.MaGiong = dGV.CurrentRow.Cells[0].Value.ToString();
                    giongBus.Sua(giong, maGiong);
                }

                // Tải lại lưới
                frmGiong_Load(sender, e);
            }
        }
Пример #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa giống " + txtTenGiong.Text + "?", "Xóa", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                GiongInfo info = new GiongInfo();
                info.MaGiong = dGV.CurrentRow.Cells[0].Value.ToString();
                giongBus.Xoa(info);
            }

            // Tải lại lưới
            frmGiong_Load(sender, e);
        }
Пример #3
0
 public void Xoa(GiongInfo info)
 {
     data.Xoa(info);
 }
Пример #4
0
 public void Sua(GiongInfo info, string maGiong)
 {
     data.Sua(info, maGiong);
 }
Пример #5
0
 public void Them(GiongInfo info)
 {
     data.Them(info);
 }
Пример #6
0
        public void Xoa(GiongInfo info)
        {
            string sql = "DELETE FROM GIONG WHERE MAGIONG = '" + info.MaGiong + "'";

            db.ExecuteSQL(sql);
        }
Пример #7
0
        public void Sua(GiongInfo info, string maGiong)
        {
            string sql = "UPDATE GIONG SET MAGIONG = '" + info.MaGiong + "', TENGIONG = N'" + info.TenGiong + "', CAOTB = " + info.CaoTB + ", NANGTB = " + info.NangTB + " WHERE MAGIONG = '" + maGiong + "'";

            db.ExecuteSQL(sql);
        }
Пример #8
0
        public void Them(GiongInfo info)
        {
            string sql = "INSERT INTO GIONG(MAGIONG, TENGIONG, CAOTB, NANGTB) VALUES('" + info.MaGiong + "', N'" + info.TenGiong + "'," + info.CaoTB + "," + info.NangTB + ")";

            db.ExecuteSQL(sql);
        }