Пример #1
0
        private static int insert_mz_account(MZ_Account mz_account)
        {
            string insert = "insert into MZ_ACCOUNT (" +
                            "" + Tables.mz_account.ACCOUNTCODE + "" + "," +
                            "" + Tables.mz_account.ACCOUNTDATE + "" + "," +
                            "" + Tables.mz_account.ACCOUNTID + "" + "," +
                            "" + Tables.mz_account.BLANKOUT + "" + "," +
                            "" + Tables.mz_account.CASH_FEE + "" + "," +
                            "" + Tables.mz_account.LASTDATE + "" + "," +
                            "" + Tables.mz_account.POS_FEE + "" + "," +
                            "" + Tables.mz_account.TOTAL_FEE + "" + ")";
            string values = " values (" +
                            "'" + mz_account.AccountCode + "'" + "," +
                            "#" + mz_account.AccountDate + "#" + "," +
                            "" + mz_account.AccountID + "" + "," +
                            "'" + mz_account.BlankOut + "'" + "," +
                            "" + mz_account.Cash_Fee + "" + "," +
                            "#" + mz_account.LastDate + "#" + "," +
                            "" + mz_account.POS_Fee + "" + "," +
                            "" + mz_account.Total_Fee + "" + ")";

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

            return(mz_account.AccountID);
        }
Пример #2
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;
            }
        }