/// <summary> /// 同步频次 /// </summary> /// <returns></returns> public string getFreq() { DBClass class2 = new DBClass(); DataSet ds = new DataSet(); string sql = " SELECT DISTINCT REPLACE(fname, '''', '’') as freqcode, REPLACE(fname, '''', '’') as freqname, 1 as timesofday , 1 as intervalday , null as UseTime FROM v_pivas_freq"; ds = class2.getOraDB(sql); string str2 = "delete from DFreqTemp"; class2.SetDB(str2); XmlToDataSet set2 = new XmlToDataSet(); WriteLog log = new WriteLog(); string content = set2.getxml(ds); log.writeLog("Freq_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), content); return(content); }
/// <summary> /// 同步药品 /// </summary> /// <returns></returns> public string getDrug() { DBClass class2 = new DBClass(); DataSet ds = new DataSet(); string sql = " SELECT distinct ccode as DrugCode,cname as DrugName, cname as DrugNameJC,spec as Spec, dos as Dosage, dosu as DosageUnit, null Major,null MajorUnit, dos AS Capacity, null Conversion,capu as CapacityUnit,null as Form,units as FormUnit,null as Conversion, spell as SpellCode, 0 as UniPreparationID,0 IsMenstruum, 0 withmenstruum, 0 PreConfigure, pishi as PiShi, 0 NotCompound, 0 Precious, null AsMajorDrug, null BigUnit, portno PortNo,null Symbol, null IsValid, null Difficulty, null DifficultySF, null Species, null Positions1,null Positions2,null NoName,spec1 ProductName,null Concentration, FIRM_ID firm_id FROM v_pivas_drugdict"; ds = class2.getOraDB(sql); string str2 = "delete from DDrugTemp "; class2.SetDB(str2); XmlToDataSet set2 = new XmlToDataSet(); WriteLog log = new WriteLog(); string content = set2.getxml(ds); log.writeLog("Drug_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), content); return(content); }
/// <summary> /// 同步员工 /// </summary> /// <returns></returns> public string getEmployee() { DBClass class2 = new DBClass(); DataSet ds = new DataSet(); string sql = " SELECT distinct eno AccountID ,null Pas ,null Position ,eno DEmployeeCode , ename DEmployeeName ,1 IsValid ,0 Type FROM v_pivas_employee"; ds = class2.getOraDB(sql); string str2 = "truncate table DEmployeeTemp "; class2.SetDB(str2); XmlToDataSet set2 = new XmlToDataSet(); WriteLog log = new WriteLog(); string content = set2.getxml(ds); log.writeLog("Employee_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), content); return(content); }
/// <summary> /// 同步病区 /// </summary> /// <returns></returns> public string getWard() { DBClass class2 = new DBClass(); DataSet ds = new DataSet(); XmlToDataSet set2 = new XmlToDataSet(); string sql = " select wcode as WardCode, wname as WardName, null as WardSimName, null as WardSeqNo,null as WardArea, null as IsOpen, null as Spellcode from v_pivas_ward"; ds = class2.getOraDB(sql); string str2 = "delete from DWardTemp "; class2.SetDB(str2); WriteLog log = new WriteLog(); string content = set2.getxml(ds); log.writeLog("Ward_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), content); return(content); }
/// <summary> /// 同步剂量单位 /// </summary> /// <returns></returns> public string getDosage() { DBClass class2 = new DBClass(); DataSet ds = new DataSet(); string sql = "SELECT distinct UNIT_CODE MetricCode ,UNIT_NAME MetricName ,null UnitID FROM v_pivas_dosunit"; ds = class2.getOraDB(sql); string str2 = "delete from DMetricTemp "; class2.SetDB(str2); XmlToDataSet set2 = new XmlToDataSet(); WriteLog log = new WriteLog(); string content = set2.getxml(ds); log.writeLog("Dosage_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), content); return(content); }
/// <summary> /// 同步医嘱 /// </summary> /// <returns></returns> public string getPrecption() { DBClass class2 = new DBClass(); DataSet ds = new DataSet(); string sql = " select distinct hospital_no||visit_id||'Y'||parent_no||'Z'||act_order_no as RecipeNo, hospital_no||visit_id||parent_no as GroupNo, ward_code WardCode, Doctor DoctorCode, '' DrawerCode, inpatient_no PatientCode, hospital_no CaseID, Bed_no BedNo, UsageName UsageCode, UsageName UsageName, freq_code FreqCode, charge_code DrugCode, drugname DrugName, specification Spec, dose Dosage, dose_unit DosageUnit, 0 Quantity, null QuantityUnit, sysdate InceptDT, start_time StartDT, end_time EndDT, TPN, 2 PDStatus, 0 PPause, null Remark1, null Remark2,'未记帐' as Remark3, null Remark4, null Remark5, null Remark6, remark Remark7, null Remark8, null Remark9, null Remark10, 0 OldGroup, 0 OldRecipe, 0 OldStop from v_pivas_yz"; ds = class2.getOraDB(sql); string str2 = "delete from PrescriptionTemp"; class2.SetDB(str2); XmlToDataSet set2 = new XmlToDataSet(); WriteLog log = new WriteLog(); string content = set2.getxml(ds); log.writeLog("Precption_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), content); return(content); }
/// <summary> /// 同步患者 /// </summary> /// <returns></returns> public string getPatient() { DBClass class2 = new DBClass(); DataSet ds = new DataSet(); string sql = "SELECT distinct pcode PatCode ,pname PatName, CASE Sex WHEN '?D' THEN '1' ELSE '2' END Sex , birthday Birthday ,'0'Height ,'0'Weight ,ward WardCode ,bed BedNo ,1 PatStatus ,trunc(months_between (sysdate,birthday)/12) Age ,null AgeSTR ,0 UPdateStatu FROM v_pivas_actpatient"; ds = class2.getOraDB(sql); string str2 = "delete from PatientTemp "; class2.SetDB(str2); XmlToDataSet set2 = new XmlToDataSet(); WriteLog log = new WriteLog(); string content = set2.getxml(ds); log.writeLog("Patient_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), content); return(content); }
private string execProc(DataSet ds, ref string s) { string ret = "1"; int num = 1; string hismsg = "计费成功"; string hisret = ""; tran = proc.Connection.BeginTransaction(); proc.Transaction = tran; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string pcode = ds.Tables[0].Rows[i]["iv_patient_id"].ToString(); string visit_time = ds.Tables[0].Rows[i]["in_visit_id"].ToString(); string order_no = ds.Tables[0].Rows[i]["in_order_no"].ToString(); string order_sub_no = ds.Tables[0].Rows[i]["in_order_sub_no"].ToString(); string charge_id = pcode + "_" + visit_time + "-" + order_no + "-" + order_sub_no; string drugcode = ds.Tables[0].Rows[i]["iv_drug_code"].ToString(); string labelno = ds.Tables[0].Rows[i]["iv_bar_code"].ToString(); string log_sql = "insert into charge_log values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')"; string begintime = DateTime.Now.ToString(); string query = "select 1 from charge_log where labelno='" + labelno + "' and hisret=2"; DBClass db = new DBClass(); DataSet ds2 = db.GetDB(query); if (ds2.Tables[0].Rows.Count > 0) { num = 2; break; } proc.Parameters["iv_dispensary"].Value = ds.Tables[0].Rows[i]["iv_dispensary"].ToString();// "5101"; proc.Parameters["iv_patient_id"].Value = ds.Tables[0].Rows[i]["iv_patient_id"].ToString(); proc.Parameters["in_visit_id"].Value = ds.Tables[0].Rows[i]["in_visit_id"].ToString(); proc.Parameters["in_baby_no"].Value = ds.Tables[0].Rows[i]["in_baby_no"].ToString(); proc.Parameters["in_order_no"].Value = ds.Tables[0].Rows[i]["in_order_no"].ToString(); proc.Parameters["in_order_sub_no"].Value = ds.Tables[0].Rows[i]["in_order_sub_no"].ToString(); proc.Parameters["iv_drug_code"].Value = ds.Tables[0].Rows[i]["iv_drug_code"].ToString(); proc.Parameters["iv_drug_spec"].Value = ds.Tables[0].Rows[i]["iv_drug_spec"].ToString(); proc.Parameters["iv_drug_units"].Value = ds.Tables[0].Rows[i]["iv_drug_units"].ToString(); proc.Parameters["iv_firm_id"].Value = ds.Tables[0].Rows[i]["iv_firm_id"].ToString(); proc.Parameters["in_dispense_amount"].Value = ds.Tables[0].Rows[i]["in_dispense_amount"].ToString(); proc.Parameters["iv_DISPENSING_PROVIDER"].Value = ds.Tables[0].Rows[i]["iv_DISPENSING_PROVIDER"].ToString(); proc.Parameters["in_order_sub_sub_no"].Value = ds.Tables[0].Rows[i]["in_order_sub_sub_no"].ToString(); proc.Parameters["iv_bar_code"].Value = ds.Tables[0].Rows[i]["iv_bar_code"].ToString(); proc.Parameters["id_PREFORM_DATETIME"].Value = DateTime.Now; proc.Parameters["in_SINA_MOUNT"].Value = "1"; proc.Parameters["iv_ADD_NURSE"].Value = ds.Tables[0].Rows[i]["iv_ADD_NURSE"].ToString(); proc.Parameters["in_stock_flag"].Value = ds.Tables[0].Rows[i]["in_stock_flag"].ToString(); proc.Parameters["on_price"].Value = ""; proc.Parameters["on_charges"].Value = ""; proc.Parameters["od_DISPENSING_DATE_TIME"].Value = DateTime.Now; proc.Parameters["on_exec_val"].Value = ""; proc.Parameters["ov_exec_txt"].Value = ""; try { proc.ExecuteNonQuery(); string endtime = DateTime.Now.ToString(); string inceptdt = DateTime.Now.ToString(); hisret = proc.Parameters["on_exec_val"].Value.ToString(); string msg = proc.Parameters["ov_exec_txt"].Value.ToString(); DB_Help dbhelp = new DB_Help(); dbhelp.addAndUpdate(string.Format(log_sql, begintime, endtime, inceptdt, labelno, charge_id, drugcode, hisret, msg)); if (hisret == "0" || hisret == "-1") { hismsg = proc.Parameters["ov_exec_txt"].Value.ToString(); // dbhelp.addAndUpdate("update charge_log set hisret=0 where labelno='"+labelno +"'"); num = 0; break; } else { num = 1; } } catch (Exception ex) { DB_Help dbhelp = new DB_Help(); string endtime = DateTime.Now.ToString(); string inceptdt = DateTime.Now.ToString(); hismsg = ex.Message; hisret = "0"; dbhelp.addAndUpdate(string.Format(log_sql, begintime, endtime, inceptdt, labelno, charge_id, drugcode, hisret, hismsg)); //dbhelp.addAndUpdate("update charge_log set hisret=0 where labelno='" + labelno + "'"); num = 0; break; } num = num * num; } s = hismsg; ret = num.ToString(); if (ret == "0") { tran.Rollback(); com.Connection.Close(); return "0"; } else if (ret == "2") { tran.Rollback(); com.Connection.Close(); s = "已计费"; return "1"; } else { tran.Commit(); com.Connection.Close(); string label = ds.Tables[0].Rows[0]["iv_bar_code"].ToString(); string insert = "insert into charge_log (labelno,hisret) values('{0}','{1}')"; DBClass db2 = new DBClass(); db2.SetDB(string.Format(insert, label, 2)); return "1"; } }
public string ChargeQD(string LabelNo, string UserCode, out string hismsg, out string hisret) { hismsg = ""; hisret = ""; DBClass class2 = new DBClass(); string str = DateTime.Now.ToString(); string format = ("update ivrecord set remark3='{0}',remark6='{1}' where labelno='" + LabelNo + "' ") + "update IVRecordDetail set ReturnFromHis='{2}' where ivrecordid in (select ivrecordid from ivrecord where labelno='" + LabelNo + "')"; string str3 = "select iv.GroupNo ,iv.InfusionDT , iv.Remark3 ,iv.PackAdvance ,iv.LabelOver ,p.PStatus from IVRecord iv inner join Prescription p on p.PrescriptionID =iv.PrescriptionID where iv.LabelNo ='{0}'"; DataSet dB = class2.GetDB(string.Format(str3, LabelNo)); string groupno = dB.Tables[0].Rows[0]["groupno"].ToString(); string infusionDT = dB.Tables[0].Rows[0]["InfusionDT"].ToString(); string str6 = dB.Tables[0].Rows[0]["Remark3"].ToString(); string str7 = dB.Tables[0].Rows[0]["PackAdvance"].ToString(); string str8 = dB.Tables[0].Rows[0]["LabelOver"].ToString(); string str9 = dB.Tables[0].Rows[0]["PStatus"].ToString(); if (Convert.ToInt32(str6) == 15) { if (Convert.ToInt32(str7) == 1) { hismsg = "已计费(提前打包)"; hisret = "0"; return "0"; } hismsg = "已计费"; hisret = "1"; return "1"; } if (Convert.ToInt32(str9) == 4) { hismsg = "医嘱已停止"; hisret = "0"; class2.SetDB(string.Concat(new object[] { "update ivrecord set labelover='-3',labeloverid='", UserCode, "',labelovertime='", DateTime.Now, "' where labelno='", LabelNo, "'" })); return "0"; } if (Convert.ToInt32(str8) < 0) { hismsg = "pivas已配置取消"; hisret = "0"; return "0"; } try { string str10; string str11; this.WXChargeQD(groupno, infusionDT, UserCode, out str10, out str11); string str12 = DateTime.Now.ToString(); string str13 = groupno + "||" + infusionDT + "||" + UserCode; class2.SetDB("insert into ToHisChargeLog (begintime,endtime,labelno,msg,ChargeResult,Parameters,HisReturn,Remark2) values ('" + str + "','" + str12 + "','" + LabelNo + "','" + str10 + "','" + str11 + "' ,'" + str13 + "','" + str11 + "','" + UserCode + "' )"); if (str10.Contains("记账成功") || str10.Contains("已接收")) { string str14 = ""; string sql = "select top 1 demployeeid from demployee where demployeecode='" + UserCode + "'"; DataTable table = class2.GetDB(sql).Tables[0]; if (table.Rows.Count > 0) { str14 = table.Rows[0][0].ToString(); } string str16 = " update IVRecord set IVStatus=9 where labelNo = '{0}' insert into IVRecord_PZ(IVrecordID,PZDT,ScanCount,pcode,Location,[Type]) values('{1}',getdate(), (SELECT COUNT(2) from IVRecord_PZ where IVrecordID = '{2}' and Invalid is null), '{3}','I',2)"; class2.SetDB(string.Format(str16, new object[] { LabelNo, LabelNo, LabelNo, str14 })); if (Convert.ToInt32(str7) == 1) { hismsg = "记账成功(提前打包)"; hisret = "0"; class2.SetDB(string.Format(format, 15, str10, str11)); return "0"; } hismsg = "记账成功"; hisret = "0"; class2.SetDB(string.Format(format, 15, str10, str11)); return "1"; } hismsg = str10; hisret = str11; class2.SetDB(string.Format(format, 12, str10, str11)); if (str10.Contains("医嘱")) { class2.SetDB(string.Concat(new object[] { "update ivrecord set labelover='-3',labeloverid='", UserCode, "',labelovertime='", DateTime.Now, "' where labelno='", LabelNo, "'" })); } return "0"; } catch (Exception exception) { string str17 = DateTime.Now.ToString(); hismsg = exception.Message; hisret = "0"; class2.SetDB(string.Concat(new object[] { "INSERT INTO ToHisChargeLog(BeginTime,EndTime,LabelNo,ChargeResult,HisReturn,msg,remark2) VALUES ('", str, "','", str17, "','", LabelNo, "','", 0, "','", hisret, "','", hismsg, "') " })); return "0"; } }
private string execProcEx(DataSet ds, ref string s) { string rett = ""; string begindt = DateTime.Now.ToString(); string chargeproc = "PHARMACY.DRUG_TRANS_PKG.TRANS_DRUG_PIVAS"; string connString = "Provider=MSDAORA;Data Source=yzxzh9i;User ID=inter_pivas;Password=pivas_inter; Persist Security Info=True"; OleDbCommand proc = new OleDbCommand(); OleDbConnection conn = new OleDbConnection(connString); proc.CommandText = chargeproc; proc.CommandType = CommandType.StoredProcedure; proc.Parameters.Clear(); proc.Parameters.Add("iv_dispensary", OleDbType.VarChar); proc.Parameters.Add("iv_patient_id", OleDbType.VarChar); proc.Parameters.Add("in_visit_id", OleDbType.VarChar); proc.Parameters.Add("in_baby_no", OleDbType.VarChar); proc.Parameters.Add("in_order_no", OleDbType.VarChar); proc.Parameters.Add("in_order_sub_no", OleDbType.VarChar); proc.Parameters.Add("iv_drug_code", OleDbType.VarChar); proc.Parameters.Add("iv_drug_spec", OleDbType.VarChar); proc.Parameters.Add("iv_drug_units", OleDbType.VarChar); proc.Parameters.Add("iv_firm_id", OleDbType.VarChar); proc.Parameters.Add("in_dispense_amount", OleDbType.VarChar); proc.Parameters.Add("iv_DISPENSING_PROVIDER", OleDbType.VarChar); proc.Parameters.Add("in_order_sub_sub_no", OleDbType.VarChar); proc.Parameters.Add("iv_bar_code", OleDbType.VarChar); proc.Parameters.Add("id_PREFORM_DATETIME", OleDbType.DBDate); proc.Parameters.Add("in_SINA_MOUNT", OleDbType.Integer); proc.Parameters.Add("iv_ADD_NURSE", OleDbType.VarChar); proc.Parameters.Add("in_stock_flag", OleDbType.Integer); for (int i = 0; i < 18; i++) { proc.Parameters[i].Direction = ParameterDirection.Input; } proc.Parameters.Add("on_price", OleDbType.VarChar); proc.Parameters.Add("on_charges", OleDbType.VarChar); proc.Parameters.Add("od_DISPENSING_DATE_TIME", OleDbType.DBDate); proc.Parameters.Add("on_exec_val", OleDbType.VarChar); proc.Parameters.Add("ov_exec_txt", OleDbType.VarChar); for (int i = 18; i < 23; i++) { proc.Parameters[i].Direction = ParameterDirection.Output; proc.Parameters[i].Size = 255; } proc.Connection = conn; if (conn.State != ConnectionState.Open) conn.Open(); OleDbTransaction tran = conn.BeginTransaction(); proc.Transaction = tran; //循环执行存储过程 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string hisret; string hismsg; string pcode = ds.Tables[0].Rows[i]["iv_patient_id"].ToString(); string visit_time = ds.Tables[0].Rows[i]["in_visit_id"].ToString(); string order_no = ds.Tables[0].Rows[i]["in_order_no"].ToString(); string order_sub_no = ds.Tables[0].Rows[i]["in_order_sub_no"].ToString(); string charge_id = pcode + "_" + visit_time + "-" + order_no + "-" + order_sub_no; string drugcode = ds.Tables[0].Rows[i]["iv_drug_code"].ToString(); string labelno = ds.Tables[0].Rows[i]["iv_bar_code"].ToString(); string log_sql = "insert into charge_log values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')"; string begintime = DateTime.Now.ToString(); string query = "select 1 from charge_log where labelno='" + labelno + "' and hisret=2"; DBClass db = new DBClass(); DataSet ds2 = db.GetDB(query); if (ds2.Tables[0].Rows.Count > 0) { s = "已计费"; tran = null; return "1"; } //存储过程参数赋值 proc.Parameters["iv_dispensary"].Value = ds.Tables[0].Rows[i]["iv_dispensary"].ToString(); proc.Parameters["iv_patient_id"].Value = ds.Tables[0].Rows[i]["iv_patient_id"].ToString(); proc.Parameters["in_visit_id"].Value = ds.Tables[0].Rows[i]["in_visit_id"].ToString(); proc.Parameters["in_baby_no"].Value = ds.Tables[0].Rows[i]["in_baby_no"].ToString(); proc.Parameters["in_order_no"].Value = ds.Tables[0].Rows[i]["in_order_no"].ToString(); proc.Parameters["in_order_sub_no"].Value = ds.Tables[0].Rows[i]["in_order_sub_no"].ToString(); proc.Parameters["iv_drug_code"].Value = ds.Tables[0].Rows[i]["iv_drug_code"].ToString(); proc.Parameters["iv_drug_spec"].Value = ds.Tables[0].Rows[i]["iv_drug_spec"].ToString(); proc.Parameters["iv_drug_units"].Value = ds.Tables[0].Rows[i]["iv_drug_units"].ToString(); proc.Parameters["iv_firm_id"].Value = ds.Tables[0].Rows[i]["iv_firm_id"].ToString(); proc.Parameters["in_dispense_amount"].Value = ds.Tables[0].Rows[i]["in_dispense_amount"].ToString(); proc.Parameters["iv_DISPENSING_PROVIDER"].Value = ds.Tables[0].Rows[i]["iv_DISPENSING_PROVIDER"].ToString(); proc.Parameters["in_order_sub_sub_no"].Value = ds.Tables[0].Rows[i]["in_order_sub_sub_no"].ToString(); proc.Parameters["iv_bar_code"].Value = ds.Tables[0].Rows[i]["iv_bar_code"].ToString(); proc.Parameters["id_PREFORM_DATETIME"].Value = DateTime.Now; proc.Parameters["in_SINA_MOUNT"].Value = "1"; proc.Parameters["iv_ADD_NURSE"].Value = ds.Tables[0].Rows[i]["iv_ADD_NURSE"].ToString(); proc.Parameters["in_stock_flag"].Value = ds.Tables[0].Rows[i]["in_stock_flag"].ToString(); proc.Parameters["on_price"].Value = ""; proc.Parameters["on_charges"].Value = ""; proc.Parameters["od_DISPENSING_DATE_TIME"].Value = DateTime.Now; proc.Parameters["on_exec_val"].Value = ""; proc.Parameters["ov_exec_txt"].Value = ""; //执行存储过程,设定超时时间,过了就终止循环 try { Thread threadToKill = null; Action wrappedAction = () => { threadToKill = Thread.CurrentThread; proc.ExecuteNonQuery(); }; IAsyncResult result = wrappedAction.BeginInvoke(null, null); if (result.AsyncWaitHandle.WaitOne(6000)) { wrappedAction.EndInvoke(result); } else { rett = "0"; s = " 捕获到超时,失败"; //threadToKill.Abort(); //throw new TimeoutException(); break; } string endtime = DateTime.Now.ToString(); string inceptdt = DateTime.Now.ToString(); hisret = proc.Parameters["on_exec_val"].Value.ToString(); string msg = proc.Parameters["ov_exec_txt"].Value.ToString(); s = msg; DB_Help dbhelp = new DB_Help(); dbhelp.addAndUpdate(string.Format(log_sql, begintime, endtime, inceptdt, labelno, charge_id, drugcode, hisret, msg)); if (hisret == "1") { rett = "1"; continue; } else { rett = "0"; break; } } catch (Exception ex) { DB_Help dbhelp = new DB_Help(); string endtime = DateTime.Now.ToString(); string inceptdt = DateTime.Now.ToString(); hismsg = " 捕获到异常 ," + ex.Message; s = hismsg; hisret = "0"; dbhelp.addAndUpdate(string.Format(log_sql, begintime, endtime, inceptdt, labelno, charge_id, drugcode, hisret, hismsg)); rett = "0"; break; } } //如果正常计费 if (rett == "1") { //事务提交 if (conn != null && tran != null) { tran.Commit(); tran = null; } //写入日志 string label = ds.Tables[0].Rows[0]["iv_bar_code"].ToString(); string insert = "insert into charge_log ( begindt,enddt, labelno,hisret) values('{0}','{1}','{2}','{3}')"; DBClass db2 = new DBClass(); db2.SetDB(string.Format(insert, begindt, DateTime.Now.ToString(), label, 2)); //释放连接 if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Dispose(); proc.Parameters.Clear(); proc.Dispose(); return "1"; } //如果计费失败或者有异常 //事务回滚 if (rett == "0") { if (conn != null && tran != null) { tran.Rollback(); tran = null; } //释放连接 if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Dispose(); proc.Parameters.Clear(); proc.Dispose(); return "0"; } return "1"; }