Exemplo n.º 1
0
        public void Delete()
        {
            short            routes       = 0;
            BAudit           bAudit       = new BAudit();
            EAudit           eAudit       = null;
            BCompany         bCompany     = new BCompany();
            ECompany         eCompany     = new ECompany();
            BCorporation     bCorporation = new BCorporation();
            ECorporation     eCorporation = new ECorporation();
            TransactionScope ts           = new TransactionScope(TransactionScopeOption.RequiresNew);

            eCorporation.CodeCorporation    = Aleatory.GetString(2);
            eCorporation.Name               = Aleatory.GetString(8);
            eCorporation.State              = 1;
            eCorporation.Audit.UserRegister = Aleatory.GetString(8);
            bCorporation.Insert(eCorporation);

            eCompany.CodeCompany        = Aleatory.GetString(2);
            eCompany.Ruc                = Aleatory.GetString(11);
            eCompany.CodeCorporation    = eCorporation.CodeCorporation;
            eCompany.LongName           = Aleatory.GetString(8);
            eCompany.State              = Aleatory.GetShort();
            eCompany.Audit.UserRegister = Aleatory.GetString(8);
            bCompany.Insert(eCompany);

            if (bCompany.Select(eCompany) != null)
            {
                routes++;
            }

            bCompany.Delete(eCompany);

            if (bCompany.Select(eCompany) == null)
            {
                routes++;
            }

            eAudit = bAudit.Select(eCompany.Audit).
                     Where(x => x.UserRegister == eCompany.Audit.UserRegister &&
                           x.TypeEvent == "Delete" &&
                           x.Code == eCompany.Audit.Code).FirstOrDefault();
            if (eAudit != null)
            {
                routes++;
            }

            ts.Dispose();

            Assert.AreEqual(routes, 3);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 删除
 /// </summary>
 private void MasterToolBar_DoDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要删除吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK)
     {
         try
         {
             GetCurrentSelectedTable();
             if (_currentCompanyTable != null)
             {
                 bCompany.Delete(_currentCompanyTable.CODE);
                 Search(this.pgControl.GetCurrentPage());
             }
             else
             {
                 MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         _currentCompanyTable = null;
     }
 }