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();
            }
        }
Example #2
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);
                }
            }
        }