Ejemplo n.º 1
0
 private void btnUpdate_Click_1(object sender, EventArgs e)
 {
     if (!mbbl.UpdateMon(txtMonID2.Text, txtIDMon.Text, txtTenMon.Text, cbTheLoai2.SelectedValue.ToString(), Convert.ToInt32(Math.Round(nudGia.Value)), dtpCapNhat.Value.ToString("yyyyMMdd")))
     {
         MessageBox.Show("update không thành công !!!");
     }
     else
     {
         MessageBox.Show("update" +
                         " thành công !!!");
     }
 }
Ejemplo n.º 2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string error = "Có lỗi xảy ra";

            if (them)
            {
                if (monbll.InsertMon(txtMaMon.Text, txtTenMon.Text, txtMLM.Text, float.Parse(txtGiaTien.Text), ref error))
                {
                    MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadMon();
                    dgvMon.DataSource = monbll.LayDanhSachMon(txtTenLM.Text);
                }
                else
                {
                    MessageBox.Show(error, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                int    r      = dgvMon.CurrentCell.RowIndex;
                string strMon =
                    dgvMon.Rows[r].Cells[0].Value.ToString();
                if (monbll.UpdateMon(strMon, txtTenMon.Text, float.Parse(txtGiaTien.Text), ref error))
                {
                    MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadMon();
                    dgvMon.DataSource = monbll.LayDanhSachMon(txtTenLM.Text);
                }
                else
                {
                    MessageBox.Show(error, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            this.groupBox1.Enabled = false;
            this.btnThem.Enabled   = true;
            this.btnSua.Enabled    = true;
            this.btnXoa.Enabled    = true;
            this.btnHuy.Enabled    = false;
            this.btnLuu.Enabled    = false;
        }