private void SelectedRow_Click(object sender, EventArgs e) { Int32 rowToDelete = DGVReceiptsDespatchsItems.Rows.GetFirstRow(DataGridViewElementStates.Selected); DGVReceiptsDespatchsItems.Rows.RemoveAt(rowToDelete); DGVReceiptsDespatchsItems.ClearSelection(); }
private void EditRow_Click(object sender, EventArgs e) { if (DGVReceiptsDespatchsItems.SelectedRows.Count == 1) { //frmNewReceiptsDespatchs editClient = new frmNewReceiptsDespatchs(clientForEdit); FrmNewReceiptsDespatchs editClient = new FrmNewReceiptsDespatchs(); editClient.ShowDialog(); DGVReceiptsDespatchsItems.ClearSelection(); } }
private void MyDataGridView_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { var hti = DGVReceiptsDespatchsItems.HitTest(e.X, e.Y); if (hti.RowIndex >= 0) { DGVReceiptsDespatchsItems.ClearSelection(); DGVReceiptsDespatchsItems.Rows[hti.RowIndex].Selected = true; } } }
private void DGVReceiptsDespatchsItems_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (inload) { return; } inload = true; if (DGVReceiptsDespatchsItems.Columns[e.ColumnIndex].Name == "ArticleNoUnbound") { if (DGVReceiptsDespatchsItems.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null || DGVReceiptsDespatchsItems.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "") { // ((DocumentItem)DGVReceiptsDespatchsItems.Rows[e.RowIndex].DataBoundItem).Item = null; //((DocumentItem)DGVReceiptsDespatchsItems.Rows[e.RowIndex].DataBoundItem).ItemID = 0; ((DocumentItem)DGVReceiptsDespatchsItems.Rows[e.RowIndex].DataBoundItem).ArticleNo = null; ((DocumentItem)DGVReceiptsDespatchsItems.Rows[e.RowIndex].DataBoundItem).ItemPrice = 0; } else { Data.Model.Article pronadjen = listaArtikla.FirstOrDefault(x => x.ArticleNo == DGVReceiptsDespatchsItems.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()); if (pronadjen != null) { // ((DocumentItem)DGVReceiptsDespatchsItems.Rows[e.RowIndex].DataBoundItem).Item = (pronadjen); ((DocumentItem)DGVReceiptsDespatchsItems.Rows[e.RowIndex].DataBoundItem).ItemID = (pronadjen.ID); ((DocumentItem)DGVReceiptsDespatchsItems.Rows[e.RowIndex].DataBoundItem).ArticleNo = pronadjen.ArticleNo; ((DocumentItem)DGVReceiptsDespatchsItems.Rows[e.RowIndex].DataBoundItem).ItemPrice = pronadjen.ItemPrice; } else { DGVReceiptsDespatchsItems.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ""; DGVReceiptsDespatchsItems.Refresh(); } } } if (DGVReceiptsDespatchsItems.Columns[e.ColumnIndex].Name == "ArticleNo") { var stavka = ((DocumentItem)DGVReceiptsDespatchsItems.Rows[e.RowIndex].DataBoundItem); Data.Model.Article pronadjen = listaArtikla.FirstOrDefault(x => x.ArticleNo == stavka.ArticleNo); //Article pronadjen = stavka.Item; if (pronadjen != null) { stavka.ItemID = pronadjen.ID; // stavka.Item = (pronadjen); stavka.ArticleNo = pronadjen.ArticleNo; stavka.ItemPrice = pronadjen.ItemPrice; DGVReceiptsDespatchsItems.Rows[e.RowIndex].Cells["ArticleNoUnbound"].Value = pronadjen.ArticleNo; } } inload = false; DGVReceiptsDespatchsItems.Refresh(); }
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(); }
private void FrmReceiptsDespatchs_Shown(object sender, EventArgs e) { DGVReceiptsDespatchsItems.Refresh(); }
private void RefreshDGVSource() { //DGVReceiptsDespatchs.DataSource = _documentLogic.GetAllDocuments(); DGVReceiptsDespatchsItems.RefreshEdit(); }