$maPhieuNhap = ThemPhieuNhap(); ThemChiTietPhieuNhap($maPhieuNhap); CapNhatKhoThuoc(); echo $maPhieuNhap; break; case "show": $maPhieuNhap = $_REQUEST['maphieu']; HienThiDanhSach($maPhieuNhap); break; case "detail": $maPhieuNhap = $_REQUEST['maphieu']; XemChiTiet($maPhieuNhap); break; case "delete": $maPhieuNhap = $_REQUEST['mact']; Xoa($maPhieuNhap); break; } function ThemPhieuNhap() { include "../../db.inc"; if ($_REQUEST['maphieu'] == 0) { $ngayNhan = $_REQUEST['ngayNhan']; $ngayNhan = ChangeFormatDate($ngayNhan); $query = "insert into PhieuNhapKho(NgayNhap) values('{$ngayNhan}')"; mysql_query($query, $link); // get current id $query = "select MaPhieuNhap from PhieuNhapKho order by MaPhieuNhap desc limit 0,1"; $result = mysql_query($query, $link); $row = mysql_fetch_row($result); $maPhieuNhap = $row[0];
include "../db.inc"; $loaiThuoc = $_POST['cbLoaiThuoc']; $cachDung = $_REQUEST['cbCachDung']; $ngaySX = ChangeFormatDate($_REQUEST['txtNgaySX']); $ngayHH = ChangeFormatDate($_REQUEST['txtNgayHetHan']); $tenThuoc = $_REQUEST["txtTenThuoc"]; $gia = $_REQUEST["txtGia"]; $query = "Update Thuoc set TenThuoc='{$tenThuoc}',MaLoaiThuoc={$loaiThuoc},MaCachSD={$cachDung},NgaySX='{$ngaySX}',NgayHetHan='{$ngayHH}',Gia={$gia} " . "where MaThuoc={$maThuoc}"; $result = mysql_query($query, $link); header('Location:DMThuoc_CapNhat.php?id=' . $maThuoc); } // "page_load" $act = $_REQUEST['act']; if (isset($act)) { switch ($act) { case "delete": $mathuoc = $_REQUEST['id']; Xoa($mathuoc); break; case "show": HienThiDanhSach(); break; case "insert": Them(); echo "<script>Them Thanh Cong</script>"; break; case "update": CapNhat($_REQUEST['id']); break; } }