Esempio n. 1
0
        /// <summary>
        /// GetTheGT
        /// </summary>
        /// <param name="barCode"></param>
        /// <param name="congTy"></param>
        /// <returns></returns>
        public MaVachThe[] GetTheGt(Barcode[] barCode, ThongTinCongTy congTy)
        {
            List <MaVachThe> retVal = null;

            try
            {
                retVal = new List <MaVachThe>();
                cl     = new Server_Client.Client();
                // gán TCPclient
                client = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo
                TheGiamGia pt = new TheGiamGia {
                    HanhDong = "Select"
                };
                clientstrem = cl.SerializeObj(client, "TheGiamGia", pt);
                TheGiamGia[] tggArr = new TheGiamGia[1];
                // đổ mảng đối tượng vào datagripview
                tggArr = (TheGiamGia[])cl.DeserializeHepper1(clientstrem, tggArr);
                //
                foreach (Barcode code in barCode)
                {
                    foreach (TheGiamGia item in tggArr)
                    {
                        if (code.MaHangHoa.Trim().ToUpper().Equals(item.MaTheGiamGia.Trim().ToUpper()))
                        {
                            MaVachThe mavach = new MaVachThe
                            {
                                TenCongTy   = congTy.TenCongTy + "\r\n" + congTy.DiaChi,
                                TenThe      = "Thẻ Giá Trị",
                                MaKH        = item.MaKhachHang,
                                TenKH       = code.TenHangHoa,
                                NgayBatDau  = item.NgayBatDau.ToShortDateString(),
                                NgayKetThuc = item.NgayKetThuc.ToShortDateString(),
                                MaVach      = code.MaVach,
                                MaThe       = item.MaTheGiamGia,
                                GiaTriThe   = double.Parse(item.GiaTriThe)
                            };
                            retVal.Add(mavach);
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
                retVal = null;
            }

            return(retVal.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// GetTheVip
        /// </summary>
        /// <param name="barCode"></param>
        /// <param name="thongTinCongTy"></param>
        /// <returns></returns>
        public MaVachThe[] GetTheVip(Barcode[] barCode, ThongTinCongTy thongTinCongTy)
        {
            List <MaVachThe> retVal;

            try
            {
                retVal = new List <MaVachThe>();
                cl     = new Server_Client.Client();
                // gán TCPclient
                client = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo
                //Entities.TheVip kh = new Entities.TheVip("Select", txtmkh.Text);
                clientstrem = cl.SerializeObj(client, "LayTheVip", null);
                // đổ mảng đối tượng vào datagripview
                TheVip[] theVip = (TheVip[])cl.DeserializeHepper1(clientstrem, null);
                //
                foreach (Barcode code in barCode)
                {
                    foreach (TheVip item in theVip)
                    {
                        if (!code.MaHangHoa.Trim().ToUpper().Equals(item.MaThe.Trim().ToUpper()))
                        {
                            continue;
                        }
                        MaVachThe maVachThe = new MaVachThe
                        {
                            TenCongTy   = thongTinCongTy.TenCongTy + "\r\n" + thongTinCongTy.DiaChi,
                            TenThe      = "Thẻ Vip",
                            MaKH        = item.MaKhachHang,
                            TenKH       = code.TenHangHoa,
                            NgayBatDau  = new DateTime().ToShortDateString(),
                            NgayKetThuc = new DateTime().ToShortDateString(),
                            MaVach      = code.MaVach,
                            MaThe       = item.MaThe,
                            GiaTriThe   = double.Parse(item.GiaTriThe)
                        };
                        retVal.Add(maVachThe);
                        break;
                    }
                }
            }
            catch (Exception)
            {
                retVal = null;
            }

            return(retVal.ToArray());
        }