public void LayHDNhap()
 {
     try
     {
         cl           = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("HDN", "");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         Entities.HoaDonNhap[] HDN = new Entities.HoaDonNhap[0];
         HDN = (Entities.HoaDonNhap[])cl.DeserializeHepper1(clientstrem, HDN);
         if (HDN == null)
         {
             HoaDonNhap = new Entities.HoaDonNhap[0];
             return;
         }
         int count = 0;
         for (int i = 0; i < HDN.Length; i++)
         {
             DateTime ngaylap = HDN[i].NgayNhap;
             if (ngaylap >= BatDau && ngaylap <= KetThuc)
             {
                 count++;
             }
         }
         Entities.HoaDonNhap[] HoaDonNhap1 = new Entities.HoaDonNhap[count];
         count = 0;
         for (int i = 0; i < HDN.Length; i++)
         {
             DateTime ngaylap = HDN[i].NgayNhap;
             if (ngaylap >= BatDau && ngaylap <= KetThuc)
             {
                 HoaDonNhap1[count] = HDN[i];
                 count++;
             }
         }
         if (HoaDonNhap1.Length == 0)
         {
             HoaDonNhap = new Entities.HoaDonNhap[0];
             return;
         }
         else
         {
             HoaDonNhap = HoaDonNhap1;
         }
     }
     catch { }
 }
 public void ChiTietGoiHang()
 {
     try
     {
         cl           = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("CTGH");
         clientstrem    = cl.SerializeObj(this.client1, "Select", ctxh);
         chitietgoihang = (Entities.ChiTietGoiHang[])cl.DeserializeHepper1(clientstrem, chitietgoihang);
         if (chitietgoihang == null)
         {
             chitietgoihang = new Entities.ChiTietGoiHang[0];
             return;
         }
     }
     catch { }
 }
 public void LayChiTietHoaDonNhap()
 {
     ctHDN        = new Entities.ChiTietHoaDonNhap[0];
     cl           = new Server_Client.Client();
     this.client1 = cl.Connect(Luu.IP, Luu.Ports);
     Entities.CheckRefer ctxh = new Entities.CheckRefer("CTHDN", "");
     clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
     Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[0];
     ctHDN1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, ctHDN1);
     if (ctHDN1 == null)
     {
         return;
     }
     else
     {
         ctHDN = ctHDN1;
     }
 }
        public void ChiTietGoiHang()
        {
            try
            {
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.CheckRefer ctxh = new Entities.CheckRefer("CTGH");
                clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
                chitietgoihang = (Entities.ChiTietGoiHang[])cl.DeserializeHepper1(clientstrem, chitietgoihang);
                if (chitietgoihang == null)
                {
                    chitietgoihang = new Entities.ChiTietGoiHang[0];
                    return;
                }
            }
            catch
            {

            }
        }
        public void LayCTKHTL()
        {
            try
            {
                cl           = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.CheckRefer ctxh = new Entities.CheckRefer("CTKHTL");
                clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
                Entities.ChiTietKhachHangTraLai[] HDN = new Entities.ChiTietKhachHangTraLai[0];
                HDN = (Entities.ChiTietKhachHangTraLai[])cl.DeserializeHepper1(clientstrem, HDN);
                if (HDN == null)
                {
                    CTKHTL = new Entities.ChiTietKhachHangTraLai[0];
                    return;
                }

                CTKHTL = HDN;
            }
            catch
            {
            }
        }
        public void KhoiTao()
        {
            try
            {
                Server_Client.Client client = new Server_Client.Client();
                Client1 = client.Connect(Luu.IP, Luu.Ports);
                CheckRefer ctxh = new CheckRefer("BanBuon");
                Clientstrem = client.SerializeObj(Client1, "Select", ctxh);
                selectall = (SelectAll)client.DeserializeHepper(Clientstrem, selectall);
                // gói hàng
                _goihang = selectall.GoiHang;
                // chi tiết gói hàng
                _chitietgoihang = selectall.ChiTietGoiHang;
                // quy đổi đơn vị tính
                _quidoidvt = selectall.QuyDoiDonViTinh;

                // lay hang hoa the kho
                client = new Server_Client.Client();
                // gán TCPclient
                Client1 = client.Connect(Luu.IP, Luu.Ports);
                client = new Server_Client.Client();

                TruyenGiaTri khoHang = (TruyenGiaTri)cbbkhohang.SelectedItem;
                string makho = khoHang.Giatritruyen;
                HangHoa kh = new HangHoa("SelectTheoKho", makho);
                Clientstrem = client.SerializeObj(Client1, "HangHoa", kh);
                HangHoa[] hhArr = new HangHoa[1];
                hhArr = (HangHoa[])client.DeserializeHepper1(Clientstrem, hhArr);

                if (hhArr == null)
                    _hangHoaTheoKho = new HangHoa[0];

                if (hhArr.Length <= 0) return;

                List<HangHoa> array = hhArr.ToList();

                HangHoa[] save = Common.Utilities.CheckGoiHang(hhArr, _goihang, _chitietgoihang);
                if (save != null) array.AddRange(save);

                // lay hang hoa theo kho
                _hangHoaTheoKho = array.ToArray();

                // Lay Thue
                client = new Server_Client.Client();

                Thue thueTemp = new Thue("Select");
                Clientstrem = client.SerializeObj(Client1, "Thue", thueTemp);
                _thue = new Thue[1];
                _thue = (Thue[])client.DeserializeHepper1(Clientstrem, _thue) ?? new Thue[0];
            }
            catch
            {
            }
        }
 public void TraLaiNCC()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("TLNCC");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         tralaincc = (Entities.TraLaiNCC[])cl.DeserializeHepper1(clientstrem, tralaincc);
         if (tralaincc == null)
         {
             tralaincc = new Entities.TraLaiNCC[0];
             return;
         }
     }
     catch
     {
     }
 }
 public void PhieuXuatHuy()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("PXH");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         phieuxuathuy = (Entities.PhieuXuatHuy[])cl.DeserializeHepper1(clientstrem, phieuxuathuy);
         if (phieuxuathuy == null)
         {
             phieuxuathuy = new Entities.PhieuXuatHuy[0];
             return;
         }
     }
     catch
     {
     }
 }
 public void PhieuDieuChuyenKhoNoiBo()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("PDCKNB");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         phieudieuchuyenkhonoibo = (Entities.PhieuDieuChuyenKhoNoiBo[])cl.DeserializeHepper1(clientstrem, phieudieuchuyenkhonoibo);
         if (phieudieuchuyenkhonoibo == null)
         {
             phieudieuchuyenkhonoibo = new Entities.PhieuDieuChuyenKhoNoiBo[0];
             return;
         }
     }
     catch
     {
     }
 }
 public void KhoHang()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("KH");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         khohang = (Entities.KhoHang[])cl.DeserializeHepper1(clientstrem, khohang);
         if (khohang == null)
         {
             khohang = new Entities.KhoHang[0];
             return;
         }
     }
     catch
     {
     }
 }
 public void LayHDNhap()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("HDN", "");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         Entities.HoaDonNhap[] HDN = new Entities.HoaDonNhap[0];
         HDN = (Entities.HoaDonNhap[])cl.DeserializeHepper1(clientstrem, HDN);
         if (HDN == null)
         {
             HoaDonNhap = new Entities.HoaDonNhap[0];
             return;
         }
         int count = 0;
         for (int i = 0; i < HDN.Length; i++)
         {
             DateTime ngaylap = HDN[i].NgayNhap;
             if (ngaylap >= BatDau && ngaylap <= KetThuc)
             {
                 count++;
             }
         }
         Entities.HoaDonNhap[] HoaDonNhap1 = new Entities.HoaDonNhap[count];
         count = 0;
         for (int i = 0; i < HDN.Length; i++)
         {
             DateTime ngaylap = HDN[i].NgayNhap;
             if (ngaylap >= BatDau && ngaylap <= KetThuc)
             {
                 HoaDonNhap1[count] = HDN[i];
                 count++;
             }
         }
         if (HoaDonNhap1.Length == 0)
         {
             HoaDonNhap = new Entities.HoaDonNhap[0];
             return;
         }
         else
             HoaDonNhap = HoaDonNhap1;
     }
     catch { }
 }
 public void HDBanHang1()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("HDBH");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         hdbanhang = (Entities.HDBanHang[])cl.DeserializeHepper1(clientstrem, hdbanhang);
         if (hdbanhang == null)
         {
             hdbanhang = new Entities.HDBanHang[0];
             return;
         }
     }
     catch
     {
     }
 }
 public void HangHoa1()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("HH");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         hanghoa = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, hanghoa);
         if (hanghoa == null)
         {
             hanghoa = new Entities.HangHoa[0];
             return;
         }
     }
     catch
     {
     }
 }
 ///////////////////////////////////////////////////MRK FIX
 List<QuyDoiDonViTinh> Bangquydoidonvitinh()
 {
     // quy đổi đơn vị tính
     Server_Client.Client cl1 = new Server_Client.Client();
     TcpClient client1 = cl1.Connect(Luu.IP, Luu.Ports);
     CheckRefer ctxh = new CheckRefer("QD");
     clientstrem = cl1.SerializeObj(client1, "Select", ctxh);
     QuyDoiDonViTinh[] quidoidvt = new Entities.QuyDoiDonViTinh[0];
     return ((QuyDoiDonViTinh[])cl1.DeserializeHepper1(clientstrem, quidoidvt)).ToList();
 }
 /// <summary>
 /// Lấy dữ liệu bảng quy đổi đơn vị tính
 /// </summary>
 /// <returns></returns>
 List<QuyDoiDonViTinh> GetQuyDoiDonViTinh()
 {
     List<QuyDoiDonViTinh> dsQuyDoiDonViTinh = new List<QuyDoiDonViTinh>();
     try
     {
         // quy đổi đơn vị tính
         Server_Client.Client client2 = new Server_Client.Client();
         TcpClient client1 = client2.Connect(Luu.IP, Luu.Ports);
         CheckRefer ctxh = new CheckRefer("QD");
         clientstrem = client2.SerializeObj(client1, "Select", ctxh);
         QuyDoiDonViTinh[] quidoidvt = new QuyDoiDonViTinh[0];
         dsQuyDoiDonViTinh = ((QuyDoiDonViTinh[])client2.DeserializeHepper1(clientstrem, quidoidvt)).ToList();
     }
     catch { }
     return dsQuyDoiDonViTinh;
 }
 public void QuyDoiDVT()
 {
     // quy đổi đơn vị tính
     cl = new Server_Client.Client();
     this.client1 = cl.Connect(Luu.IP, Luu.Ports);
     Entities.CheckRefer ctxh = new Entities.CheckRefer("QD");
     clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
     this.quidoidvt = new Entities.QuyDoiDonViTinh[0];
     this.quidoidvt = (Entities.QuyDoiDonViTinh[])cl.DeserializeHepper1(clientstrem, this.quidoidvt);
     if (quidoidvt == null)
     {
         quidoidvt = new Entities.QuyDoiDonViTinh[0];
         return;
     }
     List<Entities.QuyDoiDonViTinh> quydoi = new List<Entities.QuyDoiDonViTinh>();
     foreach (Entities.QuyDoiDonViTinh item in quidoidvt)
     {
         if (item.MaHangDuocQuyDoi == txtMaHangHoa.Text)
         {
             quydoi.Add(item);
         }
     }
     dgvHienThi.DataSource = (Entities.QuyDoiDonViTinh[])quydoi.ToArray();
     fix();
 }
 public void LayChiTietHoaDonNhap()
 {
     ctHDN = new Entities.ChiTietHoaDonNhap[0];
     cl = new Server_Client.Client();
     this.client1 = cl.Connect(Luu.IP, Luu.Ports);
     Entities.CheckRefer ctxh = new Entities.CheckRefer("CTHDN", "");
     clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
     Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[0];
     ctHDN1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, ctHDN1);
     if (ctHDN1 == null)
     {
         return;
     }
     else
         ctHDN = ctHDN1;
 }
 public void HoaDonNhap()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("HDN");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         hoadonnhap = (Entities.HoaDonNhap[])cl.DeserializeHepper1(clientstrem, hoadonnhap);
         if (hoadonnhap == null)
         {
             hoadonnhap = new Entities.HoaDonNhap[0];
             return;
         }
     }
     catch
     {
     }
 }
        public void LayCTKHTL()
        {
            try
            {
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.CheckRefer ctxh = new Entities.CheckRefer("CTKHTL");
                clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
                Entities.ChiTietKhachHangTraLai[] HDN = new Entities.ChiTietKhachHangTraLai[0];
                HDN = (Entities.ChiTietKhachHangTraLai[])cl.DeserializeHepper1(clientstrem, HDN);
                if (HDN == null)
                {
                    CTKHTL = new Entities.ChiTietKhachHangTraLai[0];
                    return;
                }

                CTKHTL = HDN;
            }
            catch
            {
            }
        }
 public void KhachHangTraLai()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CheckRefer ctxh = new Entities.CheckRefer("KHTL");
         clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
         khachhangtralai = (Entities.KhachHangTraLai[])cl.DeserializeHepper1(clientstrem, khachhangtralai);
         if (khachhangtralai == null)
         {
             khachhangtralai = new Entities.KhachHangTraLai[0];
             return;
         }
     }
     catch
     {
     }
 }
        void SelectGoiHang()
        {
            cl = new Server_Client.Client();
            this.client1 = cl.Connect(Luu.IP, Luu.Ports);
            Entities.CheckRefer ctxh = new Entities.CheckRefer("frmBCXuatHangTheoTungKho", new Common.Utilities().CaiDatKho("View", "", "").Giatritruyen);
            clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
            selectall = (Entities.SelectAll)cl.DeserializeHepper(clientstrem, selectall);
            // gói hàng
            goihang = selectall.GoiHang;

            // chi tiết gói hàng
            chitietgoihang = selectall.ChiTietGoiHang;
            HangHoa = selectall.HangHoaTheoKho;
        }