Exemplo n.º 1
0
 public ReportViewInvoice(int id)
 {
     InitializeComponent();
     DataAccess da = new DataAccess();
     InvoiceId = id;
     Outgo = da.InvoiceGet(id);
 }
Exemplo n.º 2
0
 public SpareOutgoEditView(invoice _inv)
 {
     da = new DataAccess();
     InitializeComponent();
     edtNumber.Text = da.SpareOutgoGetMaxId().ToString();
     Invoice = da.InvoiceGet(_inv.id);
 }
Exemplo n.º 3
0
 // загрузка Item из БД, заполнение полей =====================
 private void ItemToForm(int ItemID)
 {
     //.1
     Item = da.InvoiceGet(ItemID);
     if (Item.account == null)
         Item.accountReference.Load();
     if (Item.account != null)
         edtAccount.SelectedValue = Item.account.id;
     edtAccountAddress.Text = Item.AccountAddress;
     edtAccountBankMFO.Text = Item.AccountBankMFO;
     edtAccountBankName.Text = Item.AccountBankName;
     edtBankAccount.SelectedValue = Item.BankAccountID;
     edtAccountUNN.Text = Item.AccountUNN;
     if (Item.InvoiceDate.HasValue)
         edtDate.SelectedDate = Item.InvoiceDate.Value;
     edtNumber.Text = Item.InvoiceNumber.ToString();
     edtSum.Content = Item.InvoiceSum.ToString();
 }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
        private void CreateOutgoByInvoice()
        {
            da = new DataAccess();
            this.Item = FormToItem();
            bool WarningFlag = false;
            List<SpareInInvoiceView> items = da.GetSparesByInvoiceID(Item.id);
            foreach (SpareInInvoiceView siiv in items)
            {
                if (!siiv.IncomeID.HasValue)
                {
                    WarningFlag = true;
                }
            }
            if (WarningFlag)
            {
                MessageBox.Show("Вероятно, данный счет-фактура создан в предыдущей версии программы, поэтому не все товары могут быть перенесены в новую накладную.");
            }
            SpareOutgoEditView v = new SpareOutgoEditView(this.Item);
            v.ShowDialog();

            //Close();
        }
Exemplo n.º 6
0
 // Создать инвойс
 private void CreateInvoice()
 {
     DeleteNew = true;
     Item = new invoice();
     Item = da.InvoiceCreate(Item);
     edtNumber.Text = Item.InvoiceNumber.ToString();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the invoices EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToinvoices(invoice invoice)
 {
     base.AddObject("invoices", invoice);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Create a new invoice object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 public static invoice Createinvoice(global::System.Int32 id)
 {
     invoice invoice = new invoice();
     invoice.id = id;
     return invoice;
 }
Exemplo n.º 9
0
        public void InvoiceEdit(invoice item, int AccountID)
        {
            objDataContext = new DriveEntities();
            invoice original = objDataContext.invoices.FirstOrDefault(b => b.id == item.id);
            if (original != null)
            {
                original.InvoiceDate = item.InvoiceDate;
                original.InvoiceSum = item.InvoiceSum;
                original.AccountBankName = item.AccountBankName;
                original.BankAccountID = item.BankAccountID;

                //original.AccountName = item.AccountName;
                original.AccountUNN = item.AccountUNN;
                original.AccountAddress = item.AccountAddress;
                original.AccountBankMFO = item.AccountBankMFO;
                original.InvoiceNumber = item.InvoiceNumber;

                //original.account = item.account;
                if (AccountID > 0)
                {
                    original.account = objDataContext.accounts.FirstOrDefault(i => i.id == AccountID);
                    original.AccountName = original.account.name;
                }

                //original.base_doc = item.base_doc;
                //original.base_doc_date = item.base_doc_date;
                //original.currency = objDataContext.currencies.FirstOrDefault(i => i.code == CurrencyCode);
                //original.si_date = item.si_date;
                //original.warehouse = objDataContext.warehouses.FirstOrDefault(i => i.name == WarehouseName);
                //original.cashless = item.cashless;
                objDataContext.SaveChanges();
            }
        }
Exemplo n.º 10
0
        public invoice InvoiceCreate(invoice _obj)
        {
            objDataContext = new DriveEntities();
            if (objDataContext.invoices.Count() > 0)
                _obj.InvoiceNumber = objDataContext.invoices.Max(x => x.InvoiceNumber) + 1;
            else
                _obj.InvoiceNumber = 1;
            objDataContext.AddToinvoices(_obj);
            objDataContext.SaveChanges();

            //_obj.InvoiceNumber = _obj.id;
            return _obj;
        }