private void InitArticles() { _articalLogic = new ArticalLogic(); List <string> _rowForDelete = new List <string>(); articleBindingSource.DataSource = _articalLogic.GetAllArticles(); DGVArticles.AllowUserToAddRows = false; DGVArticles.ReadOnly = true; DGVArticles.AllowUserToDeleteRows = true; DGVArticles.UserDeletingRow += DGVArticles_UserDeletingRow;; DGVArticles.UserDeletedRow += DGVArticles_UserDeletedRow; DGVArticles.Click += Right_Click; }
private void InitNewItem() { _articalLogic = new ArticalLogic(); // tip dokumenta cmbItemType.DisplayMember = "Description"; cmbItemType.DataSource = Enum.GetValues(typeof(Classes.Lib.ItemType)) .Cast <Enum>() .Select(value => new { (Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()), typeof(DescriptionAttribute)) as DescriptionAttribute).Description, v = (int)(Enum.Parse(typeof(Classes.Lib.ItemType), value.ToString())) }) .OrderBy(item => item.v) .ToList(); BindingAttributes(); }
private void InitDocument() { _articalLogic = new ArticalLogic(); _documentLogic = new DocumentLogic(); _warehouseLogic = new WarehouseLogic(); if (FormMode == FormMode.New) { _document = new Document(); _documentLogic.AddDocument(_document); // datum _document.DocumentDateTime = DateTime.Now; _document.PaymentEndDate = DateTime.Now; _document.PaymentDate = DateTime.Now; _document.DocumentType = DocumentTypeID; string documentNumber = ""; string middle = _documentLogic.GetLastNoForDoument(_document.DocumentDateTime.Year, DocumentTypeID) + "-" + DateTime.Now.Year; string end = ""; switch (DocumentTypeID) { case 0: documentNumber = "P"; break; case 1: documentNumber = "O"; break; case 2: _client = _documentForPayment.Client; _document.ClientID = _documentForPayment.ClientID; _document.TotalPrice = _documentForPayment.TotalPrice; documentNumber = "DO"; end = " {" + _documentForPayment.DocumentNo + "}"; // _client = _document.Client; _document.LinkDocumentNo = _documentForPayment.DocumentNo; _document.DocumentType = 2; break; default: break; } documentNumber += "-" + middle + end; _document.DocumentNo = documentNumber;// (DocumentTypeID == 0 ? "P" : "O") + "-" + _documentLogic.GetLastNoForDoument(_document.DocumentDateTime.Year, DocumentTypeID) + "-" + DateTime.Now.Year; } else if (FormMode == FormMode.Modifying || FormMode == FormMode.ReadOnly) { _document = _documentLogic.GetDocument(SelectedDocument.ID); _client = _document.Client; if (FormMode == FormMode.ReadOnly) { SetAllControlsReadOnly(); } } if (_client != null) { BindClientProperties(); } tbTotalWithVAT.DataBindings.Clear(); tbTotalWithVAT.DataBindings.Add("Text", _document, "TotalPrice"); tbDocumentNo.DataBindings.Clear(); tbDocumentNo.DataBindings.Add("Text", _document, "DocumentNo"); tbSpoljniBroj.DataBindings.Clear(); tbSpoljniBroj.DataBindings.Add("Text", _document, "LinkDocumentNo"); dtpCreationDate.DataBindings.Clear(); dtpCreationDate.DataBindings.Add("Value", _document, "DocumentDateTime"); dtpEndDateForPayment.DataBindings.Clear(); dtpEndDateForPayment.DataBindings.Add("Value", _document, "PaymentEndDate"); dtpPaymentDate.DataBindings.Clear(); dtpPaymentDate.DataBindings.Add("Value", _document, "PaymentDate"); // status cmbStatus.DisplayMember = "Description"; cmbStatus.DataSource = Enum.GetValues(typeof(Classes.Lib.StatusEnum)) .Cast <Enum>() .Select(value => new { (Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()), typeof(DescriptionAttribute)) as DescriptionAttribute).Description, v = (int)(Enum.Parse(typeof(Classes.Lib.StatusEnum), value.ToString())) }) .OrderBy(item => item.v) .ToList(); cmbStatus.SelectedIndex = _document.StatusID; // magacini cmbWarehouse.DataSource = _warehouseLogic.GetAllWarehouse(); cmbWarehouse.DisplayMember = "Name"; cmbWarehouse.ValueMember = "WarehouseTypeID"; cmbWarehouse.SelectedIndex = 1; cmbWarehouse.SelectedIndexChanged += CmbWarehouse_ValuseChanged; // tip dokumenta cmbDocumentType.DisplayMember = "Description"; cmbDocumentType.DataSource = Enum.GetValues(typeof(Classes.Lib.DocumentType)) .Cast <Enum>() .Select(value => new { (Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()), typeof(DescriptionAttribute)) as DescriptionAttribute).Description, v = (int)(Enum.Parse(typeof(Classes.Lib.DocumentType), value.ToString())) }) .OrderBy(item => item.v) .ToList(); cmbDocumentType.Enabled = false; cmbDocumentType.SelectedIndex = _document.DocumentType; this.Text = cmbDocumentType.Text; listaArtikla = _articalLogic.GetAllArticlesByWarehouseType(cmbWarehouse.SelectedIndex); documentItemBindingSource.DataSource = _document.DocumentItems; articleBindingSource.DataSource = listaArtikla; documentItemBindingSource.ListChanged += DocumentItemBindingSource_ListChanged; documentItemBindingSource.CurrentChanged += DocumentItemBindingSource_CurrentChanged; DGVReceiptsDespatchsItems.DataError += DGVReceiptsDespatchsItems_DataError; DGVReceiptsDespatchsItems.CellValueChanged += DGVReceiptsDespatchsItems_CellValueChanged; DGVReceiptsDespatchsItems.CellContentClick += DGVReceiptsDespatchsItems_CellContentClick; DGVReceiptsDespatchsItems.CellFormatting += DGVReceiptsDespatchsItems_CellFormatting; if (_document.DocumentType == (int)DocumentType.Payment) { DGVReceiptsDespatchsItems.Enabled = false; tbTotalWithVAT.Text = _document.TotalPrice.ToString("N2"); } else { inload = true; InitUnboundColumns(); inload = false; } DGVReceiptsDespatchsItems.Update(); DGVReceiptsDespatchsItems.Refresh(); }