private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            int cd1Value = 0, cd2Value = 0;

            Int32.TryParse(txtRemaining1.Text, out cd1Value);
            Int32.TryParse(txtRemaining1.Text, out cd2Value);

            if (cd1Value > 0 || cd2Value > 0)
            {
                if (MessageBox.ShowBox("MessageID391", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }

            bool overallResult = true;

            try
            {
                bool result = false;

                CashDispenserItem item = txtCassetteAlias.Tag as CashDispenserItem;

                //Upper Cassette
                item.CassetteAlias = txtCassetteAlias.Text;
                item.Denimination  = Convert.ToInt32(txtDenom.Text);
                item.TotalValue    = txtTotalValue.Text.GetDecimal();
                result             = CashDispenserFactory.UpdateItem(item);

                //Lower Cassette
                item = txtCassetteAlias2.Tag as CashDispenserItem;
                item.CassetteAlias = txtCassetteAlias2.Text;
                item.Denimination  = Convert.ToInt32(txtDenom2.Text);
                item.TotalValue    = txtTotal2.Text.GetDecimal();

                result = CashDispenserFactory.UpdateItem(item);

                overallResult = true;
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
            finally
            {
                if (overallResult)
                {
                    MessageBox.ShowBox("MessageID389", BMC_Icon.Information);
                }
                else
                {
                    MessageBox.ShowBox("MessageID390", BMC_Icon.Information);
                }

                this.LoadItems();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the items.
        /// </summary>
        private void LoadItems()
        {
            LogManager.WriteLog("|=> (LoadItems) : Invoked.", LogManager.enumLogLevel.Info);
            string message = string.Empty;
            uint   iErrorCode;

            try
            {
                using (ICashDispenser dispenser = CashDispenserFactory.GetDispenser())
                {
                    bool isOK = false;
                    try
                    {
                        // GetStatus Calling
                        isOK = (CashDispenserItem.GetStatus(out message, out iErrorCode) == CashDispenserItem.DispenserStatus.Available);
                    }
                    catch (Exception ex)
                    {
                        _errorText = "Unable to connect cash dispenser.";
                        iErrorCode = 1;
                        ExceptionManager.Publish(ex);
                    }

                    // after calling GetStatus
                    _errorText = (isOK ? string.Empty : message);
                    for (int i = 0; i < dispenser.DispenserItems.Count; i++)
                    {
                        CashDispenserItem item = dispenser.DispenserItems[i];

                        if (item.DeckType == CashDispenserItem.TypeOfDeck.Upper)
                        {
                            _upperText.IsOK = Convert.ToInt32(_upperText.StatusText) == 0 ? false: !CashDispenserItem.IsUpperTrayError(iErrorCode);
                        }
                        else
                        {
                            _lowerText.IsOK = Convert.ToInt32(_lowerText.StatusText) == 0 ? false : !CashDispenserItem.IsLowerTrayError(iErrorCode);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _errorText = "Unable to connect cash dispenser.";
                ExceptionManager.Publish(ex);
            }
            finally
            {
                this.Dispatcher.Invoke(new Action(
                                           delegate()
                {
                    this.UpdateTexts();
                }
                                           ));
            }
        }
        /// <summary>
        /// Loads the items.
        /// </summary>
        private void LoadItems()
        {
            try
            {
                using (ICashDispenser dispenser = CashDispenserFactory.GetDispenser())
                {
                    string currencySymbol = ExtensionMethods.GetCurrencySymbol(string.Empty);

                    for (int i = 0; i < dispenser.DispenserItems.Count; i++)
                    {
                        CashDispenserItem item  = dispenser.DispenserItems[i];
                        string            sText = item.CassetteAlias + " : " + currencySymbol + " " + item.Denimination.ToString();

                        if (item.DeckType == CashDispenserItem.TypeOfDeck.Upper)
                        {
                            _upperDenomination = item.Denimination;
                            lblCD1.Text        = sText;
                            string balance = item.TotalValue.ToString();
                            if (string.IsNullOrEmpty(balance))
                            {
                                balance = "0";
                            }
                            lblBalance1.Text = balance;
                            txtCD1.Text      = "";
                            txtCD1.Tag       = item;
                            txtCD1_TextChanged(txtCD1, null);
                        }
                        else
                        {
                            _lowerDenomination = item.Denimination;
                            lblCD2.Text        = sText;
                            string balance = item.TotalValue.ToString();
                            if (string.IsNullOrEmpty(balance))
                            {
                                balance = "0";
                            }
                            lblBalance2.Text = balance;
                            txtCD2.Text      = "";
                            txtCD2.Tag       = item;
                            txtCD2_TextChanged(txtCD2, null);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
        /// <summary>
        /// Loads the items.
        /// </summary>
        private void LoadItems(bool isInit)
        {
            Brush redBrush   = Brushes.Red;
            Brush greenBrush = Brushes.Green;

            try
            {
                using (ICashDispenser dispenser = CashDispenserFactory.GetDispenser())
                {
                    string currencySymbol = ExtensionMethods.GetCurrencySymbol(string.Empty);

                    for (int i = 0; i < dispenser.DispenserItems.Count; i++)
                    {
                        CashDispenserItem item   = dispenser.DispenserItems[i];
                        string            sText  = item.CassetteAlias + " : ";
                        string            sText2 = currencySymbol + " " + item.Denimination.ToString();

                        string message = string.Empty;
                        bool   isOK    = isInit ? false : (item.TestStatus(out message) == CashDispenserItem.DispenserStatus.Available);
                        lblErrorDesc.Text = (isOK ? string.Empty : message);

                        Brush  brush      = isOK ? greenBrush : redBrush;
                        string statusText = string.Empty;

                        if (item.DeckType == CashDispenserItem.TypeOfDeck.Upper)
                        {
                            lblCD1.Text            = sText;
                            lblCD1Calc.Text        = sText2;
                            rcCD1Status.Content    = statusText;
                            rcCD1Status.Background = brush;
                        }
                        else
                        {
                            lblCD2.Text            = sText;
                            lblCD2Calc.Text        = sText2;
                            rcCD2Status.Content    = statusText;
                            rcCD2Status.Background = brush;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
Ejemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool overallResult = true;

            try
            {
                foreach (DataGridViewRow row in dgvItems.Rows)
                {
                    CashDispenserItem item = row.Tag as CashDispenserItem;
                    if (item != null)
                    {
                        int     iValue = 0;
                        Decimal dValue = 0;
                        bool    result = false;

                        item.CassetteAlias = row.Cells[chdrCassetteAlias.Index].Value.ToString();

                        Int32.TryParse(row.Cells[chdrDenomination.Index].Value.ToString(), out iValue);
                        item.Denimination = iValue;

                        Decimal.TryParse(row.Cells[chdrTotalValue.Index].Value.ToString(), out dValue);
                        item.TotalValue = dValue;

                        result         = CashDispenserFactory.UpdateItem(item);
                        overallResult &= result;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (overallResult)
                {
                    MessageBox.Show("All the details are saved successfully.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Unable to save some items.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Loads the items.
        /// </summary>
        public void LoadDBItems()
        {
            if (!CashDispenserWorker.IsVisible)
            {
                return;
            }
            LogManager.WriteLog("|=> (LoadDBItems) : Invoked.", LogManager.enumLogLevel.Info);

            try
            {
                using (ICashDispenser dispenser = CashDispenserFactory.GetDispenser())
                {
                    string currencySymbol = ExtensionMethods.GetCurrencySymbol(string.Empty);

                    // before calling GetStatus
                    for (int i = 0; i < dispenser.DispenserItems.Count; i++)
                    {
                        CashDispenserItem item       = dispenser.DispenserItems[i];
                        string            sText      = item.CassetteAlias + " : ";
                        string            sText2     = currencySymbol + " " + item.Denimination.ToString();
                        string            statusText = item.RemainingValueCalculated.ToString();

                        if (item.DeckType == CashDispenserItem.TypeOfDeck.Upper)
                        {
                            _upperText.Text       = sText;
                            _upperText.Text2      = sText2;
                            _upperText.StatusText = statusText;
                        }
                        else
                        {
                            _lowerText.Text       = sText;
                            _lowerText.Text2      = sText2;
                            _lowerText.StatusText = statusText;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
 private void WriteAuditLog(CashDispenserItem deck, decimal value)
 {
     try
     {
         string auditValue = deck.CassetteAlias + " : " + deck.Denimination + ", " + value.ToString();
         AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
         {
             AuditModuleName    = ModuleName.Cash_Dispenser,
             Audit_Screen_Name  = "Manual Cash Dispense",
             Audit_Desc         = "From Module : " + _parentModuleName.ToString(),
             AuditOperationType = OperationType.ADD,
             Audit_Field        = "Amount",
             Audit_New_Vl       = auditValue,
             Audit_Slot         = string.Empty
         });
     }
     catch (Exception ex)
     {
         ExceptionManager.Publish(ex);
     }
 }
Ejemplo n.º 8
0
 //
 private void WriteAuditLog(CashDispenserItem UpperDeck, CashDispenserItem LowerDeck, decimal UpperCount, decimal LowerCount, string AutoDispense, decimal value)
 {
     try
     {
         string auditValue = UpperDeck.CassetteAlias + " : " + UpperDeck.Denimination + ", " + (UpperCount * UpperDeck.Denimination).ToString();
         auditValue += " | " + LowerDeck.CassetteAlias + " : " + LowerDeck.Denimination + ", " + (LowerCount * LowerDeck.Denimination).ToString();
         auditValue += " | " + AutoDispense + " : " + value.ToString();
         AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
         {
             AuditModuleName    = ModuleName.Cash_Dispenser,
             Audit_Screen_Name  = "Auto Cash Dispense",
             Audit_Desc         = "From Module : " + ModuleName.Cash_Dispenser.ToString(),
             AuditOperationType = OperationType.ADD,
             Audit_Field        = "Amount",
             Audit_New_Vl       = auditValue,
             Audit_Slot         = string.Empty
         });
     }
     catch (Exception ex)
     {
         ExceptionManager.Publish(ex);
     }
 }