Exemplo n.º 1
0
        public void Delete(string MANV)
        {
            try
            {
                DB.SubmitChanges();
                //ORDER DELETION, PLEASE DO NOT CHANGE

                //1. Delete MANV in DONXINs
                DONXINBLL DX = new DONXINBLL();
                DX.onMinifrm = this.onMinifrm;
                DX.Delete(MANV);
                this.Status += (DX.Status);


                //2. Delete MANV in TAIKHOANs
                TAIKHOANBLL TK = new TAIKHOANBLL();
                TK.onMinifrm = this.onMinifrm;
                TK.Delete(MANV);
                this.Status += (TK.Status);


                //4. Delete MANV in QTCONGTACs
                QTCONGTACBLL QTCT = new QTCONGTACBLL();
                QTCT.onMinifrm = this.onMinifrm;
                QTCT.Delete_MANV(MANV);
                this.Status += (QTCT.Status);

                //5. Delete MANV in LICHs
                LICHBLL LI = new LICHBLL();
                LI.onMinifrm = this.onMinifrm;
                LI.Delete_MANV(MANV);
                this.Status += (LI.Status);

                //6. Delete MANV in COTNs
                COTNBLL COTN = new COTNBLL();
                COTN.onMinifrm = this.onMinifrm;
                COTN.Delete_MANV(MANV);
                this.Status += (COTN.Status);

                //7. Delete MANV in QUYETDINHs
                QUYETDINHBLL QD = new QUYETDINHBLL();
                QD.onMinifrm = this.onMinifrm;
                QD.Delete_MANV(MANV);
                this.Status += (QD.Status);

                //8. Delete MANV in TRINHDONGHIEPVUs
                TRINHDOBLL TD = new TRINHDOBLL();
                TD.onMinifrm = this.onMinifrm;
                TD.Delete_MANV(MANV);
                this.Status += (TD.Status);

                var NVIEN = DB.NHANVIENs.FirstOrDefault(rc => rc.MANV == MANV);
                DB.NHANVIENs.DeleteOnSubmit(NVIEN);
                DB.SubmitChanges();
                //3. Delete MABCC in BANGCCs
                BANGCHAMCONGBLL BCC = new BANGCHAMCONGBLL();
                BCC.onMinifrm = this.onMinifrm;
                BCC.Delete(this.get_MABCC(MANV));
                this.Status += (BCC.Status);


                this.Status += "\nNHANVIEN: " + msg.delete_success;

                MessageBox.Show(this.Status, "Thông báo.", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            catch
            {
                this.Status += "\nNHANVIEN: " + msg.delete_fail;
                MessageBox.Show(this.Status, "Thông báo.", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }