protected void btnThem_Click(object sender, EventArgs e) { if (cmbHangHoa.Value != null && txtSoLuong.Text != "") { float SoLuong = float.Parse(txtSoLuong.Value.ToString()); if (SoLuong > 0) { string IDNguyenLieu = cmbHangHoa.Value.ToString(); string IDPhieuXuatKhac = IDPhieuXuatKhac_Temp.Value.ToString(); DataTable db = data.KTChiTietPhieuXuatKhac_Temp(IDNguyenLieu, IDPhieuXuatKhac);// kiểm tra hàng hóa if (db.Rows.Count == 0) { data = new dtPhieuXuatKhac(); data.ThemPhieuXuatKhac_Temp1(IDPhieuXuatKhac, IDNguyenLieu, txtTonKho.Text, dtThemHangHoa.LayIDDonViTinh(IDNguyenLieu), txtSoLuong.Text, dtThemHangHoa.LayMaNguyenLieu(IDNguyenLieu), dtSetting.GiaMua(IDNguyenLieu).ToString()); Clear(); } else { data = new dtPhieuXuatKhac(); data.UpdatePhieuXuatKhac_temp(IDPhieuXuatKhac, IDNguyenLieu, SoLuong.ToString()); Clear(); } LoadGrid(IDPhieuXuatKhac); } else { txtSoLuong.Focus(); Response.Write("<script language='JavaScript'> alert('Số Lượng phải > 0.'); </script>"); } } else { cmbHangHoa.Focus(); Response.Write("<script language='JavaScript'> alert('Bạn chưa chọn nguyên liệu.'); </script>"); } }
protected void btnThem_Click(object sender, EventArgs e) { if (cmbHangHoa.Value != null && txtSoLuong.Text != "") { float SoLuong = float.Parse(txtSoLuong.Value.ToString()); if (SoLuong > 0) { float SLTon = float.Parse(txtTonKho.Text); string IDHangHoa = cmbHangHoa.Value.ToString(); string IDPhieuXuatKhac = IDPhieuXuatKhac_Temp.Value.ToString(); string MaHang = dtHangHoa.LayMaHang(IDHangHoa); string IDDonViTinh = dtHangHoa.LayIDDonViTinh(IDHangHoa); string TonKho = txtTonKho.Text.ToString(); string GhiChuHH = txtGhiChuHH.Text == null ? "" : txtGhiChuHH.Text.ToString(); if (dtSetting.KT_ChuyenAm() == 0) { if (SLTon < SoLuong) { txtSoLuong.Text = SLTon.ToString(); Response.Write("<script language='JavaScript'> alert('Hàng hóa tồn kho không đủ.'); </script>"); } else { DataTable db = data.KTChiTietPhieuXuatKhac_Temp(IDHangHoa, IDPhieuXuatKhac);// kiểm tra hàng hóa if (db.Rows.Count == 0) { data = new dtPhieuXuatKhac(); data.ThemPhieuXuatKhac_Temp(IDPhieuXuatKhac, MaHang, IDHangHoa, IDDonViTinh, TonKho, SoLuong.ToString(), GhiChuHH); Clear(); } else { data = new dtPhieuXuatKhac(); data.UpdatePhieuXuatKhac_temp(IDPhieuXuatKhac, IDHangHoa, SoLuong); Clear(); } LoadGrid(IDPhieuXuatKhac); } } else { DataTable db = data.KTChiTietPhieuXuatKhac_Temp(IDHangHoa, IDPhieuXuatKhac);// kiểm tra hàng hóa if (db.Rows.Count == 0) { data = new dtPhieuXuatKhac(); data.ThemPhieuXuatKhac_Temp(IDPhieuXuatKhac, MaHang, IDHangHoa, IDDonViTinh, TonKho, SoLuong.ToString(), GhiChuHH); Clear(); } else { data = new dtPhieuXuatKhac(); data.UpdatePhieuXuatKhac_temp(IDPhieuXuatKhac, IDHangHoa, SoLuong); Clear(); } if (SLTon < SoLuong) { Response.Write("<script language='JavaScript'> alert('Số hàng tồn trong kho hiện tại không đủ.'); </script>"); } LoadGrid(IDPhieuXuatKhac); } } else { Response.Write("<script language='JavaScript'> alert('Số Lượng phải > 0.'); </script>"); } } else { Response.Write("<script language='JavaScript'> alert('Bạn chưa chọn hàng hóa.'); </script>"); } }