/// <summary>
        /// 保存日结数据
        /// </summary>
        public void DayBalance()
        {
            if (this.alBalanceData == null)
            {
                return;
            }

            if (MessageBox.Show("是否进行日结,日结后数据将不能恢复?", "门诊收款员缴款日报", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                //
                // 变量定义
                //
                // 返回值
                int intReturn = 0;
                // 事务对象
                //Neusoft.FrameWork.Management.Transaction transaction = new Neusoft.FrameWork.Management.Transaction(Neusoft.FrameWork.Management.Connection.Instance);
                // 等待窗口
                Neusoft.FrameWork.WinForms.Forms.frmWait waitForm = new Neusoft.FrameWork.WinForms.Forms.frmWait();
                // 门诊收费业务层
                Neusoft.HISFC.BizLogic.Fee.Outpatient outpatient = new Neusoft.HISFC.BizLogic.Fee.Outpatient();
                // 日结序号
                string sequence = "";

                //
                // 判断合法性
                //
                if (!this.enableBalance)
                {
                    MessageBox.Show("不能进行日结");
                    return;
                }
                if (this.alBalanceData == null)
                {
                    return;
                }

                // 启动等待窗口
                waitForm.Tip = "正在进行日结";
                waitForm.Show();

                //
                // 设置事务
                //
                Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();

                //transaction.BeginTransaction();
                this.clinicDayBalance.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);
                outpatient.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);

                //
                // 保存日结数据
                //
                this.operateDate = this.clinicDayBalance.GetDateTimeFromSysDateTime().ToString();
                // 获取日结序号
                intReturn = this.clinicDayBalance.GetBalanceSequence(ref sequence);
                if (intReturn == -1)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                    waitForm.Hide();
                    MessageBox.Show("获取日结序列号失败");
                    return;
                }
                foreach (Class.ClinicDayBalance tempBalance in this.alBalanceData)
                {
                    tempBalance.BalanceSequence = sequence;
                    tempBalance.BalanceDate     = DateTime.Parse(this.operateDate);
                    intReturn = clinicDayBalance.CreateClinicDayBalance(tempBalance);
                    if (intReturn == -1)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        waitForm.Hide();
                        MessageBox.Show("日结失败" + outpatient.Err);
                        return;
                    }
                }

                //
                // 更新其他表
                //
                // 更新发票主表表FIN_OPB_INVOICEINFO
                intReturn = outpatient.UpdateInvoiceForDayBalance(DateTime.Parse(this.lastDate),
                                                                  DateTime.Parse(this.dayBalanceDate),
                                                                  "1",
                                                                  sequence,
                                                                  DateTime.Parse(this.operateDate));
                if (intReturn <= 0)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                    waitForm.Hide();
                    MessageBox.Show("更新发票主表失败" + outpatient.Err);
                    return;
                }
                // 更新发票明细表FIN_OPB_INVOICEDETAIL
                intReturn = outpatient.UpdateInvoiceDetailForDayBalance(DateTime.Parse(this.lastDate),
                                                                        DateTime.Parse(this.dayBalanceDate),
                                                                        "1",
                                                                        sequence,
                                                                        DateTime.Parse(this.operateDate));
                if (intReturn <= 0)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                    waitForm.Hide();
                    MessageBox.Show("更新发票明细表失败");
                    return;
                }
                // 更新支付情况表FIN_OPB_PAYMODE
                intReturn = outpatient.UpdatePayModeForDayBalance(DateTime.Parse(this.lastDate),
                                                                  DateTime.Parse(this.dayBalanceDate),
                                                                  "1",
                                                                  sequence,
                                                                  DateTime.Parse(this.operateDate));
                if (intReturn <= 0)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                    waitForm.Hide();
                    MessageBox.Show("更新支付情况表失败" + outpatient.Err);
                    return;
                }

                //
                // 保存成功
                //
                Neusoft.FrameWork.Management.PublicTrans.Commit();
                waitForm.Hide();
                MessageBox.Show("日结成功完成");
                this.PrintPanel(this.panelPrint);

                alBalanceData = null;

                // 设置上次日结时间显示
                this.ucClinicDayBalanceDateControl1.tbLastDate.Text      = this.dayBalanceDate;
                this.ucClinicDayBalanceDateControl1.dtpBalanceDate.Value = this.clinicDayBalance.GetDateTimeFromSysDateTime();
            }
        }