Пример #1
0
        private void MakeDeletes(IDataSource ds, XmlDocument xml)
        {
            XmlNodeList deletingRecords = xml.SelectNodes("records/Deleted/record");
            string      id = GetIdColumnName();

            foreach (XmlNode node in deletingRecords)
            {
                record    = node;
                values    = new SortedList(0);
                keys      = new SortedList();
                oldValues = new SortedList(0);

                confirmation = null;
                if (!string.IsNullOrEmpty(id))
                {
                    XmlNode keyNode = node.SelectSingleNode(id);
                    string  idStr   = keyNode != null ? keyNode.InnerText : null;

                    int idInt;
                    if (int.TryParse(idStr, out idInt))
                    {
                        keys[id] = idInt;
                    }
                    else
                    {
                        keys[id] = idStr;
                    }

                    if (this.UseIdConfirmation && keys[id] != null)
                    {
                        confirmation = changingEventArgs.ConfirmationList[keys[id].ToString()];
                    }
                }

                BeforeRecordDeletedEventArgs eBeforeRecordDeleted = new BeforeRecordDeletedEventArgs(record, keys, confirmation);
                this.OnBeforeRecordDeleted(eBeforeRecordDeleted);
                if (eBeforeRecordDeleted.CancelAll)
                {
                    break;
                }
                if (eBeforeRecordDeleted.Cancel)
                {
                    continue;
                }

                if (ds != null)
                {
                    ds.GetView("").Delete(keys, oldValues, DeleteCallback);
                }
                else
                {
                    this.DeleteCallback(0, null);
                }
            }

            if (deletingRecords.Count > 0)
            {
                needRetrieve = true;
            }
        }
Пример #2
0
        protected virtual void OnBeforeRecordDeleted(BeforeRecordDeletedEventArgs e)
        {
            BeforeRecordDeletedEventHandler handler = (BeforeRecordDeletedEventHandler)Events[EventBeforeRecordDeleted];

            if (handler != null)
            {
                handler(this, e);
            }
        }