Ejemplo n.º 1
0
        private void btnAnnuleren_Click(object sender, EventArgs e)
        {
            if (bNewRecord == true)
            {
                tblPd pd = new tblPd();
                if (actueelProductId != 0)
                {
                    pd.deleteRecord(actueelProductId);
                    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);
                        }
                    }
                }
            }
            else
            {
                int rijIndex = dtgrdvwProducten.CurrentCell.RowIndex;
                actueelProductId = int.Parse(dtgrdvwProducten.Rows[rijIndex].Cells[0].Value.ToString());
                tblPd pd = new tblPd();

                pd.zoekProductRecord("Prod_Id = " + dtgrdvwProducten.Rows[rijIndex].Cells[0].Value.ToString());
                if (pd.lstProductRecord.Count == 1)
                {
                    var pdVan = pd.vanRecord(0);
                    vulVelden(pdVan);
                }
            }
            btnToevoegen.Enabled     = true;
            btnVerwijderen.Enabled   = true;
            dtgrdvwProducten.Enabled = true;
            dtgrdvwProducten.Refresh();
        }
Ejemplo n.º 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);
                            }
                        }
                    }
                }
            }
        }