Exemplo n.º 1
0
        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
            {
            }
        }
        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;
        }