void controller_BeforeInsertRow(object sender, BeforeInsertRowArgs e)
 {
     if (e.Cancel)
     {
         MessageBox.Show(e.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        /// <summary>
        /// 是否允许增加空的明细行
        /// </summary>
        /// <param name="crossRowIndex">参照行,一般为当前所在行</param>
        /// <param name="message">返回不能插入行的原因提示</param>
        /// <returns></returns>
        public bool AllowAddEmptyPrescriptionDetail(int crossRowIndex, out string message)
        {
            message = "";
            DataTable tbPresc = (DataTable)formView.Prescriptions;

            if (tbPresc.Rows.Count == 0)
            {
                return(true);
            }

            bool bRet             = true;
            BeforeInsertRowArgs e = new BeforeInsertRowArgs( );
            bool isLastRow        = (crossRowIndex == (tbPresc.Rows.Count - 1) ? true : false);
            int  subTotalRowFlag  = Convert.ToInt32(tbPresc.Rows[crossRowIndex][COL_SUB_TOTAL_FLAG]);

            if (subTotalRowFlag == 1)
            {
                message   = "小计行不能进行任何操作";
                e.Message = message;
                bRet      = false;
            }
            else
            {
                int doctor_presc_id = Convert.ToInt32(tbPresc.Rows[crossRowIndex][COL_DOC_PRESMASTER_ID]);
                if (doctor_presc_id != 0)
                {
                    message   = "医生处方不允许进行追加,删除行操作!";
                    e.Message = message;
                    e.Cancel  = true;
                    bRet      = false;
                }

                int itemId = Convert.ToInt32(tbPresc.Rows[crossRowIndex][COL_ITEM_ID]);
                if (isLastRow && itemId == 0)
                {
                    message   = "最后一行已经是空行";
                    e.Message = message;
                    bRet      = false;
                }

                if (formView.PrescDoctorId == 0 || formView.DoctorDeptId == 0)
                {
                    message   = "新增处方或处方明细前请先指定处方医生";
                    e.Cancel  = true;
                    e.Message = message;
                    bRet      = false;
                }
                else
                {
                    int start, end, subtotalRow;
                    GetPrescriptionSectionStartRow(crossRowIndex, out start, out end, out subtotalRow);
                    Hashtable doctorIds = new Hashtable( );
                    int       presambit = Convert.ToInt32(tbPresc.Rows[crossRowIndex][COL_PRESC_AMBIT]);
                    DataRow[] drs       = tbPresc.Select(COL_PRESC_AMBIT + "=" + presambit + " AND " + COL_SUB_TOTAL_FLAG + "= 0");
                    for (int i = 0; i < drs.Length; i++)
                    {
                        int docId = Convert.ToInt32(drs[i][COL_PRES_DOC_ID]);
                        if (!doctorIds.ContainsKey(docId))
                        {
                            doctorIds.Add(docId, drs[i][COL_PRES_DOC_NAME].ToString( ).Trim( ));
                        }
                    }
                    if (doctorIds.Count > 0)
                    {
                        if (!doctorIds.ContainsKey(formView.PrescDoctorId))
                        {
                            message   = "相同处方内处方医生必须一致";
                            e.Cancel  = true;
                            e.Message = message;
                            bRet      = false;
                        }
                    }
                }
            }
            if (BeforeInsertRow != null)
            {
                BeforeInsertRow(this, e);
            }
            return(bRet);
        }