protected void Grid_LegalInvoiceArtifactType_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
 {
     try
     {
         e.Cancel = true;
         session.BeginTransaction();
         string description = "";
         NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType artifactType = new NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType(session);
         if (BO.check_LegalInvoiceArtifacType(session, e.NewValues["Code"].ToString(), Utility.Constant.ROWSTATUS_ACTIVE.ToString()))
         {
             throw new Exception("Mã số phân loại trùng");
         }
         if (e.NewValues["Description"] != null)
         {
             description = e.NewValues["Description"].ToString();
         }
         artifactType.Code        = e.NewValues["Code"].ToString();
         artifactType.Name        = e.NewValues["Name"].ToString();
         artifactType.Category    = char.Parse(e.NewValues["Category"].ToString());
         artifactType.RowStatus   = Utility.Constant.ROWSTATUS_ACTIVE;
         artifactType.Description = description;
         session.CommitTransaction();
         session.FlushChanges();
         Grid_LegalInvoiceArtifactType.CancelEdit();
     }
     catch (Exception)
     {
         session.RollbackTransaction();
         throw;
     }
 }
 protected void Grid_LegalInvoiceArtifactType_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
 {
     try
     {
         e.Cancel = true;
         session.BeginTransaction();
         NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType artifactType = session.GetObjectByKey <NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType>(Guid.Parse(e.Keys[0].ToString()));
         if (artifactType == null)
         {
             throw new Exception("LegalInvoiceArtifactType is not exist system");
         }
         SaleInvoiceArtiface saleId = session.FindObject <SaleInvoiceArtiface>(
             CriteriaOperator.And(
                 new BinaryOperator("LegalInvoiceArtifactTypeId", artifactType.LegalInvoiceArtifactTypeId, BinaryOperatorType.Equal),
                 new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.Equal)
                 ));
         if (saleId == null)
         {
             artifactType.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
         }
         else
         {
             throw new Exception("Đã có thông tin nên không được xóa!");
         }
         session.CommitTransaction();
         session.FlushChanges();
         Grid_LegalInvoiceArtifactType.CancelEdit();
     }
     catch (Exception)
     {
         session.RollbackTransaction();
         throw;
     }
 }