Exemple #1
0
        private void btnVerwijderen_Click(object sender, EventArgs e)
        {
            if (actueelJaarGegevensId != 0)
            {
                tblVr vr = new tblVr();
                int   ssAantal;
                int   vrAantal;
                int   jsAantal;

                // Controle gebruik in voorraad
                vr.bvrNaarList = false;
                vrAantal       = vr.telVoorraadRecord("Vrrd_JgegId = " + actueelJaarGegevensId.ToString());

                // Controle gebruik in Jaarsaldo
                tblJs js = new tblJs();
                jsAantal = js.telJaarSaldoRecord("Jsal_JgegId = " + actueelJaarGegevensId.ToString());

                // Controle gebruik in Saldostand
                tblSs ss = new tblSs();
                ssAantal = ss.telSaldoStandRecord("Saldostand_JgegId = " + actueelJaarGegevensId.ToString());

                string sGebruik = "";
                if (vrAantal != 0 && ssAantal != 0 && jsAantal != 0)
                {
                    sGebruik = "Jaargegevens " + msktxtbxOmschrijving.Text + " \nis nog in gebruik bij: \n\n";
                    if (vrAantal != 0)
                    {
                        sGebruik = sGebruik + "- " + vrAantal.ToString() + " voorraadrecords" + "\n";
                    }
                    if (jsAantal != 0)
                    {
                        sGebruik = sGebruik + "- " + jsAantal.ToString() + " jaarsaldorecords" + "\n";
                    }
                    if (ssAantal != 0)
                    {
                        sGebruik = sGebruik + "- " + ssAantal.ToString() + " saldostandrecords" + "\n";
                    }
                    sGebruik = sGebruik + "Verwijderen is niet mogelijk!";
                }

                if (sGebruik != "")
                {
                    DialogResult resultDelete = MessageBox.Show(sGebruik, "Jaargegevens verwijderen?");
                }
                else
                {
                    int          iId           = actueelJaarGegevensId;
                    string       sJaarGegevens = "Wilt u deze jaargegevens (" + msktxtbxOmschrijving.Text + ") verwijderen?";
                    DialogResult resultDelete  = MessageBox.Show(sJaarGegevens, "Jaargegevens verwijderen?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (resultDelete == DialogResult.Yes)
                    {
                        tblJg jg = new tblJg();
                        if (actueelJaarGegevensId == 0 && iId != 0)
                        {
                            actueelJaarGegevensId = iId;
                        }
                        jg.deleteRecord(actueelJaarGegevensId);
                        //DisplayData();
                        bDeleteRecord = true;
                        this.jaargegevensTableAdapter.Fill(this._Cmbap_dataDataSet.Jaargegevens);
                        bDeleteRecord = false;

                        int rijIndex       = dtgrdvwJaarGegevens.CurrentCell.RowIndex;
                        int JaarGegevensId = int.Parse(dtgrdvwJaarGegevens.Rows[rijIndex].Cells[0].Value.ToString());

                        jg.zoekJaarGegevensRecord("Jgeg_Id = " + dtgrdvwJaarGegevens.Rows[rijIndex].Cells[0].Value.ToString());
                        if (jg.lstJaarGegevensRecord.Count == 1)
                        {
                            var jgVan = jg.vanRecord(0);
                            if (actueelJaarGegevensId != jgVan.Jgeg_Id)
                            {
                                vulVelden(jgVan);
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void btnVerwijderen_Click(object sender, EventArgs e)
        {
            if (actueelProductId != 0)
            {
                tblVr vr = new tblVr();
                int   blAantal;
                int   vrAantal;

                vr.bvrNaarList = false;
                vrAantal       = vr.telVoorraadRecord("Vrrd_ProdId = " + actueelProductId.ToString());

                tblBl bl = new tblBl();
                blAantal = bl.telBestelregelRecord("Bstlr_ProdId = " + actueelProductId.ToString());

                string sGebruik = "";
                if (vrAantal != 0 && blAantal != 0)
                {
                    sGebruik = "Product " + txtbxKorteNaam.Text + " \nis nog in gebruik bij: \n\n" +
                               "- " + vrAantal.ToString() + " voorraadrecords" + "\n -" +
                               "- " + blAantal.ToString() + " bestelregelrecords" + "\n \n" +
                               "Verwijderen is niet mogelijk!";
                }
                if (vrAantal == 0 && blAantal != 0)
                {
                    sGebruik = "Product " + txtbxKorteNaam.Text + " \nis nog in gebruik bij: \n\n" +
                               "- " + blAantal.ToString() + " bestelregelrecords" + "\n \n" +
                               "Verwijderen is niet mogelijk!";
                }

                if (vrAantal != 0 && blAantal == 0)
                {
                    sGebruik = "Product " + txtbxKorteNaam.Text + " \n is nog in gebruik bij: \n\n" +
                               "- " + vrAantal.ToString() + " voorraadrecords" + "\n \n" +
                               "Verwijderen is niet mogelijk!";
                }


                if (sGebruik != "")
                {
                    DialogResult resultDelete = MessageBox.Show(sGebruik, "Product verwijderen?");
                }
                else
                {
                    int iId = actueelProductId;
                    //  <<Zoek of product wordt gebruikt in Voorraad of in Bestelregels en daar reactie op >>
                    string       sProduct     = "Wilt u dit product (" + txtbxKorteNaam.Text + ") verwijderen?";
                    DialogResult resultDelete = MessageBox.Show(sProduct, "Product verwijderen?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (resultDelete == DialogResult.Yes)
                    {
                        tblPd pd = new tblPd();
                        if (actueelProductId == 0 && iId != 0)
                        {
                            actueelProductId = iId;
                        }
                        pd.deleteRecord(actueelProductId);
                        //DisplayData();
                        bDeleteRecord = true;
                        this.productTableAdapter.Fill(this._Cmbap_dataDataSet.Product);
                        bDeleteRecord = false;

                        int rijIndex  = dtgrdvwProducten.CurrentCell.RowIndex;
                        int ProductId = int.Parse(dtgrdvwProducten.Rows[rijIndex].Cells[0].Value.ToString());

                        pd.zoekProductRecord("Prod_Id = " + dtgrdvwProducten.Rows[rijIndex].Cells[0].Value.ToString());
                        if (pd.lstProductRecord.Count == 1)
                        {
                            var pdVan = pd.vanRecord(0);
                            if (actueelProductId != pdVan.Prod_Id)
                            {
                                vulVelden(pdVan);
                            }
                        }
                    }
                }
            }
        }