protected void Page_Load(object sender, EventArgs e) { string NgayBD = Request.QueryString["ngayBD"]; string NgayKT = Request.QueryString["NgayKT"]; string IDLyDo = Request.QueryString["IDLyDo"]; string strLyDo = "Tất cả"; if (Int32.Parse(IDLyDo) != -1) { dtPhieuXuatKhac dt = new dtPhieuXuatKhac(); strLyDo = dt.lyDoXuat(IDLyDo); } string strNgay = DateTime.Parse(NgayBD).ToString("dd-MM-yyyy") + " - " + DateTime.Parse(NgayKT).ToString("dd-MM-yyyy"); rpBKXuatKhac rp = new rpBKXuatKhac(); rp.Parameters["IDLyDo"].Value = IDLyDo; rp.Parameters["IDLyDo"].Visible = false; rp.Parameters["strLyDo"].Value = strLyDo; rp.Parameters["strLyDo"].Visible = false; rp.Parameters["strNgay"].Value = strNgay; rp.Parameters["strNgay"].Visible = false; rp.Parameters["NgayBD"].Value = NgayBD; rp.Parameters["NgayBD"].Visible = false; rp.Parameters["NgayKT"].Value = NgayKT; rp.Parameters["NgayKT"].Visible = false; viewerReport.Report = rp; }
protected void btnHuyPhieuXuatKhac_Click(object sender, EventArgs e) { data = new dtPhieuXuatKhac(); int ID = Int32.Parse(IDPhieuXuatKhac_Temp.Value.ToString()); data.XoaChiTietPhieuXuatKhac_Temp(IDPhieuXuatKhac_Temp.Value.ToString()); Response.Redirect("DanhSachPhieuXuatKhac.aspx"); }
private void LoadGrid() { data = new dtPhieuXuatKhac(); gridPhieuXuatKhac.DataSource = data.DanhSachPhieuXuatKhac(); gridPhieuXuatKhac.DataBind(); dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Danh sách phiếu xuất khác", "Truy cập"); }
protected void gridDanhSachHangHoa_Temp_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { int ID = Int32.Parse(e.Keys[0].ToString()); data = new dtPhieuXuatKhac(); data.XoaChiTietPhieuXuatKhac_Temp_ID(ID); e.Cancel = true; gridDanhSachHangHoa_Temp.CancelEdit(); LoadGrid(IDPhieuXuatKhac_Temp.Value.ToString()); }
protected void btnThemPhieuXuatKhac_Click(object sender, EventArgs e) { if (cmbLyDoXuat.Text != "") { string IDPhieuXuatKhac = IDPhieuXuatKhac_Temp.Value.ToString(); DataTable db = data.LayDanhSachPhieuXuatKhac(IDPhieuXuatKhac); if (db.Rows.Count != 0) { string IDNguoiLapPhieu = cmbNguoiLapPhieu.Value.ToString(); DateTime NgayLapPhieu = DateTime.Parse(cmbNgayLapPhieu.Text.ToString()); string IDLyDoXuat = cmbLyDoXuat.Value.ToString(); string GhiChu = txtGhiChu == null ? "" : txtGhiChu.Text.ToString(); string SoDonXuat = txtSoDonXuat.Text.ToString(); string IDNhanVien = Session["IDNhanVien"].ToString(); data = new dtPhieuXuatKhac(); object ID = data.ThemPhieuXuatKhac(IDNhanVien, IDLyDoXuat, GhiChu, NgayLapPhieu, SoDonXuat); if (ID != null) { foreach (DataRow dr in db.Rows) { string MaHang = dr["MaHang"].ToString(); string IDHangHoa = dr["IDHangHoa"].ToString(); string IDDonViTinh = dr["IDDonViTinh"].ToString(); string TonKho = dr["TonKho"].ToString(); string SoLuongXuat = dr["SoLuongXuat"].ToString(); string GhiChuHH = dr["GhiChu"].ToString(); data = new dtPhieuXuatKhac(); data.ThemChiTietPhieuXuatKhac(ID, MaHang, IDHangHoa, IDDonViTinh, TonKho, SoLuongXuat, GhiChuHH); // dtLichSuKho.ThemLichSu(IDHangHoa, Session["IDNhanVien"].ToString(), SoLuong, "Phiếu xuất khác", Session["IDKho"].ToString()); // dtLichSuKho.ThemLichSuXuat(IDHangHoa, Session["IDNhanVien"].ToString(), SoLuong, Session["IDKho"].ToString()); // xuất khác qua giám đốc duyệt // object TheKho = dtTheKho.ThemTheKho(SoDonXuat, "Phiếu xuất khác ", "0", "", (Int32.Parse(dtCapNhatTonKho.SoLuong_TonKho(IDHangHoa, Session["IDKho"].ToString()).ToString()) - Int32.Parse(SoLuongXuat)).ToString(), Session["IDNhanVien"].ToString(), Session["IDKho"].ToString(), IDHangHoa, "Xuất", SoLuongXuat, "0", "0"); // if (TheKho != null) // { dtCapNhatTonKho.TruTonKho(IDHangHoa, SoLuongXuat, Session["IDKho"].ToString()); // } } dtLichSuTruyCap.ThemLichSu(Session["IDNhanVien"].ToString(), Session["IDNhom"].ToString(), "Phiếu Xuất Khác", Session["IDKho"].ToString(), "Nhập xuất tồn", "Thêm"); data = new dtPhieuXuatKhac(); data.XoaChiTietPhieuXuatKhac_Temp(IDPhieuXuatKhac); Response.Redirect("DanhSachPhieuXuatKhac.aspx"); } } else { Response.Write("<script language='JavaScript'> alert('Danh sách hàng hóa rỗng.'); </script>"); } } else { Response.Write("<script language='JavaScript'> alert('Vui lòng chọn lý do để xuất.'); </script>"); } }
protected void btnThemPhieuXuatKhac_Click(object sender, EventArgs e) { if (cmbLyDoXuat.Text != "") { string IDPhieuXuatKhac = IDPhieuXuatKhac_Temp.Value.ToString(); DataTable db = data.LayDanhSachPhieuXuatKhac_Temp(IDPhieuXuatKhac); if (db.Rows.Count != 0) { string IDNguoiLapPhieu = Session["IDNhanVien"].ToString(); DateTime NgayLapPhieu = DateTime.Parse(cmbNgayLapPhieu.Text.ToString()); string IDLyDoXuat = cmbLyDoXuat.Value.ToString(); string GhiChu = txtGhiChu == null ? "" : txtGhiChu.Text.ToString(); string IDChiNhanh = Session["IDChiNhanh"].ToString(); data = new dtPhieuXuatKhac(); object ID = data.ThemPhieuXuatKhac_Temp(); if (ID != null) { data.CapNhatPhieuXuatKhac_ID(ID, IDNguoiLapPhieu, IDLyDoXuat, NgayLapPhieu, GhiChu, IDChiNhanh); foreach (DataRow dr in db.Rows) { string IDNguyenLieu = dr["IDNguyenLieu"].ToString(); string TonKho = dr["TonKho"].ToString(); string IDDonViTinh = dr["IDDonViTinh"].ToString(); string SoLuongXuat = dr["SoLuongXuat"].ToString(); string MaNguyenLieu = dr["MaNguyenLieu"].ToString(); string DonGia = dr["DonGia"].ToString(); string ThanhTien = dr["ThanhTien"].ToString(); data = new dtPhieuXuatKhac(); data.ThemChiTietPhieuXuatKhac(ID, IDNguyenLieu, TonKho, IDDonViTinh, SoLuongXuat, MaNguyenLieu, DonGia, ThanhTien); //dtLichSuKho.ThemLichSu(Session["IDChiNhanh"].ToString(), IDNguyenLieu, Session["IDNhanVien"].ToString(), dtLichSuKho.LaySoLuongTonKho(Session["IDChiNhanh"].ToString(), IDNguyenLieu), (Int32.Parse(dtLichSuKho.LaySoLuongTonKho(Session["IDChiNhanh"].ToString(), IDNguyenLieu)) - Int32.Parse(SoLuongXuat)) + "", "Phiếu xuất khác"); dtSetting.TruTonKho(IDNguyenLieu, SoLuongXuat, IDChiNhanh); } data = new dtPhieuXuatKhac(); data.XoaChiTietPhieuXuatKhac_Temp(IDPhieuXuatKhac); dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Phiếu xuất khác", "Thêm phiếu xuất khác"); Response.Redirect("DanhSachPhieuXuatKhac.aspx"); } } else { cmbHangHoa.Focus(); Response.Write("<script language='JavaScript'> alert('Danh sách hàng hóa rỗng.'); </script>"); } } else { cmbLyDoXuat.Focus(); Response.Write("<script language='JavaScript'> alert('Vui lòng chọn lý do để xuất.'); </script>"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { data = new dtPhieuXuatKhac(); object IDPhieuXuatKhac = data.ThemPhieuXuatKhac_Temp(); IDPhieuXuatKhac_Temp.Value = IDPhieuXuatKhac.ToString(); cmbChiNhanh.Text = Session["IDChiNhanh"].ToString(); txtNguoiLapPhieu.Text = Session["TenDangNhap"].ToString(); } LoadGrid(IDPhieuXuatKhac_Temp.Value.ToString()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { dtPhieuXuatKhac dt = new dtPhieuXuatKhac(); DataTable da = dt.LayLyDoXuat(); da.Rows.Add(-1, "Tất cả"); cmbLyDoXuat.DataSource = da; cmbLyDoXuat.TextField = "TenTrangThai"; cmbLyDoXuat.ValueField = "ID"; cmbLyDoXuat.DataBind(); cmbLyDoXuat.SelectedIndex = da.Rows.Count; } }
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>"); } }
private void LoadGrid() { data = new dtPhieuXuatKhac(); gridPhieuXuatKhac.DataSource = data.DanhSachPhieuXuatKhac(); gridPhieuXuatKhac.DataBind(); }
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>"); } }
private void LoadGrid(string IDPhieuXuatKhac) { data = new dtPhieuXuatKhac(); gridDanhSachHangHoa_Temp.DataSource = data.LayDanhSachPhieuXuatKhac(IDPhieuXuatKhac); gridDanhSachHangHoa_Temp.DataBind(); }
private void LoadGrid(string IDPhieuXuatKhac) { data = new dtPhieuXuatKhac(); gridChiTietPhieuXuatKhac.DataSource = data.DanhSachChiTietPhieuXuatKhac_ID(IDPhieuXuatKhac); gridChiTietPhieuXuatKhac.DataBind(); }