Gjoreski | 15.06.2018 11:29 |
---|---|
Predmet:Re: Kako sprečiti dupli unos u DataGrid (dupli proizvod) Nemam ja Visual Basic 2017. Da bi resio tvoj problem treba da uradis probera dali vec si uneo artikal prije unosa novog artikla. To bi uradio na dogadzaj na data gridu koi se zove Befor Update. Eve vidi go ovaj kod bi trebalo da zavrsi rabota. PreuzmiIzvorni kôd (vbnet):
|
xl_kid | 13.06.2018 13:52 |
---|---|
Predmet:Kako sprečiti dupli unos u DataGrid (dupli proizvod) Imam perent formu u kojoj unosim kupca i slične podatke a u child DataGrid su proizvodi i količine. Kako da sprečim unos duplih proizvoda? |
xl_kid | 15.06.2018 10:28 |
---|---|
Predmet:Re: Kako sprečiti dupli unos u DataGrid (dupli proizvod) 1. - visual studio 2017 2. - 3. - bound DataGrid ************** Public Class Form1 Private Sub PorudzbineBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles PorudzbineBindingNavigatorSaveItem.Click Me.Validate() Me.PorudzbineBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.Porudzbine_DataSet) Me.PorudzbineDetaljiTableAdapter.Update(Me.Porudzbine_DataSet) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'Porudzbine_DataSet.PorudzbineDetalji' table. You can move, or remove it, as needed. Me.PorudzbineDetaljiTableAdapter.Fill(Me.Porudzbine_DataSet.PorudzbineDetalji) 'TODO: This line of code loads data into the 'Porudzbine_DataSet.Relacije' table. You can move, or remove it, as needed. Me.RelacijeTableAdapter.Fill(Me.Porudzbine_DataSet.Relacije) 'TODO: This line of code loads data into the 'Porudzbine_DataSet.Kupci' table. You can move, or remove it, as needed. Me.KupciTableAdapter.Fill(Me.Porudzbine_DataSet.Kupci) 'TODO: This line of code loads data into the 'Porudzbine_DataSet.Porudzbine' table. You can move, or remove it, as needed. Me.PorudzbineTableAdapter.Fill(Me.Porudzbine_DataSet.Porudzbine) CustomDataGridView1.Columns(4).DefaultCellStyle.Format = "N2" CustomDataGridView1.Columns(5).DefaultCellStyle.Format = "N2" End Sub Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown If e.KeyCode = Keys.Enter Then Me.SelectNextControl(Me.ActiveControl, True, True, True, False) 'for Select Next Control End If End Sub Private Sub NazivComboBox_LostFocus(sender As Object, e As EventArgs) Handles NazivComboBox.LostFocus Dim naziv_dm As New Porudzbine_DataSetTableAdapters.KupciTableAdapter KupacIDTextBox.Text = naziv_dm.id_dm_ScalarQuery(NazivComboBox.Text) End Sub Private Sub CustomDataGridView1_DataError(sender As Object, e As DataGridViewDataErrorEventArgs) Handles CustomDataGridView1.DataError Dim view As DataGridView = CType(sender, DataGridView) 'view.Rows(e.RowIndex).Cells(e.ColumnIndex).ErrorText = "an error" 'e.ThrowException = False End Sub Private Sub CustomDataGridView1_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles CustomDataGridView1.CellEndEdit 'MessageBox.Show(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString()) Dim proizvod_info As New Porudzbine_DataSetTableAdapters.ProizvodiTableAdapter 'Dim ukupna_tezina As New Porudzbine_DataSetTableAdapters.PorudzbineDetaljiTableAdapter If (e.ColumnIndex = 0) Then If Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) > 0 Then CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value = proizvod_info.naziv_proizvoda_ScalarQuery(CInt(Val(CustomDataGri dView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value))) End If End If Dim UkupnaTezina As DataGridView = DirectCast(sender, DataGridView) UkupnaTezina(5, e.RowIndex).Value = Math.Round(UkupnaTezina(2, e.RowIndex).Value * proizvod_info.TezinaProizvoda_ScalarQuery(UkupnaTezina(0, e.RowIndex).Value) + UkupnaTezina(3, e.RowIndex).Value * proizvod_info.BrojKomPak_ScalarQuery(UkupnaTezina(0, e.RowIndex).Value) * Convert.ToDouble(proizvod_info.TezinaProizvoda_ScalarQuery(UkupnaTezina(0, e.RowIndex).Value)) + proizvod_info.TezinaProizvoda_ScalarQuery(UkupnaTezina(0, e.RowIndex).Value) * Math.Round((Convert.ToDouble(UkupnaTezina(4, e.RowIndex).Value) / Convert.ToDouble(proizvod_info.TezinaProizvoda_ScalarQuery(UkupnaTezina(0, e.RowIndex).Value)))), 2) If IsDBNull(UkupnaTezina(0, e.RowIndex).Value) Then Exit Sub ' If CustomDataGridView1.RowCount > 1 Then ' Dim amount As Decimal = 0 ' For index As Integer = 0 To CustomDataGridView1.RowCount - 1 ' amount += Convert.ToDecimal(CustomDataGridView1.Rows(index).Cells(5).Value) ' Next ' TextBox1.Text = Val(amount) ' End If End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click BindingNavigatorAddNewItem.PerformClick() Me.NazivComboBox.Select() End Sub End Class |
zxz | 13.06.2018 18:34 |
---|---|
Predmet:Re: Kako sprečiti dupli unos u DataGrid (dupli proizvod) Koja je baza podataka? U koju bazu smijestas podatke? |
Gjoreski | 13.06.2018 21:16 |
---|---|
Predmet:Re: Kako sprečiti dupli unos u DataGrid (dupli proizvod) Pitajne br1 . Dali je vb6 ili neka od verzije Vb,Net a. Pitajne Br2 . Koja konenekcija koristis. Pitajne Br3. Jeli datagrid boun ili unbound. i tako dalje do beskraja. Najbolje postavi primer pa da resimeo. |
xl_kid | 15.06.2018 13:20 |
---|---|
Predmet:Re: Kako sprečiti dupli unos u DataGrid (dupli proizvod) NaÅ¡ao sam na netu ovo reÅ¡enje. ****************** Private Sub CustomDataGridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles CustomDataGridView1.CellValueChanged If CustomDataGridView1.Columns(e.ColumnIndex).Name = "ProizvodIDDataGridViewTextBoxColumn" Then 'Prevent duplicates For i As Integer = 0 To CustomDataGridView1.RowCount - 1 For j As Integer = i + 1 To CustomDataGridView1.RowCount - 2 If CustomDataGridView1.Rows(i).Cells(0).Value = CustomDataGridView1.Rows(j).Cells(0).Value Then MsgBox("Ovaj proizvod je unet.", MsgBoxStyle.Information, "Upozorenje") 'CustomDataGridView1.CurrentCell.Value = "" Continue For End If Next Next End If End Sub ***************** Prijavi mi greÅ¡ku o duplom unosu Å¡to je ok. Kako sada da stovim focus na prvo polje i nastavim sa unosom. Ako stavim #CustomDataGridView1.CurrentCell.Value = ""# dozvoli mi unos ali posle entera obriÅ¡e tj vrati na "". Å ta sad? |
Gjoreski | 15.06.2018 13:34 |
---|---|
Predmet:Re: Kako sprečiti dupli unos u DataGrid (dupli proizvod) Moras da kazes na gridi da posle poruka koja dobijes dodaje se novi red |