Exemplo n.º 1
0
        private static void update_mz_costmaster(MZ_CostMaster mz_costmaster)
        {
            string update = "update " + "MZ_COSTMASTER" + " set " +
                            Tables.mz_costmaster.ACCOUNTID + "=" + "" + mz_costmaster.AccountID + "" + "," +
                            Tables.mz_costmaster.CHARGECODE + "=" + "'" + mz_costmaster.ChargeCode + "'" + "," +
                            Tables.mz_costmaster.CHARGENAME + "=" + "'" + mz_costmaster.ChargeName + "'" + "," +
                            Tables.mz_costmaster.COSTDATE + "=" + "#" + mz_costmaster.CostDate + "#" + "," +
                            Tables.mz_costmaster.FAVOR_FEE + "=" + "" + mz_costmaster.Favor_Fee + "" + "," +
                            Tables.mz_costmaster.HANG_FLAG + "=" + "" + mz_costmaster.Hang_Flag + "" + "," +
                            Tables.mz_costmaster.HURRIED_FLAG + "=" + "" + mz_costmaster.Hurried_Flag + "" + "," +
                            Tables.mz_costmaster.MONEY_FEE + "=" + "" + mz_costmaster.Money_Fee + "" + "," +
                            Tables.mz_costmaster.OLDID + "=" + "" + mz_costmaster.OldID + "" + "," +
                            Tables.mz_costmaster.PATID + "=" + "" + mz_costmaster.PatID + "" + "," +
                            Tables.mz_costmaster.PATLISTID + "=" + "" + mz_costmaster.PatListID + "" + "," +
                            Tables.mz_costmaster.POS_FEE + "=" + "" + mz_costmaster.Pos_Fee + "" + "," +
                            Tables.mz_costmaster.PRESMASTERID + "=" + "" + mz_costmaster.PresMasterID + "" + "," +
                            Tables.mz_costmaster.RECORD_FLAG + "=" + "" + mz_costmaster.Record_Flag + "" + "," +
                            Tables.mz_costmaster.SELF_FEE + "=" + "" + mz_costmaster.Self_Fee + "" + "," +
                            Tables.mz_costmaster.SELF_TALLY + "=" + "" + mz_costmaster.Self_Tally + "" + "," +
                            Tables.mz_costmaster.TICKET_FLAG + "=" + "" + mz_costmaster.Ticket_Flag + "" + "," +
                            Tables.mz_costmaster.TICKETCODE + "=" + "'" + mz_costmaster.TicketCode + "'" + "," +
                            Tables.mz_costmaster.TICKETNUM + "=" + "'" + mz_costmaster.TicketNum + "'" + "," +
                            Tables.mz_costmaster.TOTAL_FEE + "=" + "" + mz_costmaster.Total_Fee + "" + "," +
                            Tables.mz_costmaster.VILLAGE_FEE + "=" + "" + mz_costmaster.Village_Fee + "" + "" +
                            " where " + Tables.mz_costmaster.COSTMASTERID + "=" + "" + mz_costmaster.CostMasterID;

            Execute(update);
        }
Exemplo n.º 2
0
        private static int insert_mz_costmaster(MZ_CostMaster mz_costmaster)
        {
            string insert = "insert into MZ_COSTMASTER (" +
                            "" + Tables.mz_costmaster.COSTMASTERID + "," +
                            "" + Tables.mz_costmaster.ACCOUNTID + "," +
                            "" + Tables.mz_costmaster.CHARGECODE + "," +
                            "" + Tables.mz_costmaster.CHARGENAME + "," +
                            "" + Tables.mz_costmaster.COSTDATE + "," +
                            "" + Tables.mz_costmaster.FAVOR_FEE + "," +
                            "" + Tables.mz_costmaster.HANG_FLAG + "," +
                            "" + Tables.mz_costmaster.HURRIED_FLAG + "," +
                            "" + Tables.mz_costmaster.MONEY_FEE + "," +
                            "" + Tables.mz_costmaster.OLDID + "," +
                            "" + Tables.mz_costmaster.PATID + "," +
                            "" + Tables.mz_costmaster.PATLISTID + "," +
                            "" + Tables.mz_costmaster.POS_FEE + "," +
                            "" + Tables.mz_costmaster.PRESMASTERID + "," +
                            "" + Tables.mz_costmaster.RECORD_FLAG + "," +
                            "" + Tables.mz_costmaster.SELF_FEE + "," +
                            "" + Tables.mz_costmaster.SELF_TALLY + "," +
                            "" + Tables.mz_costmaster.TICKET_FLAG + "," +
                            "" + Tables.mz_costmaster.TICKETCODE + "," +
                            "" + Tables.mz_costmaster.TICKETNUM + "," +
                            "" + Tables.mz_costmaster.TOTAL_FEE + "," +
                            "" + Tables.mz_costmaster.VILLAGE_FEE + ")";

            string values = "values (" +
                            "" + mz_costmaster.CostMasterID + "," +
                            "" + mz_costmaster.AccountID + "," +
                            "'" + mz_costmaster.ChargeCode + "'," +
                            "'" + mz_costmaster.ChargeName + "'," +
                            "#" + mz_costmaster.CostDate + "#," +
                            "" + mz_costmaster.Favor_Fee + "," +
                            "" + mz_costmaster.Hang_Flag + "," +
                            "" + mz_costmaster.Hurried_Flag + "," +
                            "" + mz_costmaster.Money_Fee + "," +
                            "" + mz_costmaster.OldID + "," +
                            "" + mz_costmaster.PatID + "," +
                            "" + mz_costmaster.PatListID + "," +
                            "" + mz_costmaster.Pos_Fee + "," +
                            "" + mz_costmaster.PresMasterID + "," +
                            "" + mz_costmaster.Record_Flag + "," +
                            "" + mz_costmaster.Self_Fee + "," +
                            "" + mz_costmaster.Self_Tally + "," +
                            "" + mz_costmaster.Ticket_Flag + "," +
                            "'" + mz_costmaster.TicketCode + "'," +
                            "'" + mz_costmaster.TicketNum + "'," +
                            "" + mz_costmaster.Total_Fee + "," +
                            "" + mz_costmaster.Village_Fee + ")";

            int effectrow = Execute(insert + " " + values);

            return(mz_costmaster.CostMasterID);
        }
Exemplo n.º 3
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("读取发票信息错误!");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 上传单个病人费用信息
        /// </summary>
        /// <param name="PatlistId"></param>
        public void UploadDataWithSinglePatient(int PatlistId)
        {
            if (_oleDb == null)
            {
                ConnectToRemoteDB( );
            }

            DataTable tbPatList       = MSAccessDb.GetDataTable("select * from mz_patlist where patlistid=" + PatlistId);
            DataTable tbPresMaster    = MSAccessDb.GetDataTable("select * from mz_presmaster where upload_flag=0 and patlistid = " + PatlistId + " and record_flag in (0,1,2) and prescostcode='" + _employeeId + "'");
            DataTable tbPresOrder     = MSAccessDb.GetDataTable("select * from mz_presorder where upload_flag=0 and presmasterid in (select presmasterid from mz_presmaster where patlistid = " + PatlistId + " and record_flag in (0,1,2) and prescostcode='" + _employeeId + "')");
            DataTable tbCostMaster    = MSAccessDb.GetDataTable("select * from mz_costmaster where upload_flag=0 and patlistid = " + PatlistId + " and record_flag in (0,1,2) and chargecode='" + _employeeId + "'");
            DataTable tbCostOrder     = MSAccessDb.GetDataTable("select * from mz_costorder where upload_flag=0 and costid in (select costmasterid from mz_costmaster where patlistid = " + PatlistId + " and record_flag in (0,1,2) and chargecode='" + _employeeId + "')");
            DataTable tbAccount       = MSAccessDb.GetDataTable("select * from mz_account where accountcode='" + _employeeId + "' and upload_flag = 0 ");
            string    patName         = tbPatList.Rows[0]["patname"].ToString( );
            int       presMasterCount = tbPresMaster.Rows.Count;
            int       presOrderCount  = tbPresOrder.Rows.Count;
            int       costMasterCount = tbCostMaster.Rows.Count;
            int       costOrderCount  = tbCostOrder.Rows.Count;
            int       accountCount    = tbAccount.Rows.Count;

            if (UpLoadingEvent != null)
            {
                UpLoadingEvent(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "开始上传病人【" + patName + "】的数据!\r\n");
            }
            if (presMasterCount == 0 && presOrderCount == 0 && costMasterCount == 0 && costOrderCount == 0 && accountCount == 0)
            {
                if (UpLoadingEvent != null)
                {
                    UpLoadingEvent("病人【" + patName + "】没有需要上传的数据!\r\n");
                }
                return;
            }
            try
            {
                BeginTrans( );

                MZ_PatList mz_patlist = new MZ_PatList( );
                DataBind <MZ_PatList>(tbPatList.Rows[0], mz_patlist);
                BindEntity <MZ_PatList> .CreateInstanceDAL(_oleDb).Add(mz_patlist);

                int serverPatlistId = mz_patlist.PatListID;
                MSAccessDb.Execute("update mz_patlist set upload_flag =1 where patlistid=" + PatlistId);
                for (int accountIndex = 0; accountIndex < tbAccount.Rows.Count; accountIndex++)
                {
                    //上传交款记录
                    int        localAccountId = Convert.ToInt32(tbAccount.Rows[accountIndex][Tables.mz_account.ACCOUNTID]);
                    MZ_Account mz_account     = new MZ_Account( );
                    DataBind <MZ_Account>(tbAccount.Rows[accountIndex], mz_account);
                    BindEntity <MZ_Account> .CreateInstanceDAL(_oleDb).Add(mz_account);

                    MSAccessDb.Execute("update mz_account set upload_flag = 1 where accountid=" + localAccountId);
                    //上传已交款的结算记录、结算明细,处方记录和处方明细(传完后从tbCostMaster中移除,剩下未交账的记录)
                    #region .....
                    DataRow[] drsCostMaster = tbCostMaster.Select(Tables.mz_costmaster.ACCOUNTID + "=" + localAccountId);
                    for (int costmasterIndex = 0; costmasterIndex < drsCostMaster.Length; costmasterIndex++)
                    {
                        //结算记录
                        int           localCostMasterId = Convert.ToInt32(drsCostMaster[costmasterIndex][Tables.mz_costmaster.COSTMASTERID]);
                        MZ_CostMaster mz_costmaster     = new MZ_CostMaster( );
                        DataBind <MZ_CostMaster>(drsCostMaster[costmasterIndex], mz_costmaster);
                        mz_costmaster.AccountID = mz_account.AccountID;
                        mz_costmaster.PatListID = serverPatlistId;
                        BindEntity <MZ_CostMaster> .CreateInstanceDAL(_oleDb).Add(mz_costmaster);

                        MSAccessDb.Execute("update mz_costmaster set upload_flag =1 where costmasterid=" + localCostMasterId);
                        //结算明细
                        DataRow[] drsCostOrder = tbCostOrder.Select(Tables.mz_costorder.COSTID + "=" + localCostMasterId);
                        for (int costorderIndex = 0; costorderIndex < drsCostOrder.Length; costorderIndex++)
                        {
                            int          loaclCostorderId = Convert.ToInt32(drsCostOrder[costorderIndex][Tables.mz_costorder.COSTORDERID]);
                            MZ_CostOrder mz_costorder     = new MZ_CostOrder( );
                            DataBind <MZ_CostOrder>(drsCostOrder[costorderIndex], mz_costorder);
                            mz_costorder.CostID = mz_costmaster.CostMasterID;
                            BindEntity <MZ_CostOrder> .CreateInstanceDAL(_oleDb).Add(mz_costorder);

                            MSAccessDb.Execute("update mz_costorder set upload_flag =1 where costorderid=" + loaclCostorderId);
                        }
                        //处方记录
                        DataRow[] drsPresMaster = tbPresMaster.Select(Tables.mz_presmaster.COSTMASTERID + "=" + localCostMasterId);
                        for (int presMasterIndex = 0; presMasterIndex < drsPresMaster.Length; presMasterIndex++)
                        {
                            int           localPresMasterId = Convert.ToInt32(drsPresMaster[presMasterIndex][Tables.mz_presmaster.PRESMASTERID]);
                            MZ_PresMaster mz_presmaster     = new MZ_PresMaster( );
                            DataBind <MZ_PresMaster>(drsPresMaster[presMasterIndex], mz_presmaster);
                            mz_presmaster.CostMasterID = mz_costmaster.CostMasterID;
                            mz_presmaster.PatListID    = serverPatlistId;
                            BindEntity <MZ_PresMaster> .CreateInstanceDAL(_oleDb).Add(mz_presmaster);

                            MSAccessDb.Execute("update mz_presmaster set upload_flag =1 where presmasterid=" + localPresMasterId);
                            //处方明细
                            DataRow[] drsPresOrder = tbPresOrder.Select(Tables.mz_presorder.PRESMASTERID + "=" + localPresMasterId);
                            for (int presorderIndex = 0; presorderIndex < drsPresOrder.Length; presorderIndex++)
                            {
                                int          localPresOrderId = Convert.ToInt32(drsPresOrder[presorderIndex][Tables.mz_presorder.PRESORDERID]);
                                MZ_PresOrder mz_presorder     = new MZ_PresOrder( );
                                DataBind <MZ_PresOrder>(drsPresOrder[presorderIndex], mz_presorder);
                                mz_presorder.PresMasterID = mz_presmaster.PresMasterID;
                                BindEntity <MZ_PresOrder> .CreateInstanceDAL(_oleDb).Add(mz_presorder);

                                MSAccessDb.Execute("update mz_presorder set upload_flag =1 where presorderid=" + localPresOrderId);
                            }
                        }
                        tbCostMaster.Rows.Remove(drsCostMaster[costmasterIndex]);
                    }
                    #endregion
                }
                //上传未交账的结算记录
                for (int costMasterIndex = 0; costMasterIndex < tbCostMaster.Rows.Count; costMasterIndex++)
                {
                    #region ...
                    //结算记录
                    int           localCostMasterId = Convert.ToInt32(tbCostMaster.Rows[costMasterIndex][Tables.mz_costmaster.COSTMASTERID]);
                    MZ_CostMaster mz_costmaster     = new MZ_CostMaster( );
                    DataBind <MZ_CostMaster>(tbCostMaster.Rows[costMasterIndex], mz_costmaster);
                    mz_costmaster.PatListID = serverPatlistId;
                    BindEntity <MZ_CostMaster> .CreateInstanceDAL(_oleDb).Add(mz_costmaster);

                    MSAccessDb.Execute("update mz_costmaster set upload_flag =1 where costmasterid=" + localCostMasterId);
                    //结算明细
                    DataRow[] drsCostOrder = tbCostOrder.Select(Tables.mz_costorder.COSTID + "=" + localCostMasterId);
                    for (int costorderIndex = 0; costorderIndex < drsCostOrder.Length; costorderIndex++)
                    {
                        int          loaclCostorderId = Convert.ToInt32(drsCostOrder[costorderIndex][Tables.mz_costorder.COSTORDERID]);
                        MZ_CostOrder mz_costorder     = new MZ_CostOrder( );
                        DataBind <MZ_CostOrder>(drsCostOrder[costorderIndex], mz_costorder);
                        mz_costorder.CostID = mz_costmaster.CostMasterID;
                        BindEntity <MZ_CostOrder> .CreateInstanceDAL(_oleDb).Add(mz_costorder);

                        MSAccessDb.Execute("update mz_costorder set upload_flag=1 where costorderid=" + loaclCostorderId);
                    }
                    //处方记录
                    DataRow[] drsPresMaster = tbPresMaster.Select(Tables.mz_presmaster.COSTMASTERID + "=" + localCostMasterId);
                    for (int presMasterIndex = 0; presMasterIndex < drsPresMaster.Length; presMasterIndex++)
                    {
                        int           localPresMasterId = Convert.ToInt32(drsPresMaster[presMasterIndex][Tables.mz_presmaster.PRESMASTERID]);
                        MZ_PresMaster mz_presmaster     = new MZ_PresMaster( );
                        DataBind <MZ_PresMaster>(drsPresMaster[presMasterIndex], mz_presmaster);
                        mz_presmaster.CostMasterID = mz_costmaster.CostMasterID;
                        mz_presmaster.PatListID    = serverPatlistId;
                        BindEntity <MZ_PresMaster> .CreateInstanceDAL(_oleDb).Add(mz_presmaster);

                        MSAccessDb.Execute("update mz_presmaster set upload_flag=1 where presmasterid=" + localPresMasterId);
                        //处方明细
                        DataRow[] drsPresOrder = tbPresOrder.Select(Tables.mz_presorder.PRESMASTERID + "=" + localPresMasterId);
                        for (int presorderIndex = 0; presorderIndex < drsPresOrder.Length; presorderIndex++)
                        {
                            int          localPresOrderId = Convert.ToInt32(drsPresOrder[presorderIndex][Tables.mz_presorder.PRESORDERID]);
                            MZ_PresOrder mz_presorder     = new MZ_PresOrder( );
                            DataBind <MZ_PresOrder>(drsPresOrder[presorderIndex], mz_presorder);
                            mz_presorder.PresMasterID = mz_presmaster.PresMasterID;
                            BindEntity <MZ_PresOrder> .CreateInstanceDAL(_oleDb).Add(mz_presorder);

                            MSAccessDb.Execute("update mz_presorder set upload_flag =1 where presorderid=" + localPresOrderId);
                        }
                    }
                    #endregion
                }

                //提交事务
                CommitTrans( );

                if (UpLoadingEvent != null)
                {
                    UpLoadingEvent(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "上传成功!\r\n处方记录" + presMasterCount + "条,处方明细" + presOrderCount + "条,结算记录" + costMasterCount + "条,结算明细" + costOrderCount + "条,个人交款记录" + accountCount + "条\r\n\r\n");
                }
            }
            catch (Exception err)
            {
                RollbackTrans( );
                throw err;
            }
        }