private void btnSua_Click_1(object sender, EventArgs e) { if (kttxt()) { DialogResult dlr = MessageBox.Show("Bạn có chắc muốn sửa dữ liệu nhập kho này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dlr == DialogResult.Yes) { String sql = "set dateformat dmy update phieunhap_kho set mancc = '" + NHACUNGCAPDAO.MaNCCTheoTenNCC(QuanLyNhaCungCap.dsNCC, cbboxTenSP.SelectedItem.ToString().Trim()) + "', ngaylap = '" + dateNgayLap.Text.Trim() + "', ghichu = N'" + txtGhiChu.Text.Trim() + "' where mapn = '" + txtMaNK.Text.Trim() + "'"; cn.themxoasua(sql); NHAPKHODAO.SuaNK(dsNK, txtMaNK.Text.Trim(), NHACUNGCAPDAO.MaNCCTheoTenNCC(QuanLyNhaCungCap.dsNCC, cbboxTenSP.SelectedItem.ToString().Trim()), dateNgayLap.Text.Trim(), txtGhiChu.Text.Trim()); DataGridViewRow row = dgvNK.Rows[indexNK]; row.Cells[1].Value = dateNgayLap.Text.Trim(); row.Cells[3].Value = cbboxTenNCC.SelectedItem.ToString().Trim(); row.Cells[4].Value = txtGhiChu.Text.Trim(); MessageBox.Show("Sửa thành công"); } } }
private void btnLuu_Click(object sender, EventArgs e) { if (kttxt() && ktmanktrung()) { DialogResult dlr = MessageBox.Show("Bạn có chắc muốn lưu dữ liệu nhập kho này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dlr == DialogResult.Yes) { String sql = "set dateformat dmy insert into phieunhap_kho values ('" + txtMaNK.Text.Trim() + "', '" + NHACUNGCAPDAO.MaNCCTheoTenNCC(QuanLyNhaCungCap.dsNCC, cbboxTenSP.SelectedItem.ToString().Trim()) + "', '" + dateNgayLap.Text.Trim() + "', '" + DangNhap.MaNV + "', N'" + txtGhiChu.Text.Trim() + "')"; cn.themxoasua(sql); NHAPKHODAO.ThemNK(dsNK, txtMaNK.Text.Trim(), NHACUNGCAPDAO.MaNCCTheoTenNCC(QuanLyNhaCungCap.dsNCC, cbboxTenSP.SelectedItem.ToString().Trim()), dateNgayLap.Text.Trim(), DangNhap.MaNV, txtGhiChu.Text.Trim()); dgvNK.Rows.Add(txtMaNK.Text.Trim(), dateNgayLap.Text.Trim(), DangNhap.MaNV, cbboxTenNCC.SelectedItem.ToString().Trim(), txtGhiChu.Text.Trim()); cbboxMaNK.Items.Add(txtMaNK.Text.Trim()); btnThem.Enabled = true; btnLuu.Enabled = false; MessageBox.Show("Thêm thành công"); } } }