private static void update_mz_patlist(MZ_PatList mz_patlist) { string update = "update MZ_PATLIST set " + Tables.mz_patlist.AGE + "=" + mz_patlist.Age + "" + "," + Tables.mz_patlist.CUREDATE + "=#" + mz_patlist.CureDate + "#" + "," + Tables.mz_patlist.CUREDEPTCODE + "='" + mz_patlist.CureDeptCode + "'" + "," + Tables.mz_patlist.CUREEMPCODE + "='" + mz_patlist.CureEmpCode + "'" + "," + Tables.mz_patlist.DISEASECODE + "='" + mz_patlist.DiseaseCode + "'" + "," + Tables.mz_patlist.DISEASENAME + "='" + mz_patlist.DiseaseName + "'" + "," + Tables.mz_patlist.HPCODE + "='" + mz_patlist.HpCode + "'" + "," + Tables.mz_patlist.HPGRADE + "='" + mz_patlist.HpGrade + "'" + "," + Tables.mz_patlist.MEDICARD + "='" + mz_patlist.MediCard + "'" + "," + Tables.mz_patlist.MEDITYPE + "='" + mz_patlist.MediType + "'" + "," + Tables.mz_patlist.PATCODE + "='" + mz_patlist.PatCode + "'" + "," + Tables.mz_patlist.PATID + "=" + mz_patlist.PatID + "" + "," + Tables.mz_patlist.PATNAME + "='" + mz_patlist.PatName + "'" + "," + Tables.mz_patlist.PATSEX + "='" + mz_patlist.PatSex + "'" + "," + Tables.mz_patlist.PYM + "='" + mz_patlist.PYM + "'" + "," + Tables.mz_patlist.REG_DEPT_CODE + "='" + mz_patlist.REG_DEPT_CODE + "'" + "," + Tables.mz_patlist.REG_DEPT_NAME + "='" + mz_patlist.REG_DEPT_NAME + "'" + "," + Tables.mz_patlist.REG_DOC_CODE + "='" + mz_patlist.REG_DOC_CODE + "'" + "," + Tables.mz_patlist.REG_DOC_NAME + "='" + mz_patlist.REG_DOC_NAME + "'" + "," + Tables.mz_patlist.REGCODE + "='" + mz_patlist.RegCode + "'" + "," + Tables.mz_patlist.REGNAME + "='" + mz_patlist.RegName + "'" + "," + Tables.mz_patlist.VISITNO + "='" + mz_patlist.VisitNo + "'" + "," + Tables.mz_patlist.WBM + "='" + mz_patlist.WBM + "'" + "" + " where " + Tables.mz_patlist.PATLISTID + "=" + mz_patlist.PatListID; Execute(update); }
/// <summary> /// 就诊号 /// </summary> /// <param name="RegisterID"></param> public OutPatient(int RegisterID) { //HIS.DAL.MZ_PatList mz_patList = new HIS.DAL.MZ_PatList( ); //mz_patList._OleDB = new HIS.SYSTEM.DatabaseAccessLayer.OleDB( ); //mz_patList._OleDB.Initialize( ); MZ_PatList model = (MZ_PatList)MSAccessDb.GetModel("MZ_PATLIST", Tables.mz_patlist.PATLISTID + "=" + RegisterID, typeof(MZ_PatList)); if (model == null) { throw new Exception("无效的就诊号!"); } this.PatListID = model.PatListID; this.PatID = model.PatID; this.VisitNo = model.VisitNo; this.PatientName = model.PatName; 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; }
private static int insert_mz_patlist(MZ_PatList mz_patlist) { string insert = "insert into MZ_PATLIST (" + "" + Tables.mz_patlist.PATLISTID + "" + "," + "" + Tables.mz_patlist.AGE + "" + "," + "" + Tables.mz_patlist.CUREDATE + "" + "," + "" + Tables.mz_patlist.CUREDEPTCODE + "" + "," + "" + Tables.mz_patlist.CUREEMPCODE + "" + "," + "" + Tables.mz_patlist.DISEASECODE + "" + "," + "" + Tables.mz_patlist.DISEASENAME + "" + "," + "" + Tables.mz_patlist.HPCODE + "" + "," + "" + Tables.mz_patlist.HPGRADE + "" + "," + "" + Tables.mz_patlist.MEDICARD + "" + "," + "" + Tables.mz_patlist.MEDITYPE + "" + "," + "" + Tables.mz_patlist.PATCODE + "" + "," + "" + Tables.mz_patlist.PATID + "" + "," + "" + Tables.mz_patlist.PATNAME + "" + "," + "" + Tables.mz_patlist.PATSEX + "" + "," + "" + Tables.mz_patlist.PYM + "" + "," + "" + Tables.mz_patlist.REG_DEPT_CODE + "" + "," + "" + Tables.mz_patlist.REG_DEPT_NAME + "" + "," + "" + Tables.mz_patlist.REG_DOC_CODE + "" + "," + "" + Tables.mz_patlist.REG_DOC_NAME + "" + "," + "" + Tables.mz_patlist.REGCODE + "" + "," + "" + Tables.mz_patlist.REGNAME + "" + "," + "" + Tables.mz_patlist.WBM + "" + "," + "" + Tables.mz_patlist.VISITNO + ")"; string values = " values (" + "" + mz_patlist.PatListID + "" + "," + "" + mz_patlist.Age + "" + "," + "#" + mz_patlist.CureDate + "#" + "," + "'" + mz_patlist.CureDeptCode + "'" + "," + "'" + mz_patlist.CureEmpCode + "'" + "," + "'" + mz_patlist.DiseaseCode + "'" + "," + "'" + mz_patlist.DiseaseName + "'" + "," + "'" + mz_patlist.HpCode + "'" + "," + "'" + mz_patlist.HpGrade + "'" + "," + "'" + mz_patlist.MediCard + "'" + "," + "'" + mz_patlist.MediType + "'" + "," + "'" + mz_patlist.PatCode + "'" + "," + "" + mz_patlist.PatID + "" + "," + "'" + mz_patlist.PatName + "'" + "," + "'" + mz_patlist.PatSex + "'" + "," + "'" + mz_patlist.PYM + "'" + "," + "'" + mz_patlist.REG_DEPT_CODE + "'" + "," + "'" + mz_patlist.REG_DEPT_NAME + "'" + "," + "'" + mz_patlist.REG_DOC_CODE + "'" + "," + "'" + mz_patlist.REG_DOC_NAME + "'" + "," + "'" + mz_patlist.RegCode + "'" + "," + "'" + mz_patlist.RegName + "'" + "," + "'" + mz_patlist.WBM + "'" + "," + "'" + mz_patlist.VisitNo + "')"; int effectrow = Execute(insert + " " + values); return(mz_patlist.PatListID); }
/// <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("读取发票信息错误!"); } }
/// <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; } }