void controller_BeforeDeleteEvent(object sender, BeforeDeleteEventArgs e)
 {
     if (MessageBox.Show(e.Message, "删除", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
     {
         e.Cancel = true;
     }
 }
        /// <summary>
        /// 删除一张处方
        /// </summary>
        /// <param name="rowIndex">选中的处方所包含的行索引</param>
        public void DeletePrescription(int rowIndex)
        {
            DataTable tbPresc = (DataTable)formView.Prescriptions;

            if (tbPresc.Rows.Count == 0)
            {
                return;
            }
            int start, end, subtotal;

            GetPrescriptionSectionStartRow(rowIndex, out start, out end, out subtotal);

            if (BeforeDeleteEvent != null)
            {
                //触发删除事件
                BeforeDeleteEventArgs e = new BeforeDeleteEventArgs( );
                e.Message = "确认要删除第" + rowIndex + "行的处方吗?";
                BeforeDeleteEvent(this, e);
                if (e.Cancel)
                {
                    return;
                }
            }
            AfterDeleteEventArgs e2 = new AfterDeleteEventArgs( );

            try
            {
                int presId = Convert.ToInt32(tbPresc.Rows[rowIndex][COL_PRESMASTER_ID]);
                if (presId > 0)
                {
                    prescController.DeletePrescription(presId);
                }
                e2.Message = "删除成功!";
            }
            catch (Exception err)
            {
                e2.Cancel  = true;
                e2.Message = err.Message;
            }
            if (AfterDeleteEvent != null)
            {
                AfterDeleteEvent(this, e2);
            }

            //获得处方张数标志
            int presAmbit = GetAppointedPrescriptionAmbit(rowIndex);

            //得到指定的处方的所有明细
            DataRow[] drsNeedRemove = tbPresc.Select(COL_PRESC_AMBIT + "=" + presAmbit);

            for (int i = 0; i < drsNeedRemove.Length; i++)
            {
                tbPresc.Rows.Remove(drsNeedRemove[i]);
            }
        }
        /// <summary>
        /// 删除一条处方明细
        /// </summary>
        /// <param name="rowIndex">要删除的明细所在的行索引</param>
        public void DeletePrescriptionDetail(int rowIndex)
        {
            DataTable tbPresc = (DataTable)formView.Prescriptions;

            if (tbPresc.Rows.Count == 0)
            {
                return;
            }
            int start, end, subtotal;

            GetPrescriptionSectionStartRow(rowIndex, out start, out end, out subtotal);

            if (start == end)
            {
                //如果处方的开始行等于处方的结束行,说明当前处方只有一条记录,直接调用删除整张处方功能
                DeletePrescription(rowIndex);
            }
            else
            {
                if (BeforeDeleteEvent != null)
                {
                    //触发删除事件
                    BeforeDeleteEventArgs e1 = new BeforeDeleteEventArgs( );
                    e1.Message = "确认要删除第" + rowIndex + "行的处方明细吗?";
                    BeforeDeleteEvent(this, e1);
                    if (e1.Cancel)
                    {
                        return;
                    }
                }
                int detailId           = Convert.ToInt32(tbPresc.Rows[rowIndex][COL_PRESDETAIL_ID]);
                AfterDeleteEventArgs e = new AfterDeleteEventArgs( );
                try
                {
                    if (detailId > 0)
                    {
                        prescController.DeletePrescriptionDetail(detailId);
                    }
                    e.Message = "删除成功!";
                }
                catch (Exception err)
                {
                    e.Cancel  = true;
                    e.Message = err.Message;
                }
                if (AfterDeleteEvent != null)
                {
                    AfterDeleteEvent(this, e);
                }

                tbPresc.Rows.RemoveAt(rowIndex);
            }
        }