Ejemplo n.º 1
0
        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>");
            }
        }
Ejemplo n.º 2
0
 private void LoadGrid(string IDPhieuXuatKhac)
 {
     data = new dtPhieuXuatKhac();
     gridDanhSachHangHoa.DataSource = data.LayDanhSachPhieuXuatKhac_Temp(IDPhieuXuatKhac);
     gridDanhSachHangHoa.DataBind();
 }