Exemplo n.º 1
0
        // заполнение Item из полей, сохранение в БД =================
        private invoice FormToItem()
        {
            da = new DataAccess();
            if (Item == null)
                Item = new invoice();
            Item.InvoiceDate = edtDate.SelectedDate.HasValue ? edtDate.SelectedDate.Value : DateTime.Now;
            int AccountID = 0;
            if (edtAccount.SelectedValue != null)
            {
                AccountID = (int)edtAccount.SelectedValue;
            }
            Item.AccountUNN = edtAccountUNN.Text;
            Item.AccountBankName = edtAccountBankName.Text;
            BankAccountView bav = edtBankAccount.SelectedItem as BankAccountView;
            if (bav != null)
            {
                Item.BankAccountID = bav.id;
            }
            Item.AccountAddress = edtAccountAddress.Text;
            Item.AccountBankMFO = edtAccountBankMFO.Text;
            Item.InvoiceSum = (double)InvoiceSum;
            int INum = 0;

            //if(Item.InvoiceNumber.HasValue)
            //INum = Item.InvoiceNumber.Value;
            if (Int32.TryParse(edtNumber.Text, out INum))
                Item.InvoiceNumber = INum;
            da.InvoiceEdit(Item, AccountID);
            return Item;
        }