Esempio n. 1
0
 private void onLostFocusEvent(object param)
 {
     StringNotify = "";
     if (!string.IsNullOrEmpty(Barcode) && Barcode.Trim().ToString() != "")
     {
         DataTable _gift = (param != null) ? param as DataTable : GiftCardModel.getGiftCardByBarcode(Barcode.Trim());
         if (_gift.Rows.Count == 0)
         {
             StringNotify = App.Current.FindResource("giftcard_not_existing").ToString();
             GiftBalance  = "";
             GiftSerial   = "";
             UseValue     = "";
             //OnFocusRequested(nameof(Barcode));
         }
         else
         {
             Int32 unixTimestamp = getCurrentUnixTime();
             Int32 _expreTime    = Convert.ToInt32(_gift.Rows[0]["ExpirationDate"]);
             if (unixTimestamp > _expreTime)
             {
                 StringNotify = App.Current.FindResource("giftcard_expired").ToString();
                 GiftBalance  = "";
                 GiftSerial   = "";
                 UseValue     = "";
                 //OnFocusRequested(nameof(Barcode));
             }
             else if (Convert.ToDouble(_gift.Rows[0]["Balance"]) <= 0)
             {
                 StringNotify = App.Current.FindResource("giftcard_in_used").ToString();
                 GiftBalance  = "";
                 GiftSerial   = "";
                 UseValue     = "";
                 //OnFocusRequested(nameof(Barcode));
             }
             else if (Convert.ToInt32(_gift.Rows[0]["GiftCardID"].ToString()) != ScanGiftId)
             {
                 if (allReadyExits(StaticClass.GeneralClass.customerGiftCard, _gift.Rows[0]["GiftCardID"].ToString()))
                 {
                     StringNotify = App.Current.FindResource("acard_isnot_multiple").ToString();
                     GiftBalance  = "";
                     GiftSerial   = "";
                     UseValue     = "";
                 }
                 else
                 {
                     GiftBalance = _gift.Rows[0]["Balance"].ToString();
                     GiftSerial  = _gift.Rows[0]["Serial"].ToString();
                     UseValue    = StaticClass.GeneralClass.GetNumFormatDisplay(Convert.ToDecimal(_gift.Rows[0]["Balance"].ToString()));
                 }
             }
         }
     }
 }
Esempio n. 2
0
 private void onStarScanGiftCadrEvent(string param)
 {
     if (string.IsNullOrEmpty(Barcode) || Barcode.Trim().ToString() == "")
     {
         Barcode      = "";
         StringNotify = App.Current.FindResource("barcode_null").ToString();
         OnFocusRequested(nameof(Barcode));
     }
     else if (Barcode.Trim() == "0")
     {
         ShellOutViewModel.eventFillValueGiftCard("0:0", null);
         //ShellOutViewModel.eventResetListboxSelected(null, null);
         OnFocusRequested(nameof(Barcode));
         OnRequestClose();
     }
     else
     {
         DataTable _gift = GiftCardModel.getGiftCardByBarcode(Barcode.Trim());
         if (_gift.Rows.Count == 0)
         {
             StringNotify = App.Current.FindResource("giftcard_not_existing").ToString();
         }
         else
         {
             bool  _isError      = false;
             Int32 unixTimestamp = getCurrentUnixTime();
             Int32 _expreTime    = Convert.ToInt32(_gift.Rows[0]["ExpirationDate"]);
             if (unixTimestamp > _expreTime)
             {
                 StringNotify = App.Current.FindResource("giftcard_expired").ToString();
                 OnFocusRequested(nameof(Barcode));
                 _isError = true;
             }
             else if (Convert.ToDouble(_gift.Rows[0]["Balance"]) <= 0)
             {
                 StringNotify = App.Current.FindResource("giftcard_in_used").ToString();
                 OnFocusRequested(nameof(Barcode));
                 _isError = true;
             }
             else if (Convert.ToInt32(_gift.Rows[0]["GiftCardID"].ToString()) != ScanGiftId)
             {
                 if (allReadyExits(StaticClass.GeneralClass.customerGiftCard, _gift.Rows[0]["GiftCardID"].ToString()))
                 {
                     StringNotify = App.Current.FindResource("acard_isnot_multiple").ToString();
                     OnFocusRequested(nameof(Barcode));
                     _isError = true;
                 }
             }
             else if (!_isError && StaticClass.GeneralClass.ConverStringToDecimal(UseValue) <= 0)
             {
                 StringNotify = App.Current.FindResource("enter_amount_want").ToString();
                 OnFocusRequested(nameof(UseValue));
                 _isError = true;
             }
             else if (!_isError && Convert.ToDecimal(_gift.Rows[0]["Balance"]) < StaticClass.GeneralClass.ConverStringToDecimal(UseValue))
             {
                 StringNotify = App.Current.FindResource("value_invalid").ToString();
                 OnFocusRequested(nameof(UseValue));
                 _isError = true;
             }
             if (!_isError)
             {
                 if (Convert.ToInt32(_gift.Rows[0]["GiftCardID"].ToString()) != ScanGiftId)
                 {
                     StaticClass.GeneralClass.customerGiftCard.Remove(ScanGiftId);
                     StaticClass.GeneralClass.customerGiftCard.Add(Convert.ToInt32(_gift.Rows[0]["GiftCardID"].ToString()));
                 }
                 ShellOutViewModel.eventFillValueGiftCard(_gift.Rows[0]["GiftCardID"].ToString() + ":" + UseValue, null);
                 //ShellOutViewModel.eventResetListboxSelected(null, null);
                 OnRequestClose();
             }
         }
     }
 }