Пример #1
0
        private async void btnTsbConnect_Click(object sender, RoutedEventArgs e)
        {
            tsb.printCommandInProgress();
            if (btnTsbConnect.Content == "Disconnect")
            {
                setUI(uiSetTo.SerialConnectToTsb);
                await reset();

                btnTsbConnect.Content = "Connect to TSB";
                tsb = new TSB();
                // Initialize the TSB object.  This is necessary to start SerialDeviceWatcher.
                tsb.init(serialPorts, mainDisplayScroll, rtbMainDisplay, theOneParagraph, pbSys, serialBuffer, txbOpenFilePath);
            }
            else
            {
                btnConnect.IsEnabled = false;
                await reset();

                try
                {
                    tsb.hello();
                }
                catch (Exception ex)
                {
                    //await serialPorts.disposeStream();
                    Debug.WriteLine(ex.Message);
                }
            }
        }
            public NRestResult <TSBCreditTransaction> GetInitialTSBCreditTransaction(TSB value)
            {
                NRestResult <TSBCreditTransaction> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <TSBCreditTransaction>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <TSBCreditTransaction>(
                        RouteConsts.Credit.GetInitialTSBCreditTransaction.Url, value);
                }
                else
                {
                    ret = new NRestResult <TSBCreditTransaction>();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
        public void RefreshPlazaInfo()
        {
            _tsb = ops.TSB.GetCurrent().Value();
            var tsbCredit = ops.Credits.GetTSBBalance(_tsb).Value();

            if (null != tsbCredit)
            {
                tsbCredit.Description = "เงินยืมทอนหมุนเวียนด่าน";
                tsbCredit.HasRemark   = false;
            }
            creditEntry.IsEnabled   = false;
            creditEntry.DataContext = tsbCredit;

            var tsbCoupon = ops.Coupons.GetTSBBalance(_tsb).Value();

            if (null != tsbCoupon)
            {
                tsbCoupon.Description = "คุปอง";
                tsbCoupon.HasRemark   = false;
            }
            couponEntry.IsEnabled   = false;
            couponEntry.DataContext = tsbCoupon;

            loanMoneyEntry.IsEnabled   = false;
            loanMoneyEntry.DataContext = tsbCredit;

            if (tsbCredit != null)
            {
                txtMsg.Text = tsbCredit.BHTTotal.ToString("#,##0");
            }
            else
            {
                txtMsg.Text = "0";
            }
        }
Пример #4
0
            public List <Lane> GetTSBLanes(TSB tsb)
            {
                var ret = NRestClient.Create(port: 9000).Execute <List <Lane> >(
                    RouteConsts.TSB.GetTSBLanes.Url, tsb);

                return(ret);
            }
            public NRestResult <TSBCouponBalance> GetTSBBalance(TSB value)
            {
                NRestResult <TSBCouponBalance> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <TSBCouponBalance>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <TSBCouponBalance>(
                        RouteConsts.Coupon.GetTSBBalance.Url, value);
                }
                else
                {
                    ret = new NRestResult <TSBCouponBalance>();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
            public NRestResult <List <TSBCouponSummary> > GetTSBCouponSummaries(TSB value)
            {
                NRestResult <List <TSBCouponSummary> > ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <List <TSBCouponSummary> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <List <TSBCouponSummary> >(
                        RouteConsts.Coupon.GetTSBCouponSummaries.Url, value);
                }
                else
                {
                    ret = new NRestResult <List <TSBCouponSummary> >();
                    ret.ParameterIsNull();
                    ret.data = new List <TSBCouponSummary>();
                }
                return(ret);
            }
Пример #7
0
        private void RefreshUserCredits()
        {
            _tsb = ops.TSB.GetCurrent().Value();
            var userCredits = ops.Credits.GetActiveUserCreditBalances(_tsb).Value();

            listView.ItemsSource = userCredits;
        }
        public void Setup(TSB tsb, UserCreditBalance credit)
        {
            manager.Setup(tsb, credit);

            if (manager.UserBalance.UserCreditId == 0)
            {
                panelSearch.Visibility = Visibility.Visible;
            }
            else
            {
                panelSearch.Visibility = Visibility.Collapsed;
            }

            LoadPlazaGroups();

            this.DataContext = manager.UserBalance;

            manager.UserBalance.Description = "ยอดยืมปัจจุบัน";
            manager.UserBalance.HasRemark   = false;

            manager.Transaction.Description = "ยืมเงิน";

            manager.ResultBalance.Description = "ยอดด่านคงเหลือ";
            manager.ResultBalance.HasRemark   = false;

            srcEntry.DataContext = manager.UserBalance;
            usrEntry.DataContext = manager.Transaction;
            sumEntry.DataContext = manager.ResultBalance;
        }
Пример #9
0
        public void LoadItems()
        {
            if (null == _manager && null == entry)
            {
                return;
            }

            this.listView.ItemsSource = null;
            if (null == _tsb)
            {
                _tsb = ops.TSB.GetCurrent().Value();
            }
            var sortList = RevenueEntryManager.GetEMVList(_tsb, _manager, entry);

            if (null != sortList && sortList.Count > 0)
            {
                rowCnt = sortList.Count;
                amtVal = decimal.Zero;
                sortList.ForEach(item =>
                {
                    amtVal += (item.amount.HasValue) ? item.amount.Value : decimal.Zero;
                });
            }
            else
            {
                rowCnt = 0;
                amtVal = decimal.Zero;
            }
            this.listView.ItemsSource = sortList;
            UpdateSummary();
        }
 public static List <Lane> GetLanes(this TSB value)
 {
     if (null == value)
     {
         return(new List <Lane>());
     }
     return(Lane.GetTSBLanes(value));
 }
 public static List <Plaza> GetPlazas(this TSB value)
 {
     if (null == value)
     {
         return(new List <Plaza>());
     }
     return(Plaza.GetTSBPlazas(value));
 }
Пример #12
0
 public void SetActive([FromBody] TSB value)
 {
     if (null == value)
     {
         return;
     }
     value.SetActive();
 }
 public static void SetActive(this TSB value)
 {
     if (null == value)
     {
         return;
     }
     TSB.SetActive(value.TSBId);
 }
Пример #14
0
 private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvData.SelectedRows.Count == 1)
     {
         TSB model = (TSB)dgvData.SelectedRows[0].DataBoundItem;
         ISBN = model.BKISBN;
     }
 }
Пример #15
0
        private async void btnReset_Click(object sender, RoutedEventArgs e)
        {
            tsb = new TSB();
            // Initialize the TSB object.  This is necessary to start SerialDeviceWatcher.
            tsb.init(serialPorts, mainDisplayScroll, rtbMainDisplay, theOneParagraph, pbSys, serialBuffer, txbOpenFilePath);

            await reset();

            tsbStatusUpdate(TSB.statuses.bootloaderDisconnected, null);
        }
        private void RefreshCoupon(TSB tsb)
        {
            lvCoupon.ItemsSource = null;

            if (null != tsb)
            {
                var coupons = ops.Coupons.GetTSBCouponTransactions(tsb).Value();
                lvCoupon.ItemsSource = coupons;
            }
        }
Пример #17
0
        public List <Plaza> GetTSBPlazas([FromBody] TSB value)
        {
            if (null == value)
            {
                return(new List <Plaza>());
            }
            var results = value.GetPlazas();

            return(results);
        }
Пример #18
0
        public List <Lane> GetTSBLanes([FromBody] TSB value)
        {
            if (null == value)
            {
                return(new List <Lane>());
            }
            var results = value.GetLanes();

            return(results);
        }
Пример #19
0
 public void Setup(User user)
 {
     //_user = user;
     _tsb = ops.TSB.GetCurrent().Value();
     if (null != _tsb)
     {
         dtEntryDate.SelectedDate = DateTime.Now.Date;
         grid.Setup(); // setup null list.
     }
 }
Пример #20
0
            public TSB GetCurrent()
            {
                TSB      ret = _current;
                TimeSpan ts  = DateTime.Now - LastUpdated;

                if (ts.TotalMinutes >= 1)
                {
                    _current = NRestClient.Create(port: 9000).Execute <TSB>(
                        RouteConsts.TSB.GetCurrent.Url, new { });

                    LastUpdated = DateTime.Now;
                }
                return(_current);
            }
        private void RefreshPlazaInfo()
        {
            _tsb = ops.TSB.GetCurrent().Value();
            var tsbCredit = ops.Credits.GetTSBBalance(_tsb).Value();

            this.DataContext      = tsbCredit;
            tsbCredit.Description = "เงินยืมทอน";
            tsbCredit.HasRemark   = false;
            plaza.IsEnabled       = false;
            plaza.DataContext     = tsbCredit;

            loanEntry.IsEnabled   = false;
            loanEntry.DataContext = tsbCredit;
        }
Пример #22
0
        public NDbResult SetActive([FromBody] TSB value)
        {
            NDbResult result;

            if (null == value)
            {
                result = new NDbResult();
                result.ParameterIsNull();
            }
            else
            {
                result = TSB.SetActive(value.TSBId);
                if (!result.errors.hasError)
                {
                    var plaza = ConfigManager.Instance.Plaza;
                    if (null != plaza)
                    {
                        var taApp  = plaza.TAApp;
                        var todApp = plaza.TODApp;
                        if (null != taApp && null != taApp.Http)
                        {
                            var http = taApp.Http;
                            NRestClient.WebProtocol protocol = (http.Protocol == "http") ?
                                                               NRestClient.WebProtocol.http : NRestClient.WebProtocol.https;
                            string hostName = http.HostName;
                            int    portNo   = http.PortNumber;
                            var    client   = new NRestClient(protocol, hostName, portNo);
                            if (null != client)
                            {
                                client.Execute2 <NRestResult>(RouteConsts.Notify.ActiveChanged.Url, new { });
                            }
                        }
                        if (null != todApp && null != todApp.Http)
                        {
                            var http = todApp.Http;
                            NRestClient.WebProtocol protocol = (http.Protocol == "http") ?
                                                               NRestClient.WebProtocol.http : NRestClient.WebProtocol.https;
                            string hostName = http.HostName;
                            int    portNo   = http.PortNumber;
                            var    client   = new NRestClient(protocol, hostName, portNo);
                            if (null != client)
                            {
                                client.Execute2 <NRestResult>(RouteConsts.Notify.ActiveChanged.Url, new { });
                            }
                        }
                    }
                }
            }
            return(result);
        }
Пример #23
0
        public NDbResult <TSBCreditTransaction> GetInitialTSBCreditTransaction([FromBody] TSB value)
        {
            NDbResult <TSBCreditTransaction> result;

            if (null == value)
            {
                result = new NDbResult <TSBCreditTransaction>();
                result.ParameterIsNull();
            }
            else
            {
                result = TSBCreditTransaction.GetInitialTransaction(value);
            }
            return(result);
        }
Пример #24
0
        public NDbResult <List <TSBCouponSummary> > GetTSBCouponSummaries([FromBody] TSB value)
        {
            NDbResult <List <TSBCouponSummary> > result;

            if (null == value)
            {
                result = new NDbResult <List <TSBCouponSummary> >();
                result.ParameterIsNull();
            }
            else
            {
                result = TSBCouponSummary.GetTSBCouponSummaries(value);
            }
            return(result);
        }
Пример #25
0
        public NDbResult <TSBCouponBalance> GetTSBBalance([FromBody] TSB value)
        {
            NDbResult <TSBCouponBalance> result;

            if (null == value)
            {
                result = new NDbResult <TSBCouponBalance>();
                result.ParameterIsNull();
            }
            else
            {
                result = TSBCouponBalance.GetTSBBalance(value);
            }
            return(result);
        }
Пример #26
0
        public NDbResult <List <TSBCouponTransaction> > GetTSBCouponTransactions([FromBody] TSB value)
        {
            NDbResult <List <TSBCouponTransaction> > result;

            if (null == value)
            {
                result = new NDbResult <List <TSBCouponTransaction> >();
                result.ParameterIsNull();
            }
            else
            {
                result = TSBCouponTransaction.GetTSBCouponTransactions(value);
            }
            return(result);
        }
Пример #27
0
        public NDbResult <List <PlazaGroup> > GetTSBPlazaGroups([FromBody] TSB value)
        {
            NDbResult <List <PlazaGroup> > result;

            if (null == value)
            {
                result = new NDbResult <List <PlazaGroup> >();
                result.ParameterIsNull();
            }
            else
            {
                result = PlazaGroup.GetTSBPlazaGroups(value);
            }
            return(result);
        }
Пример #28
0
        public NDbResult <List <Lane> > GetTSBLanes([FromBody] TSB value)
        {
            NDbResult <List <Lane> > result;

            if (null == value)
            {
                result = new NDbResult <List <Lane> >();
                result.ParameterIsNull();
            }
            else
            {
                result = Lane.GetTSBLanes(value);
            }
            return(result);
        }
Пример #29
0
        public NDbResult <TSB> SaveTSB([FromBody] TSB value)
        {
            NDbResult <TSB> result;

            if (null == value)
            {
                result = new NDbResult <TSB>();
                result.ParameterIsNull();
            }
            else
            {
                result = TSB.Save(value);
            }
            return(result);
        }
        public void Setup(TSB tsb, UserCreditBalance credit)
        {
            manager.Setup(tsb, credit);
            this.DataContext = manager.UserBalance;

            if (null != manager.UserBalance)
            {
                manager.UserBalance.Description = manager.UserBalance.FullNameTH;
                manager.UserBalance.HasRemark   = false;
                manager.Transaction.Description = "คืนเงิน";
            }

            srcEntry.DataContext = manager.UserBalance;
            usrEntry.DataContext = manager.Transaction;
        }