private void btnThemLoaiThucUong_Click(object sender, EventArgs e) { LoaiThucUongDTO ltuTam = new LoaiThucUongDTO(); if (txtTenLoaiThucUong.Text == string.Empty) { MessageBox.Show("Bạn chưa nhập đầy đủ thông tin!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { ltuTam.Tenloaitu = txtTenLoaiThucUong.Text; } if (loaituBUS.ThemLoaiTU(ltuTam)) { MessageBox.Show("Thêm thành công!", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDsLoaiTU(); LoadComboboxLoaiTU(); AutoCompleteLoaiTU(); } else { MessageBox.Show("Thêm thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSuaLoaiThucUong_Click(object sender, EventArgs e) { LoaiThucUongDTO ltuTam = new LoaiThucUongDTO(); ltuTam.Maloaitu = Convert.ToInt32(dtgvLoaiThucUong.SelectedCells[0].OwningRow.Cells["colMaLoaiTU"].Value.ToString()); if (txtTenLoaiThucUong.Text == string.Empty) { MessageBox.Show("Bạn chưa nhập đầy đủ thông tin!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { ltuTam.Tenloaitu = txtTenLoaiThucUong.Text; } if (loaituBUS.SuaLoaiTU(ltuTam)) { MessageBox.Show("Sửa thành công!", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDsLoaiTU(); LoadComboboxLoaiTU(); AutoCompleteLoaiTU(); } else { MessageBox.Show("Sửa thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnLoaiThucUong_Click(object sender, EventArgs e) { LoaiThucUongDTO ltuTam = new LoaiThucUongDTO(); string tenLTU = txtTimKiemLoaiThucUong.Text; ltuTam = loaituBUS.TimKiemLoaiTU(tenLTU); if (ltuTam != null) { foreach (DataGridViewRow row in dtgvLoaiThucUong.Rows) { if (Convert.ToInt32(row.Cells["colMaLoaiTU"].Value.ToString()) == ltuTam.Maloaitu) { row.Selected = true; dtgvLoaiThucUong.CurrentCell = dtgvLoaiThucUong.Rows[row.Index].Cells[0]; txtTenLoaiThucUong.Text = ltuTam.Tenloaitu; } } } else { MessageBox.Show("Không tìm thấy!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }