Пример #1
0
        /// <summary>
        /// 获取可用发票张数
        /// </summary>
        /// <param name="billKind">发票类型</param>
        /// <param name="OperatorId">操作员ID(即EMPLOYEEID)</param>
        /// <returns></returns>
        public static int GetInvoiceNumberOfCanUse(OPDBillKind billKind, int OperatorId)
        {
            int count = 0;
            List <HIS.Model.MZ_INVOICE> invoices = null;

            //第一步:查找个人当前可用票据
            invoices = MSAccessDb.GetListArray <MZ_INVOICE>("MZ_INVOICE", "invoice_type=" + (int)billKind + " and status=0 and employee_id =" + OperatorId);
            foreach (MZ_INVOICE invoice in invoices)
            {
                count = count + (invoice.END_NO - invoice.CURRENT_NO + 1);
            }

            //第二步:查找个人备用票据
            invoices = MSAccessDb.GetListArray <MZ_INVOICE>("MZ_INVOICE", "invoice_type=" + (int)billKind + " and status=2 and employee_id =" + OperatorId);
            foreach (MZ_INVOICE invoice in invoices)
            {
                count = count + (invoice.END_NO - invoice.CURRENT_NO + 1);
            }

            //第三步:查找公共当前在用票据
            invoices = MSAccessDb.GetListArray <MZ_INVOICE>("MZ_INVOICE", "invoice_type=" + (int)billKind + " and status=0 and employee_id =0");
            foreach (MZ_INVOICE invoice in invoices)
            {
                count = count + (invoice.END_NO - invoice.CURRENT_NO + 1);
            }

            //第四步:查找公共备用票据
            invoices = MSAccessDb.GetListArray <MZ_INVOICE>("MZ_INVOICE", "invoice_type=" + (int)billKind + " and status=2 and employee_id =0");
            foreach (MZ_INVOICE invoice in invoices)
            {
                count = count + (invoice.END_NO - invoice.CURRENT_NO + 1);
            }

            return(count);
        }
Пример #2
0
        /// <summary>
        /// 发票号
        /// </summary>
        /// <param name="InviceNo"></param>
        /// <param name="InvoiceType"></param>
        public OutPatient(string InviceNo, OPDBillKind InvoiceType)
        {
            List <HIS.Model.MZ_CostMaster> models = null;

            HIS.Model.MZ_PatList model = null;
            string strWhere            = "";

            if (InvoiceType == OPDBillKind.门诊收费发票)
            {
                strWhere = "TICKETNUM='" + InviceNo + "'" + oleDb.And( ) + Tables.mz_costmaster.HANG_FLAG + oleDb.EuqalTo( ) + "1";
            }
            else
            {
                strWhere = "TICKETNUM='" + InviceNo + "'" + oleDb.And( ) + Tables.mz_costmaster.HANG_FLAG + oleDb.EuqalTo( ) + "0";
            }
            models = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetListArray(strWhere);

            if (models.Count == 0)
            {
                throw new Exception("输入的发票流水号找不到病人登记信息");
            }
            else
            {
                model = BindEntity <Model.MZ_PatList> .CreateInstanceDAL(oleDb).GetModel(models[0].PatListID);
            }
            BindData(model);
        }
Пример #3
0
        /// <summary>
        /// 调整发票号
        /// </summary>
        /// <param name="billKind"></param>
        /// <param name="OperatorId"></param>
        /// <param name="NewInvoiceNo"></param>
        /// <returns></returns>
        public static bool AdjustInvoiceNo(OPDBillKind billKind, int OperatorId, string PerfChar, string NewInvoiceNo)
        {
            string strWhere = Tables.mz_invoice.STATUS + oleDb.EuqalTo() + "0";

            strWhere += oleDb.And() + Tables.mz_invoice.EMPLOYEE_ID + oleDb.EuqalTo() + OperatorId;
            strWhere += oleDb.And( ) + Tables.mz_invoice.INVOICE_TYPE + oleDb.EuqalTo( ) + (int)billKind;
            strWhere += oleDb.And( ) + Tables.mz_invoice.PERFCHAR + oleDb.EuqalTo( ) + "'" + PerfChar + "'";

            Model.MZ_INVOICE mz_invoice = BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).GetModel(strWhere);

            long newInvoiceNo = Convert.ToInt64(NewInvoiceNo);

            if (mz_invoice != null)
            {
                if (newInvoiceNo > Convert.ToInt64(mz_invoice.END_NO))
                {
                    throw new OperatorException("要调整的发票号不能超出本卷票的结束号!");
                }
                if (newInvoiceNo <= Convert.ToInt64(mz_invoice.CURRENT_NO))
                {
                    throw new OperatorException("要调整的发票号不能小于当前票号!");
                }
                BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).Update(strWhere, Tables.mz_invoice.CURRENT_NO + oleDb.EuqalTo( ) + newInvoiceNo);

                return(true);
            }
            else
            {
                throw new OperatorException("没有找到当前在用发票记录!");
            }
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="billKind"></param>
        /// <param name="OperatorId"></param>
        /// <param name="NewInvoiceNo"></param>
        /// <returns></returns>
        public static bool AdjustInvoiceNo(OPDBillKind billKind, int OperatorId, string NewInvoiceNo)
        {
            string strWhere = Tables.mz_invoice.STATUS + " = 0";

            strWhere += " and " + Tables.mz_invoice.EMPLOYEE_ID + " = " + OperatorId;
            strWhere += " and " + Tables.mz_invoice.INVOICE_TYPE + " = " + (int)billKind;

            MZ_INVOICE mz_invoice   = (MZ_INVOICE)MSAccessDb.GetModel("MZ_INVOICE", strWhere, typeof(MZ_INVOICE));
            long       newInvoiceNo = Convert.ToInt64(NewInvoiceNo);

            if (mz_invoice != null)
            {
                if (newInvoiceNo > Convert.ToInt64(mz_invoice.END_NO))
                {
                    throw new Exception("要调整的发票号不能超出本卷票的结束号!");
                }
                if (newInvoiceNo <= Convert.ToInt64(mz_invoice.CURRENT_NO))
                {
                    throw new Exception("要调整的发票号不能小于当前票号!");
                }
                //BindEntity<MZ_INVOICE>.CreateInstanceDAL( oleDb ).Update( strWhere , Tables.mz_invoice.CURRENT_NO + oleDb.EuqalTo( ) + newInvoiceNo );
                MSAccessDb.UpdateRecord(new string[] { Tables.mz_invoice.CURRENT_NO + " = " + newInvoiceNo },
                                        strWhere, typeof(MZ_INVOICE));
                return(true);
            }
            else
            {
                throw new Exception("没有找到当前在用发票记录!");
            }
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AccountBook"></param>
        /// <param name="Kind"></param>
        public FrmViewInvoice(BaseAccountBook AccountBook, OPDBillKind Kind)
        {
            InitializeComponent( );

            accountBook = AccountBook;

            kind      = Kind;
            this.Text = this.Text + " --【" + kind.ToString( ) + "】";
        }
Пример #6
0
        /// <summary>
        /// 挂号正式结算
        /// </summary>
        /// <param name="Patient"></param>
        /// <param name="budgetInfo"></param>
        /// <returns></returns>
        public override bool Register(RegPatient Patient, ChargeInfo budgetInfo)
        {
            try
            {
                //更新病人门诊号
                BindEntity <Model.MZ_PatList> .CreateInstanceDAL(oleDb).Update(Tables.mz_patlist.PATLISTID + "=" + Patient.PatListID,
                                                                               Tables.mz_patlist.VISITNO + "='" + Patient.VisitNo + "'");

                OPDBillKind invoiceType = OPDBillKind.门诊挂号发票;
                if (Convert.ToInt32(OPDParamter.Parameters["012"]) == 1)
                {
                    invoiceType = OPDBillKind.门诊收费发票;
                }

                string perfChar  = "";
                string invoiceNo = InvoiceManager.GetBillNumber(invoiceType, OperatorId, false, out perfChar);

                Model.MZ_PresMaster mz_presmaster = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetModel(budgetInfo.PrescriptionID);

                mz_presmaster.Record_Flag = 0;        //改为正常状态
                mz_presmaster.Charge_Flag = 1;        //置为收费状态
                mz_presmaster.TicketNum   = invoiceNo;
                mz_presmaster.TicketCode  = perfChar; //前缀
                mz_presmaster.ChargeCode  = OperatorId.ToString( );
                BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).Update(mz_presmaster);

                Model.MZ_CostMaster mz_costmaster = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetModel(budgetInfo.ChargeID);

                mz_costmaster.Record_Flag = 0;
                mz_costmaster.ChargeCode  = OperatorId.ToString( );
                mz_costmaster.ChargeName  = OperatorName;
                mz_costmaster.TicketNum   = invoiceNo;
                mz_costmaster.TicketCode  = perfChar;//发票前缀
                mz_costmaster.Favor_Fee   = budgetInfo.FavorFee;
                mz_costmaster.Money_Fee   = budgetInfo.CashFee;
                mz_costmaster.Pos_Fee     = budgetInfo.PosFee;
                mz_costmaster.Self_Fee    = budgetInfo.SelfFee;
                mz_costmaster.Village_Fee = budgetInfo.VillageFee;
                BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Update(mz_costmaster);

                return(true);
            }
            catch (OperatorException operr)
            {
                throw operr;
            }
            catch (Exception err)
            {
                throw err;
            }
        }
Пример #7
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cboChargetor.Text.Trim() == "" || cboChargetor.MemberValue == null)
            {
                MessageBox.Show("请指定发票领用人!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            OPDBillKind invoiceType = OPDBillKind.门诊收费发票;

            foreach (object obj in Enum.GetValues(typeof(OPDBillKind)))
            {
                if (obj.ToString() == cboInvoiceType.Text)
                {
                    invoiceType = (OPDBillKind)obj;
                    break;
                }
            }

            int chargeUserId = Convert.ToInt32(cboChargetor.MemberValue);

            if (chkCommonUser.Checked)
            {
                chargeUserId = 0;
            }

            try
            {
                int    start    = Convert.ToInt32(txtKs.Text);
                int    end      = Convert.ToInt32(txtJs.Text);
                string perfChar = txtPerfChar.Text.Trim( );
                if (end < start)
                {
                    MessageBox.Show("结束号不能大于开始号", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (InvoiceManager.CheckInvoiceExists(invoiceType, start, end, perfChar))
                {
                    InvoiceManager.SetInvoiceRecord(invoiceType, chargeUserId, txtPerfChar.Text.Trim(), start, end, Convert.ToInt32(currentEmployeeId));
                    this.Close();
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #8
0
        /// <summary>
        /// 发票号
        /// </summary>
        /// <param name="InviceNo"></param>
        /// <param name="InvoiceType"></param>
        public OutPatient(string InviceNo, OPDBillKind InvoiceType)
        {
            List <HIS.Model.MZ_CostMaster> models = null;

            HIS.Model.MZ_PatList model = null;
            string strWhere            = "";

            if (InvoiceType == OPDBillKind.门诊收费发票)
            {
                strWhere = "TICKETNUM='" + InviceNo + "'" + " and " + Tables.mz_costmaster.HANG_FLAG + " = 1";
            }
            else
            {
                strWhere = "TICKETNUM='" + InviceNo + "'" + " and " + Tables.mz_costmaster.HANG_FLAG + " = 0";
            }
            models = MSAccessDb.GetListArray <MZ_CostMaster>("MZ_COSTMASTER", strWhere);
            if (models.Count == 0)
            {
                throw new Exception("输入的发票流水号找不到病人登记信息");
            }
            else
            {
                model = (MZ_PatList)MSAccessDb.GetModel("MZ_PATLIST", Tables.mz_patlist.PATLISTID + "=" + models[0].PatListID, typeof(MZ_PatList));
            }

            this.PatListID   = model.PatListID;
            this.PatID       = model.PatID;
            this.PatientName = model.PatName;
            this.VisitNo     = model.VisitNo;
            this.Sex         = model.PatSex;
            this.Age         = model.Age;
            this.PYM         = model.PYM;
            this.WBM         = model.WBM;
            _mediCard        = model.MediCard;
            _mediType        = model.MediType;
            _hpCode          = model.HpCode;
            _hpGrade         = model.HpGrade;
            _cureDeptCode    = model.CureDeptCode;
            _cureEmpCode     = model.CureEmpCode;
            _diseaseCode     = model.DiseaseCode;
            string[] disease = model.DiseaseName.Split("|".ToCharArray( ));
            _diseaseName = disease[0];
            if (disease.Length > 1)
            {
                _diseaseMemo = disease[1];
            }
            _cureDate = model.CureDate;
        }
Пример #9
0
        /// <summary>
        /// 设置发票记录
        /// </summary>
        /// <param name="invoiceType">发票类型</param>
        /// <param name="ChargetorId">领用人ID(EmployeeId)</param>
        /// <param name="StartNo">开始号</param>
        /// <param name="EndNo">结束号</param>
        /// <param name="Operator">操作员(EmployeeId)</param>
        public static void SetInvoiceRecord(OPDBillKind invoiceType, int ChargetorId, string PerfChar, int StartNo, int EndNo, int Operator)
        {
            HIS.Model.MZ_INVOICE model_mz_invoice = new HIS.Model.MZ_INVOICE();

            model_mz_invoice.ALLOT_DATE   = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
            model_mz_invoice.ALLOT_USER   = Operator;
            model_mz_invoice.CURRENT_NO   = StartNo;
            model_mz_invoice.EMPLOYEE_ID  = ChargetorId;
            model_mz_invoice.END_NO       = EndNo;
            model_mz_invoice.PerfChar     = PerfChar;
            model_mz_invoice.INVOICE_TYPE = (int)invoiceType;
            model_mz_invoice.START_NO     = StartNo;
            model_mz_invoice.STATUS       = 2;

            BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).Add(model_mz_invoice);
        }
Пример #10
0
        /// <summary>
        /// 设置发票记录
        /// </summary>
        /// <param name="invoiceType">发票类型</param>
        /// <param name="ChargetorId">领用人ID(EmployeeId)</param>
        /// <param name="StartNo">开始号</param>
        /// <param name="EndNo">结束号</param>
        /// <param name="Operator">操作员(EmployeeId)</param>
        public static void SetInvoiceRecord(OPDBillKind invoiceType, int ChargetorId, string PerfChar, int StartNo, int EndNo, int Operator)
        {
            HIS.Model.MZ_INVOICE model_mz_invoice = new HIS.Model.MZ_INVOICE();

            model_mz_invoice.ALLOT_DATE   = DateTime.Now;
            model_mz_invoice.ALLOT_USER   = Operator;
            model_mz_invoice.CURRENT_NO   = StartNo;
            model_mz_invoice.EMPLOYEE_ID  = ChargetorId;
            model_mz_invoice.END_NO       = EndNo;
            model_mz_invoice.INVOICE_TYPE = (int)invoiceType;
            model_mz_invoice.START_NO     = StartNo;
            model_mz_invoice.STATUS       = 2;
            model_mz_invoice.PerfChar     = PerfChar;
            model_mz_invoice.ID           = MSAccessDb.GetMaxID("MZ_INVOICE", Tables.mz_invoice.ID);

            MSAccessDb.InsertRecord(model_mz_invoice, Tables.mz_invoice.ID);
        }
Пример #11
0
        /// <summary>
        /// 根据挂号流水号获取发票列表
        /// </summary>
        /// <param name="PatListId"></param>
        /// <returns></returns>
        public List <Invoice> GetInvoiceListByPatListId(int PatListId)
        {
            StringBuilder sbSQL = new StringBuilder( );

            sbSQL.Append("select ticketnum,ticketcode,hang_flag from mz_costmaster where workid=" + EntityConfig.WorkID);
            sbSQL.Append(" and record_flag in (0) ");
            sbSQL.Append(" and patlistid=" + PatListId);

            DataTable      tb         = oleDb.GetDataTable(sbSQL.ToString( ));
            List <Invoice> lstInvoice = new List <Invoice>( );

            for (int i = 0; i < tb.Rows.Count; i++)
            {
                string      ticketnum  = tb.Rows[i]["ticketnum"].ToString( );
                string      ticketcode = tb.Rows[i]["ticketcode"].ToString( );
                int         hang_flag  = Convert.ToInt32(tb.Rows[i]["hang_flag"]);
                OPDBillKind kind       = (hang_flag == 0 ? OPDBillKind.门诊挂号发票: OPDBillKind.门诊收费发票);

                Invoice invoice = new Invoice(ticketcode, ticketnum, kind);
                lstInvoice.Add(invoice);
            }
            return(lstInvoice);
        }
Пример #12
0
        private void btnStat_Click(object sender, EventArgs e)
        {
            SetControlEnable(false);
            DateTime     beginDate;
            DateTime     endDate;
            BaseReport   report = null;
            string       accountIdList;
            string       patTypeCode = "";
            StatDateType dateType    = StatDateType.自然时间;
            OPDBillKind  invoiceType = OPDBillKind.所有发票;

            #region 统计条件
            #endregion
            if (chkIsUseTime.Checked)
            {
                ReportController.GetReportBeginDateAndEndDate(dateType, 0, dtpFrom.Value, dtpEnd.Value, out beginDate, out endDate, out accountIdList);
            }
            else
            {
                ReportController.GetReportBeginDateAndEndDate(dateType, 0, new DateTime(1, 1, 1), new DateTime(9999, 12, 30),
                                                              out beginDate, out endDate, out accountIdList);
            }
            lblDate.Text = beginDate.ToString("yyyy-MM-dd HH:mm:ss") + "--" + endDate.ToString("yyyy-MM-dd HH:mm:ss");
            try
            {
                report = new PatientFeeReport( );
                ((PatientFeeReport)report).PatName = txtPatName.Text;
                ((PatientFeeReport)report).VisitNo = txtVisitNo.Text;
                report.BeginDate = beginDate;
                report.EndDate   = endDate;
                ((PatientFeeReport)report).PatientTypeCode = patTypeCode;
                ((PatientFeeReport)report).InvoiceType     = invoiceType;
                report.StatDateType  = dateType;
                report.AccountIdList = accountIdList;
                report.ReportTitle   = "门诊病人费用统计表";
                report.Lister        = PublicDataReader.GetEmployeeNameById(employeeId);
                ReportController.FillReport(report);
                dgvReport.DataSource = report.DataResult;
                dgvReport.Tag        = report;
                for (int i = 0; i < dgvReport.Columns.Count; i++)
                {
                    if (i >= 3)
                    {
                        dgvReport.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        dgvReport.Columns[i].Width = 80;
                    }
                    if (i < 4)
                    {
                        dgvReport.Columns[i].Frozen = true;
                    }
                }
            }
            catch
            {
                MessageBox.Show("统计发生错误!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SetControlEnable(true);
            }
        }
Пример #13
0
        /// <summary>
        /// 获取可用发票号
        /// </summary>
        /// <param name="billKind">发票类型</param>
        /// <param name="_operatorId">操作员</param>
        /// <param name="onlyRead">是否只读</param>
        /// <returns></returns>
        public static string GetBillNumber(OPDBillKind billKind, int _operatorId, bool onlyRead, out string PerfChar)
        {
            string invoice_no = "";

            PerfChar = "";
            List <HIS.Model.MZ_INVOICE> invoice = null;

            //第一步:查找个人当前可用票据
            invoice = BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).GetListArray("invoice_type=" + (int)billKind + " and status=0 and employee_id =" + _operatorId);

            if (invoice.Count == 0)
            {
                //第二步:查找个人备用票据
                invoice = BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).GetListArray("invoice_type=" + (int)billKind + " and status=2 and employee_id =" + _operatorId);

                if (invoice.Count == 0)
                {
                    //第三步:查找公共当前在用票据
                    invoice = BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).GetListArray("invoice_type=" + (int)billKind + " and status=0 and employee_id =0");

                    if (invoice.Count == 0)
                    {
                        //第四步:查找公共备用票据
                        invoice = BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).GetListArray("invoice_type=" + (int)billKind + " and status=2 and employee_id =0");

                        if (invoice.Count == 0)
                        {
                            throw new OperatorException("没有可用的发票!请先分配");
                        }
                        else
                        {
                            //取得当前可用号
                            invoice_no = invoice[0].CURRENT_NO.ToString();
                            PerfChar   = invoice[0].PerfChar.Trim();
                            if (IsLastNumber(invoice[0]))
                            {
                                invoice[0].STATUS = 1; //置用完状态
                            }
                            else
                            {
                                invoice[0].STATUS     = 0;
                                invoice[0].CURRENT_NO = invoice[0].CURRENT_NO + 1;
                            }
                            if (!onlyRead)
                            {
                                BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).Update(invoice[0]);
                            }
                            return(invoice_no);
                        }
                    }
                    else
                    {
                        invoice_no = invoice[0].CURRENT_NO.ToString();
                        PerfChar   = invoice[0].PerfChar.Trim( );
                        if (IsLastNumber(invoice[0]))
                        {
                            invoice[0].STATUS = 1; //置用完状态
                        }
                        else
                        {
                            invoice[0].CURRENT_NO = invoice[0].CURRENT_NO + 1;
                        }
                        if (!onlyRead)
                        {
                            BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).Update(invoice[0]);
                        }
                        return(invoice_no);
                    }
                }
                else
                {
                    invoice_no = invoice[0].CURRENT_NO.ToString();
                    PerfChar   = invoice[0].PerfChar.Trim( );
                    if (IsLastNumber(invoice[0]))
                    {
                        invoice[0].STATUS = 1; //置用完状态
                    }
                    else
                    {
                        invoice[0].STATUS     = 0; //将备用标志改为在用标志
                        invoice[0].CURRENT_NO = invoice[0].CURRENT_NO + 1;
                    }
                    if (!onlyRead)
                    {
                        BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).Update(invoice[0]);
                    }
                    return(invoice_no);
                }
            }
            else
            {
                invoice_no = invoice[0].CURRENT_NO.ToString();
                PerfChar   = invoice[0].PerfChar.Trim( );
                if (IsLastNumber(invoice[0]))
                {
                    invoice[0].STATUS = 1; //置用完状态
                }
                else
                {
                    invoice[0].CURRENT_NO = invoice[0].CURRENT_NO + 1;
                }
                if (!onlyRead)
                {
                    BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).Update(invoice[0]);
                }
                return(invoice_no);
            }
        }
Пример #14
0
        /// <summary>
        /// 检查待分配的票据起始号是否已经使用
        /// </summary>
        /// <param name="kind">票据类型</param>
        /// <param name="start">开始号</param>
        /// <param name="end">结束号</param>
        /// <param name="perfChar">前缀字符</param>
        /// <returns>true:已经使用,false:未使用</returns>
        public static bool CheckInvoiceExists(OPDBillKind kind, int start, int end, string perfChar)
        {
            List <HIS.Model.MZ_INVOICE> invoices = null;

            invoices = BindEntity <Model.MZ_INVOICE> .CreateInstanceDAL(oleDb).GetListArray(Tables.mz_invoice.INVOICE_TYPE + oleDb.EuqalTo() + (int)kind + oleDb.And() + oleDb.UCASE(Tables.mz_invoice.PERFCHAR) + oleDb.EuqalTo() + "'" + perfChar + "'");

            for (int i = 0; i < invoices.Count; i++)
            {
                switch (invoices[i].STATUS)
                {
                case 0:
                    //在用状态,比较范围该卷开始号到结束号
                    if (start >= invoices[i].START_NO && start <= invoices[i].END_NO)
                    {
                        throw new OperatorException("输入的开始号" + start + "已经包含在第" + invoices[i].ID + "卷中,并且当前正在使用");
                    }
                    if (end >= invoices[i].START_NO && end <= invoices[i].END_NO)
                    {
                        throw new OperatorException("输入的结束号" + start + "已经包含在第" + invoices[i].ID + "卷中,并且当前正在使用");
                    }
                    break;

                case 1:
                    //用完状态,比较范围该卷开始号到结束号
                    if (start >= invoices[i].START_NO && start <= invoices[i].END_NO)
                    {
                        throw new OperatorException("输入的开始号" + start + "已经包含在第" + invoices[i].ID + "卷中,并已经使用过");
                    }
                    if (end >= invoices[i].START_NO && end <= invoices[i].END_NO)
                    {
                        throw new OperatorException("输入的结束号" + start + "已经包含在第" + invoices[i].ID + "卷中,并已经使用过");
                    }
                    break;

                case 2:
                    //备用状态,比较范围该卷开始号到结束号
                    if (start >= invoices[i].START_NO && start <= invoices[i].END_NO)
                    {
                        throw new OperatorException("输入的开始号" + start + "已经包含在第" + invoices[i].ID + "卷备用票据中");
                    }
                    if (end >= invoices[i].START_NO && end <= invoices[i].END_NO)
                    {
                        throw new OperatorException("输入的结束号" + start + "已经包含在第" + invoices[i].ID + "卷备用票据中");
                    }
                    break;

                case 3:
                    //停用状态,比较范围该卷开始号到停用时的当前号
                    if (start >= invoices[i].START_NO && start <= invoices[i].CURRENT_NO)
                    {
                        throw new OperatorException("输入的开始号" + start + "已经包含在第" + invoices[i].ID + "卷停用的票据中,如果要分配的票据号在停用卷的未使用号段中,请重新分配");
                    }
                    if (end >= invoices[i].START_NO && end <= invoices[i].CURRENT_NO)
                    {
                        throw new OperatorException("输入的结束号" + start + "已经包含在第" + invoices[i].ID + "卷停用的票据中,如果要分配的票据号在停用卷的未使用号段中,请重新分配");
                    }
                    break;
                }
            }
            return(true);
        }
Пример #15
0
        /// <summary>
        /// 发票号
        /// </summary>
        /// <param name="InvoiceNo">发票号</param>
        public Invoice(string PerfChar, string InvoiceNo, OPDBillKind kind)
        {
            HIS.Model.MZ_CostMaster m_mz_costmaster = new HIS.Model.MZ_CostMaster( );
            //HIS.DAL.MZ_DAL mz_dal = new HIS.DAL.MZ_DAL( );
            //mz_dal._OleDB = oleDb;
            try
            {
                string condiction = "TicketNum='" + InvoiceNo + "' and record_flag in (0,1)";
                if (PerfChar.Trim( ) != "")
                {
                    condiction += " and TicketCode ='" + PerfChar + "'";
                }

                if (kind == OPDBillKind.门诊挂号发票)
                {
                    condiction += " and hang_flag=" + (int)OPDOperationType.门诊挂号;
                }
                if (kind == OPDBillKind.门诊收费发票)
                {
                    condiction += " and hang_flag=" + (int)OPDOperationType.门诊收费;
                }

                //m_mz_costmaster = BindEntity<MZ_CostMaster>.CreateInstanceDAL(oleDb).GetModel( condiction );
                m_mz_costmaster = (MZ_CostMaster)MSAccessDb.GetModel("MZ_COSTMASTER", condiction, typeof(MZ_CostMaster));
                _chargeId       = m_mz_costmaster.CostMasterID;
                _invoiceNo      = InvoiceNo;
                MZ_CostMaster mz_costmaster = (MZ_CostMaster)MSAccessDb.GetModel("MZ_COSTMASTER", Tables.mz_costmaster.COSTMASTERID + "=" + m_mz_costmaster.CostMasterID, typeof(MZ_CostMaster));
                MZ_PatList    mz_patlist    = (MZ_PatList)MSAccessDb.GetModel("MZ_PATLIST", Tables.mz_patlist.PATLISTID + "=" + mz_costmaster.PatListID, typeof(MZ_PatList));
                _patientName  = mz_patlist == null ? "" : mz_patlist.PatName;
                _totalPay     = m_mz_costmaster.Total_Fee;
                _posPay       = m_mz_costmaster.Pos_Fee;
                _favorPay     = m_mz_costmaster.Favor_Fee;
                _villagePay   = m_mz_costmaster.Village_Fee;
                _chargeUser   = m_mz_costmaster.ChargeName;
                _chargeUserId = m_mz_costmaster.ChargeCode;
                _chargeDate   = m_mz_costmaster.CostDate;
                _record_flag  = m_mz_costmaster.Record_Flag;
                _cashPay      = _totalPay - _posPay - _villagePay - _favorPay;//m_mz_costmaster.Money_Fee;
                //发票内容
//                string sql = @"select b.ITEM_NAME,TOTAL_FEE
//                                from mz_costorder as a,base_stat_mzfp as b,base_stat_item as c
//                                where a.ITEMTYPE = c.CODE AND c.MZFP_CODE = b.CODE AND a.COSTID = " + mz_costmaster.CostMasterID;
//                System.Data.DataTable tb = mz_dal.GetInvoiceDetail( mz_costmaster.CostMasterID );
                string    sql            = @"select c.mzfp_name as ITEM_NAME,TOTAL_FEE 
                                from mz_costorder as a,base_stat_item as c  
                                where a.ITEMTYPE = c.CODE AND a.COSTID = " + mz_costmaster.CostMasterID;
                DataTable tb             = MSAccessDb.GetDataTable(sql);
                Hashtable htInvoiceItems = new Hashtable( );
                for (int i = 0; i < tb.Rows.Count; i++)
                {
                    InvoiceItem item = new InvoiceItem();
                    item.ItemName = tb.Rows[i]["Item_Name"].ToString( ).Trim( );
                    item.Cost     = Convert.ToDecimal(tb.Rows[i]["Total_fee"]);

                    if (htInvoiceItems.ContainsKey(item.ItemName))
                    {
                        InvoiceItem item1 = (InvoiceItem)htInvoiceItems[item.ItemName];
                        item1.Cost = item1.Cost + item.Cost;
                        htInvoiceItems.Remove(item.ItemName);
                        htInvoiceItems.Add(item1.ItemName, item1);
                    }
                    else
                    {
                        htInvoiceItems.Add(item.ItemName, item);
                    }
                }

                _items = new InvoiceItem[htInvoiceItems.Count];
                int invoiceCount = 0;
                foreach (object obj in htInvoiceItems)
                {
                    _items[invoiceCount].ItemName = ((InvoiceItem)((DictionaryEntry)obj).Value).ItemName;
                    _items[invoiceCount].Cost     = ((InvoiceItem)((DictionaryEntry)obj).Value).Cost;
                    invoiceCount++;
                }

                //处方信息
                #region ...
                //定义统计大类容器
                Hashtable htStatItems = new Hashtable( );
                List <HIS.Model.MZ_PresMaster> lst_mz_presmaster = new List <HIS.Model.MZ_PresMaster>( );
                //lst_mz_presmaster = BindEntity<MZ_PresMaster>.CreateInstanceDAL( oleDb ).GetListArray( Tables.mz_presmaster.COSTMASTERID + oleDb.EuqalTo() + _chargeId );
                lst_mz_presmaster = MSAccessDb.GetListArray <MZ_PresMaster>("MZ_PRESMASTER", Tables.mz_presmaster.COSTMASTERID + "=" + _chargeId);
                _prescription     = new Prescription[lst_mz_presmaster.Count];
                int index = 0;
                foreach (MZ_PresMaster model_mz_presmaster in lst_mz_presmaster)
                {
                    _prescription[index]                = new Prescription( );
                    _prescription[index].Charge_Flag    = model_mz_presmaster.Charge_Flag;
                    _prescription[index].ChargeCode     = model_mz_presmaster.ChargeCode;
                    _prescription[index].ChargeID       = model_mz_presmaster.CostMasterID;
                    _prescription[index].Drug_Flag      = model_mz_presmaster.Drug_Flag;
                    _prescription[index].ExecDeptCode   = model_mz_presmaster.ExecDeptCode;
                    _prescription[index].ExecDocCode    = model_mz_presmaster.ExecDocCode;
                    _prescription[index].OldPresID      = model_mz_presmaster.OldID;
                    _prescription[index].PresCostCode   = model_mz_presmaster.PresCostCode;
                    _prescription[index].PrescriptionID = model_mz_presmaster.PresMasterID;
                    _prescription[index].PrescType      = model_mz_presmaster.PresType;
                    _prescription[index].PresDeptCode   = model_mz_presmaster.PresDocCode;
                    _prescription[index].PresDocCode    = model_mz_presmaster.PresDocCode;
                    _prescription[index].Record_Flag    = model_mz_presmaster.Record_Flag;
                    _prescription[index].TicketCode     = model_mz_presmaster.TicketCode;
                    _prescription[index].TicketNum      = model_mz_presmaster.TicketNum;
                    _prescription[index].Total_Fee      = model_mz_presmaster.Total_Fee;
                    _prescription[index].Drug_Flag      = model_mz_presmaster.Drug_Flag;
                    //List<HIS.Model.MZ_PresOrder> orders = BindEntity<MZ_PresOrder>.CreateInstanceDAL( oleDb ).GetListArray( "PresmasterID=" + _prescription[index].PrescriptionID );
                    List <MZ_PresOrder>  orders  = MSAccessDb.GetListArray <MZ_PresOrder>("MZ_PRESORDER", "PresmasterID=" + _prescription[index].PrescriptionID);
                    PrescriptionDetail[] details = new PrescriptionDetail[orders.Count];
                    for (int j = 0; j < orders.Count; j++)
                    {
                        #region 明细
                        details[j].Amount      = orders[j].Amount;
                        details[j].BigitemCode = orders[j].BigItemCode;
                        details[j].Buy_price   = orders[j].Buy_Price;
                        details[j].ComplexId   = orders[j].CaseID;
                        details[j].DetailId    = orders[j].PresOrderID;
                        details[j].ItemId      = orders[j].ItemID;
                        details[j].Itemname    = orders[j].ItemName;
                        details[j].ItemType    = orders[j].ItemType;
                        details[j].Order_Flag  = orders[j].Order_Flag;
                        details[j].PassId      = orders[j].PassID;
                        details[j].PresAmount  = orders[j].PresAmount;
                        details[j].PresctionId = orders[j].PresMasterID;
                        details[j].RelationNum = orders[j].RelationNum;
                        details[j].Sell_price  = orders[j].Sell_Price;
                        details[j].Standard    = orders[j].Standard;
                        details[j].Tolal_Fee   = orders[j].Tolal_Fee;
                        details[j].Unit        = orders[j].Unit;
                        details[j].Comp_Money  = orders[j].Comp_Money;
                        #endregion

                        #region 生成大项目列表
                        if (htStatItems.ContainsKey(orders[j].BigItemCode.Trim()))
                        {
                            InvoiceItem item = (InvoiceItem)htStatItems[orders[j].BigItemCode.Trim( )];
                            item.Cost += orders[j].Tolal_Fee;
                            htStatItems.Remove(orders[j].BigItemCode.Trim( ));
                            htStatItems.Add(item.ItemCode, item);
                        }
                        else
                        {
                            InvoiceItem item = new InvoiceItem( );
                            item.ItemCode = orders[j].BigItemCode.Trim();
                            item.ItemName = GetStatItemNameByStatCode(item.ItemCode);
                            item.Cost     = orders[j].Tolal_Fee;
                            htStatItems.Add(item.ItemCode, item);
                        }
                        #endregion
                    }
                    _prescription[index].PresDetails = details;
                    index++;
                }
                #endregion
                _statitems = new InvoiceItem[htStatItems.Count];
                index      = 0;
                foreach (object obj in htStatItems.Values)
                {
                    _statitems[index] = (InvoiceItem)obj;
                    index++;
                }
                paytype = "";
                if (_cashPay > 0)
                {
                    paytype += " 现金 ";
                }
                if (_posPay > 0)
                {
                    paytype += " POS ";
                }
                if (_villagePay > 0)
                {
                    paytype += " 记账 ";
                }
            }
            catch (Exception err)
            {
                throw new Exception("读取发票信息错误!");
            }
        }
Пример #16
0
        /// <summary>
        /// 发票号
        /// </summary>
        /// <param name="InvoiceNo">发票号</param>
        public Invoice(string PerfChar, string InvoiceNo, OPDBillKind kind)
        {
            HIS.Model.MZ_CostMaster m_mz_costmaster = new HIS.Model.MZ_CostMaster( );
            HIS.DAL.MZ_DAL          mz_dal          = new HIS.DAL.MZ_DAL( );
            mz_dal._OleDB = oleDb;
            try
            {
                string condiction = "TicketNum='" + InvoiceNo + "' and record_flag in (0,1)";
                //if ( PerfChar.Trim( ) != "" )
                condiction += " and TicketCode ='" + PerfChar + "'";

                if (kind == OPDBillKind.门诊挂号发票)
                {
                    condiction += " and hang_flag=" + (int)OPDOperationType.门诊挂号;
                }
                if (kind == OPDBillKind.门诊收费发票)
                {
                    condiction += " and hang_flag=" + (int)OPDOperationType.门诊收费;
                }

                m_mz_costmaster = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetModel(condiction);

                _perfchar  = PerfChar;
                _billKind  = kind;
                _chargeId  = m_mz_costmaster.CostMasterID;
                _invoiceNo = InvoiceNo;
                _perfChar  = m_mz_costmaster.TicketCode;
                Model.MZ_CostMaster mz_costmaster = BindEntity <Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetModel(m_mz_costmaster.CostMasterID);

                Model.MZ_PatList mz_patlist = BindEntity <Model.MZ_PatList> .CreateInstanceDAL(oleDb).GetModel(mz_costmaster.PatListID);

                _patientName  = mz_patlist == null ? "" : mz_patlist.PatName;
                _totalPay     = m_mz_costmaster.Total_Fee;
                _posPay       = m_mz_costmaster.Pos_Fee;
                _favorPay     = m_mz_costmaster.Favor_Fee;
                _villagePay   = m_mz_costmaster.Village_Fee;
                _selfTally    = m_mz_costmaster.Self_Tally;
                _chargeUser   = m_mz_costmaster.ChargeName;
                _chargeUserId = m_mz_costmaster.ChargeCode;
                _chargeDate   = m_mz_costmaster.CostDate;
                _record_flag  = m_mz_costmaster.Record_Flag;
                _cashPay      = _totalPay - _posPay - _villagePay - _favorPay - _selfTally;//m_mz_costmaster.Money_Fee;
                //发票内容
                System.Data.DataTable tb = mz_dal.GetInvoiceDetail(mz_costmaster.CostMasterID);
                //Hashtable htInvoiceItems = new Hashtable();
                //for (int i = 0; i < tb.Rows.Count; i++)
                //{
                //    InvoiceItem item = new InvoiceItem();
                //    item.ItemName = tb.Rows[i]["Item_Name"].ToString().Trim();
                //    item.Cost = Convert.ToDecimal(tb.Rows[i]["Total_fee"]);
                //    item.Item_Name = tb.Rows[i]["ItemName"].ToString().Trim();
                //    item.Tolal_Fee = Convert.ToDecimal(tb.Rows[i]["Fee"]);

                //    if (htInvoiceItems.ContainsKey(item.ItemName))
                //    {
                //        InvoiceItem item1 = (InvoiceItem)htInvoiceItems[item.ItemName];
                //        if (tb.Rows[i]["itemtype"].ToString() == "01" || tb.Rows[i]["itemtype"].ToString() == "02" || tb.Rows[i]["itemtype"].ToString() == "03")
                //        {
                //            item1.Cost = item1.Cost + item.Cost;
                //            htInvoiceItems.Remove(item.ItemName);
                //        }
                //        htInvoiceItems.Add(item1.ItemName, item1);
                //    }
                //    else
                //    {
                //        htInvoiceItems.Add(item.ItemName, item);
                //    }
                //}

                _items = new InvoiceItem[tb.Rows.Count];
                // int invoiceCount = 0;
                for (int i = 0; i < tb.Rows.Count; i++)
                {
                    _items[i].ItemName = tb.Rows[i]["Item_Name"].ToString().Trim();
                    _items[i].Cost     = Convert.ToDecimal(tb.Rows[i]["Total_fee"]);

                    _items[i].Item_Name = tb.Rows[i]["ItemName"].ToString().Trim();
                    if (_items[i].Item_Name.Trim() == "")
                    {
                        _items[i].Tolal_Fee = "";
                    }
                    else
                    {
                        _items[i].Tolal_Fee = tb.Rows[i]["Fee"].ToString();
                    }
                }
                //foreach (object obj in htInvoiceItems)
                //{
                //    _items[invoiceCount].ItemName = ((InvoiceItem)((DictionaryEntry)obj).Value).ItemName;
                //    _items[invoiceCount].Cost = ((InvoiceItem)((DictionaryEntry)obj).Value).Cost;
                //    _items[invoiceCount].ItemName = ((InvoiceItem)((DictionaryEntry)obj).Value).Item_Name;
                //    _items[invoiceCount].Tolal_Fee = ((InvoiceItem)((DictionaryEntry)obj).Value).Tolal_Fee;

                //    invoiceCount++;
                //}
                //处方信息
                #region ...
                //定义统计大类容器
                Hashtable htStatItems = new Hashtable( );
                List <HIS.Model.MZ_PresMaster> lst_mz_presmaster = new List <HIS.Model.MZ_PresMaster>( );
                lst_mz_presmaster = BindEntity <Model.MZ_PresMaster> .CreateInstanceDAL(oleDb).GetListArray(Tables.mz_presmaster.COSTMASTERID + oleDb.EuqalTo() + _chargeId);

                _prescription = new Prescription[lst_mz_presmaster.Count];
                int index = 0;
                foreach (Model.MZ_PresMaster model_mz_presmaster in lst_mz_presmaster)
                {
                    _prescription[index]                = new Prescription( );
                    _prescription[index].Charge_Flag    = model_mz_presmaster.Charge_Flag;
                    _prescription[index].ChargeCode     = model_mz_presmaster.ChargeCode;
                    _prescription[index].ChargeID       = model_mz_presmaster.CostMasterID;
                    _prescription[index].Drug_Flag      = model_mz_presmaster.Drug_Flag;
                    _prescription[index].ExecDeptCode   = model_mz_presmaster.ExecDeptCode;
                    _prescription[index].ExecDocCode    = model_mz_presmaster.ExecDocCode;
                    _prescription[index].OldPresID      = model_mz_presmaster.OldID;
                    _prescription[index].PresCostCode   = model_mz_presmaster.PresCostCode;
                    _prescription[index].PrescriptionID = model_mz_presmaster.PresMasterID;
                    _prescription[index].PrescType      = model_mz_presmaster.PresType;
                    _prescription[index].PresDeptCode   = model_mz_presmaster.PresDocCode;
                    _prescription[index].PresDocCode    = model_mz_presmaster.PresDocCode;
                    _prescription[index].Record_Flag    = model_mz_presmaster.Record_Flag;
                    _prescription[index].TicketCode     = model_mz_presmaster.TicketCode;
                    _prescription[index].TicketNum      = model_mz_presmaster.TicketNum;
                    _prescription[index].Total_Fee      = model_mz_presmaster.Total_Fee;
                    _prescription[index].Drug_Flag      = model_mz_presmaster.Drug_Flag;
                    _prescription[index].DocPresId      = model_mz_presmaster.DocPresId;
                    List <HIS.Model.MZ_PresOrder> orders = BindEntity <Model.MZ_PresOrder> .CreateInstanceDAL(oleDb).GetListArray("PresmasterID=" + _prescription[index].PrescriptionID);

                    PrescriptionDetail[] details = new PrescriptionDetail[orders.Count];
                    for (int j = 0; j < orders.Count; j++)
                    {
                        #region 明细
                        details[j]             = new PrescriptionDetail();
                        details[j].Amount      = orders[j].Amount;
                        details[j].BigitemCode = orders[j].BigItemCode;
                        details[j].Buy_price   = orders[j].Buy_Price;
                        details[j].ComplexId   = orders[j].CaseID;
                        details[j].DetailId    = orders[j].PresOrderID;
                        details[j].ItemId      = orders[j].ItemID;
                        details[j].Itemname    = orders[j].ItemName;
                        details[j].ItemType    = orders[j].ItemType;
                        details[j].Order_Flag  = orders[j].Order_Flag;
                        details[j].PassId      = orders[j].PassID;
                        details[j].PresAmount  = orders[j].PresAmount;
                        details[j].PresctionId = orders[j].PresMasterID;
                        details[j].RelationNum = orders[j].RelationNum;
                        details[j].Sell_price  = orders[j].Sell_Price;
                        details[j].Standard    = orders[j].Standard;
                        details[j].Tolal_Fee   = orders[j].Tolal_Fee;
                        details[j].Unit        = orders[j].Unit;
                        details[j].Comp_Money  = orders[j].Comp_Money;
                        #endregion

                        #region 生成大项目列表
                        if (htStatItems.ContainsKey(orders[j].BigItemCode.Trim()))
                        {
                            InvoiceItem item = (InvoiceItem)htStatItems[orders[j].BigItemCode.Trim( )];
                            item.Cost += orders[j].Tolal_Fee;
                            htStatItems.Remove(orders[j].BigItemCode.Trim( ));
                            htStatItems.Add(item.ItemCode, item);
                        }
                        else
                        {
                            InvoiceItem item = new InvoiceItem( );
                            item.ItemCode = orders[j].BigItemCode.Trim();
                            //item.ItemName = GetStatItemNameByStatCode( item.ItemCode );
                            item.ItemName = BaseDataController.GetName(BaseDataCatalog.基本分类科目, item.ItemCode);
                            item.Cost     = orders[j].Tolal_Fee;
                            htStatItems.Add(item.ItemCode, item);
                        }
                        #endregion
                    }
                    _prescription[index].PresDetails = details;
                    index++;
                }
                #endregion
                _statitems = new InvoiceItem[htStatItems.Count];
                index      = 0;
                foreach (object obj in htStatItems.Values)
                {
                    _statitems[index] = (InvoiceItem)obj;
                    index++;
                }
                paytype = "";
                if (_cashPay > 0)
                {
                    paytype += " 现金 ";
                }
                if (_posPay > 0)
                {
                    paytype += " POS ";
                }
                if (_villagePay > 0)
                {
                    paytype += " 农合医保记账 ";
                }
                if (_selfTally > 0)
                {
                    paytype += " 单位记账 ";
                }
            }
            catch (Exception err)
            {
                ErrorWriter.WriteLog(err.Message);
                throw new Exception("读取发票信息错误!");
            }
        }
Пример #17
0
        /// <summary>
        /// 获取病人对象列表
        /// </summary>
        /// <param name="InvoiceNo">发票号</param>
        /// <param name="InvoiceType">发票类型</param>
        /// <param name="VisitNo">门诊号</param>
        /// <param name="PatientName">病人姓名</param>
        /// <param name="dateFrom">开始时间</param>
        /// <param name="dateTo">结束时间</param>
        /// <returns></returns>
        public List <BasePatient> GetPatient(string InvoiceNo, OPDBillKind InvoiceType,
                                             string VisitNo,
                                             string PatientName,
                                             DateTime?dateFrom, DateTime?dateTo)
        {
            StringBuilder sbSQL = new StringBuilder( );

            sbSQL.Append("select a.patlistid,visitno,patname,patsex,age,meditype,cureempcode,curedeptcode,curedate from mz_patlist a");
            sbSQL.Append(" inner join ");
            sbSQL.Append("(select patlistid,ticketnum,ticketcode,hang_flag,workid from mz_costmaster where record_flag in (0,1)) b on a.patlistid = b.patlistid");
            sbSQL.Append(" where a.workid=" + EntityConfig.WorkID + " and b.workid=" + EntityConfig.WorkID);
            if (InvoiceNo.Trim( ) != "")
            {
                if (InvoiceType == OPDBillKind.门诊挂号发票)
                {
                    sbSQL.Append(" and b.hang_flag = " + (int)OPDOperationType.门诊挂号);
                }
                else
                {
                    sbSQL.Append(" and b.hang_flag = " + (int)OPDOperationType.门诊收费);
                }
                sbSQL.Append(" and b.ticketnum='" + InvoiceNo + "'");
            }

            if (VisitNo.Trim( ) != "")
            {
                sbSQL.Append(" and visitno = '" + VisitNo.Trim( ) + "' ");
            }
            if (PatientName.Trim( ) != "")
            {
                sbSQL.Append(" and patname like '%" + PatientName.Trim() + "%' ");
            }
            if (dateFrom != null)
            {
                sbSQL.Append(" and curedate >='" + dateFrom.Value.ToString("yyyy-MM-dd HH:mm:ss") + "' ");
            }
            if (dateTo != null)
            {
                sbSQL.Append(" and curedate <='" + dateTo.Value.ToString("yyyy-MM-dd HH:mm:ss") + "' ");
            }

            DataTable          tb   = oleDb.GetDataTable(sbSQL.ToString( ));
            List <BasePatient> list = new List <BasePatient>( );

            for (int i = 0; i < tb.Rows.Count; i++)
            {
                OutPatient patient = new OutPatient( );
                patient.PatListID    = Convert.ToInt32(tb.Rows[i]["PatListID"]);
                patient.VisitNo      = Convert.ToString(tb.Rows[i]["VisitNo"]);
                patient.PatientName  = Convert.ToString(tb.Rows[i]["patname"]);
                patient.Sex          = Convert.ToString(tb.Rows[i]["patsex"]);
                patient.Age          = Convert.ToInt32(tb.Rows[i]["age"]);
                patient.MediType     = Convert.ToString(tb.Rows[i]["meditype"]);
                patient.CureEmpCode  = Convert.ToString(tb.Rows[i]["cureempcode"]);
                patient.CureDeptCode = Convert.ToString(tb.Rows[i]["curedeptcode"]);
                patient.CureDate     = Convert.ToDateTime(tb.Rows[i]["curedate"]);
                if (list.Find(delegate(BasePatient p)
                {
                    return(p.PatListID == patient.PatListID ? true : false);
                }) == null)
                {
                    list.Add(patient);
                }
            }
            return(list);
        }
Пример #18
0
        private void btnStat_Click(object sender, EventArgs e)
        {
            SetControlEnable(false);

            DateTime     beginDate;
            DateTime     endDate;
            BaseReport   report = null;
            string       accountIdList;
            string       patTypeCode = "";
            int          statDay     = Convert.ToInt32(txtDay.Text);
            StatDateType dateType    = StatDateType.统计日;
            OPDBillKind  invoiceType = OPDBillKind.所有发票;

            #region 统计条件
            foreach (object obj in Enum.GetValues(typeof(StatDateType)))
            {
                if (obj.ToString( ) == cboDateType.Text)
                {
                    dateType = (StatDateType)obj;
                    break;
                }
            }
            foreach (object obj in Enum.GetValues(typeof(OPDBillKind)))
            {
                if (obj.ToString( ) == cboInvoiceType.Text)
                {
                    invoiceType = (OPDBillKind)obj;
                    break;
                }
            }
            if (chkPatType.Checked)
            {
                patTypeCode = cboPatType.SelectedValue.ToString( );
            }
            #endregion
            ReportController.GetReportBeginDateAndEndDate(dateType, statDay, dtpFrom.Value, dtpEnd.Value, out beginDate, out endDate, out accountIdList);
            lblDate.Text = beginDate.ToString("yyyy-MM-dd HH:mm:ss") + "--" + endDate.ToString("yyyy-MM-dd HH:mm:ss");
            try
            {
                report           = new PatientFeeReport( );
                report.BeginDate = beginDate;
                report.EndDate   = endDate;
                ((PatientFeeReport)report).PatientTypeCode = patTypeCode;
                ((PatientFeeReport)report).InvoiceType     = invoiceType;
                ((PatientFeeReport)report).CurDocName      = chkCureDoc.Checked ? cboDoc.Text : "";
                ((PatientFeeReport)report).CurDeptName     = chkDept.Checked ? cboDept.Text : "";
                ((PatientFeeReport)report).ChargeName      = chkSfy.Checked ? cboCharge.Text : "";
                report.StatDateType  = dateType;
                report.AccountIdList = accountIdList;
                report.ReportTitle   = "门诊病人费用统计表";
                report.Lister        = BaseDataController.GetName(BaseDataCatalog.人员列表, employeeId); //PublicDataReader.GetEmployeeNameById( employeeId );

                ReportController.FillReport(report);
                dgvReport.DataSource = report.DataResult;
                dgvReport.Tag        = report;

                for (int i = 0; i < dgvReport.Columns.Count; i++)
                {
                    if (i >= 7)
                    {
                        dgvReport.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        dgvReport.Columns[i].Width = 80;
                    }
                    if (i < 8)
                    {
                        dgvReport.Columns[i].Frozen = true;
                    }
                }
            }
            catch
            {
                MessageBox.Show("统计发生错误!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SetControlEnable(true);
            }
        }
Пример #19
0
 public FrmAdjustInvoiceNo(int OperatorId, OPDBillKind InvoiceType)
 {
     InitializeComponent( );
     operatorId  = OperatorId;
     invoiceType = InvoiceType;
 }
Пример #20
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            lblActCost.Text    = "";
            lblTotalCost.Text  = "";
            lblTotalNum.Text   = "";
            lblReturnCost.Text = "";
            lblReturnNum.Text  = "";
            lblTotalCash.Text  = "";
            lblTotalFavor.Text = "";
            lblTotalPOS.Text   = "";
            lblTotalTally.Text = "";
            plInvoice.Visible  = false;
            try
            {
                DataTable tbList = null;
                if (chkall.Checked)
                {
                    tbList = DataReader.GetChargeInvoiceList(this.dtpFrom.Value, dtpTo.Value);
                }
                else
                {
                    tbList = DataReader.GetChargeInvoiceList(this.dtpFrom.Value, dtpTo.Value, Convert.ToInt32(_currentEmployeeId));
                }

                OPDBillKind invoiceType = OPDBillKind.所有发票;

                foreach (object obj in Enum.GetValues(typeof(OPDBillKind)))
                {
                    if (obj.ToString( ) == cboInvoiceType.Text)
                    {
                        invoiceType = (OPDBillKind)obj;
                    }
                }
                string patTypeCode = "";

                if (chkPayType.Checked)
                {
                    patTypeCode = cboPatType.SelectedValue.ToString();
                }
                DataRow[] drs;
                DataTable tbList1 = tbList.Clone( );
                if (invoiceType == OPDBillKind.门诊挂号发票)
                {
                    string filter = "Hang_Flag=0";
                    if (patTypeCode != "")
                    {
                        filter = filter + " and MediType='" + patTypeCode + "'";
                    }
                    drs = tbList.Select(filter);
                    for (int i = 0; i < drs.Length; i++)
                    {
                        tbList1.Rows.Add(drs[i].ItemArray);
                    }
                }
                else if (invoiceType == OPDBillKind.门诊收费发票)
                {
                    string filter = "Hang_Flag=1";
                    if (patTypeCode != "")
                    {
                        filter = filter + " and MediType='" + patTypeCode + "'";
                    }

                    drs = tbList.Select(filter);
                    for (int i = 0; i < drs.Length; i++)
                    {
                        tbList1.Rows.Add(drs[i].ItemArray);
                    }
                }
                else
                {
                    string filter = "";
                    if (patTypeCode != "")
                    {
                        filter = filter + "MediType='" + patTypeCode + "'";
                    }

                    drs = tbList.Select(filter);
                    for (int i = 0; i < drs.Length; i++)
                    {
                        tbList1.Rows.Add(drs[i].ItemArray);
                    }
                }
                tbList             = tbList1;
                dgvList.DataSource = tbList1;

                object objValue;

                lblTotalNum.Text  = tbList.Rows.Count.ToString( );
                objValue          = tbList.Compute("Sum(COST)", "");
                lblTotalCost.Text = Convert.ToDecimal(Convert.IsDBNull(objValue) ? "0" : objValue).ToString( );

                objValue          = tbList.Compute("count(InvoiceNo)", "UnChargeDate is not null");
                lblReturnNum.Text = Convert.ToInt32(Convert.IsDBNull(objValue)?"0":objValue).ToString( );

                objValue           = tbList.Compute("Sum(UnChargeCost)", "UnChargeDate is not null");
                lblReturnCost.Text = Convert.ToDecimal(Convert.IsDBNull(objValue) ? "0" : objValue).ToString( );

                objValue        = tbList.Compute("Sum(Cost)", "UnChargeDate is  null");
                lblActCost.Text = Convert.ToDecimal(Convert.IsDBNull(objValue) ? "0" : objValue).ToString( );

                objValue          = tbList.Compute("Sum(Cash)", "UnChargeDate is  null");
                lblTotalCash.Text = Convert.ToDecimal(Convert.IsDBNull(objValue) ? "0" : objValue).ToString( );

                objValue         = tbList.Compute("Sum(POS)", "UnChargeDate is  null");
                lblTotalPOS.Text = Convert.ToDecimal(Convert.IsDBNull(objValue) ? "0" : objValue).ToString( );

                objValue           = tbList.Compute("Sum(Tally)", "UnChargeDate is  null");
                lblTotalTally.Text = Convert.ToDecimal(Convert.IsDBNull(objValue) ? "0" : objValue).ToString( );

                objValue           = tbList.Compute("Sum(Favor)", "UnChargeDate is  null");
                lblTotalFavor.Text = Convert.ToDecimal(Convert.IsDBNull(objValue) ? "0" : objValue).ToString( );

                objValue = tbList.Compute("Sum(Self_Tally)", "UnChargeDate is  null");
                lblTotalSelfTally.Text = Convert.ToDecimal(Convert.IsDBNull(objValue) ? "0" : objValue).ToString( );
            }
            catch
            {
            }
        }
Пример #21
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            if (!chkPatName.Checked && !chkInvoiceType.Checked && !chkVisitNo.Checked && !dtpFrom.Checked && !dtpTo.Checked)
            {
                MessageBox.Show("至少需要指定一个查询条件!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string      patientName = "";
            OPDBillKind invoiceType = OPDBillKind.所有发票;
            string      invoiceNo   = "";
            string      visitNo     = "";
            DateTime?   beginDate   = null;
            DateTime?   endDate     = null;

            #region 查询参数
            if (chkPatName.Checked)
            {
                if (txtPatName.Text.Trim( ) != "")
                {
                    patientName = txtPatName.Text.Trim();
                }
                else
                {
                    MessageBox.Show("指定的查询条件:病人姓名没有填写!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtPatName.Focus( );
                    return;
                }
            }
            if (chkInvoiceType.Checked)
            {
                foreach (object obj in Enum.GetValues(typeof(OPDBillKind)))
                {
                    if (((OPDBillKind)obj).ToString( ) == cboInvoiceType.Text)
                    {
                        invoiceType = (OPDBillKind)obj;
                        break;
                    }
                }
                if (txtInvoiceNo.Text.Trim( ) != "")
                {
                    invoiceNo = txtInvoiceNo.Text.Trim( );
                }
                else
                {
                    MessageBox.Show("指定的查询条件:发票号没有填写!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtInvoiceNo.Focus( );
                    return;
                }
            }
            if (chkVisitNo.Checked)
            {
                if (txtVisitNo.Text.Trim( ) != "")
                {
                    visitNo = txtVisitNo.Text.Trim( );
                }
                else
                {
                    MessageBox.Show("指定的查询条件:门诊号没有填写!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtVisitNo.Focus( );
                    return;
                }
            }
            if (dtpFrom.Checked)
            {
                beginDate = Convert.ToDateTime(dtpFrom.Value.ToString("yyyy-MM-dd") + " 00:00:00");
            }
            if (dtpTo.Checked)
            {
                endDate = Convert.ToDateTime(dtpTo.Value.ToString("yyyy-MM-dd") + " 23:59:59");
            }
            #endregion


            PatientQuery       patientQuery = new PatientQuery( );
            List <BasePatient> lstPatient   = patientQuery.GetPatient(invoiceNo, invoiceType, visitNo, patientName, beginDate, endDate);
            ShowPatientList(lstPatient);
        }