Esempio n. 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (this.transactorsDataGrid.SelectedRows.Count == 1)
            {
                XDocument xmlDocument = XDocument.Load(TransactorsFilePath);
                IEnumerable <XElement> transactors = xmlDocument.Element(XmlRoot)
                                                     .Elements(XmlElement);

                DataGridViewSelectedRowCollection selectedRows = this.transactorsDataGrid.SelectedRows;
                string no = selectedRows[0].Cells[TableColumn.No].Value.ToString();

                XElement transactor = null;

                if (!this.btnDebtors.Enabled)
                {
                    // The user has the Debtors button as the selected button.
                    transactor = transactors.Where(x => x.Attribute("no").Value == no &&
                                                   x.Element("TransactorType").Value == "Debtor")
                                 .FirstOrDefault();
                }
                else if (!this.btnCreditors.Enabled)
                {
                    // The user has the Creditors button as the selected button.
                    transactor = transactors.Where(x => x.Attribute("no").Value == no &&
                                                   x.Element("TransactorType").Value == "Creditor")
                                 .FirstOrDefault();
                }

                IEnumerable <Currency> currencies = GetCurrencies();
                Currency currency = currencies.Where(x => x.Abbreviation == transactor.Element("CurrencyAbbreviation").Value).First();

                EditTransactorForm editTransactorForm = new EditTransactorForm(
                    this,
                    int.Parse(transactor.Attribute("no").Value),
                    transactor.Element("Name").Value,
                    transactor.Element("Since").Value,
                    transactor.Element("DueDate").Value,
                    transactor.Element("PhoneNumber").Value,
                    transactor.Element("Email").Value,
                    transactor.Element("Facebook").Value,
                    decimal.Parse(transactor.Element("Amount").Value),
                    currency,
                    transactor.Element("TransactorType").Value);

                editTransactorForm.Show();
                this.Enabled = false;
                editTransactorForm.FormClosed += new FormClosedEventHandler(FormClosedAction);
            }
            else
            {
                MessageBox.Show(ErrorMessage.EditOverOneSelectedRecords,
                                MessageBoxCaption.Error,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                return;
            }
        }
Esempio n. 2
0
        private void detailsBtnEdit_Click(object sender, EventArgs e)
        {
            Currency currencySymbolObj = new Currency();

            currencySymbolObj.Abbreviation = currencyAbbreviation;

            switch (currencyAbbreviation)
            {
            case "BGN": currencySymbolObj.Id = "01"; break;

            case "EUR": currencySymbolObj.Id = "02"; break;

            case "USD": currencySymbolObj.Id = "03"; break;

            case "GBP": currencySymbolObj.Id = "04"; break;

            case "PLN": currencySymbolObj.Id = "05"; break;

            case "RON": currencySymbolObj.Id = "06"; break;

            case "TRY": currencySymbolObj.Id = "07"; break;

            case "RUB": currencySymbolObj.Id = "08"; break;

            case "CZK": currencySymbolObj.Id = "09"; break;

            case "NOK": currencySymbolObj.Id = "10"; break;

            case "SEK": currencySymbolObj.Id = "11"; break;

            case "CAD": currencySymbolObj.Id = "12"; break;

            case "CHF": currencySymbolObj.Id = "13"; break;
            }

            EditTransactorForm editTransactorForm = new EditTransactorForm(
                this.mainForm,
                this.no,
                this.name,
                this.since,
                this.dueDate,
                this.phoneNumber,
                this.email,
                this.facebook,
                this.amount,
                currencySymbolObj,
                this.transactorType);

            editTransactorForm.Show();
            this.Close();
        }