lijinchang

导航

程序使用事务操作oracle多表的方法案例

 public int JieKou_SongPan(out string sError, int v_splx,string s_spyinhangzh, DataTable Dtlxsp, DateTime v_date, string v_account, int i_wenjiangsbh, int _curBankID, Entity.Common.ParameterList parameterlist)
        {
            using (OracleConnection conn = new OracleConnection(Platform.Configuration.ConfigHelper.BusinessConnString))
            {
                conn.Open();
                OracleTransaction tran = conn.BeginTransaction(IsolationLevel.ReadCommitted);
                try
                {
                    YW_WENJIANSJ_YWMXProcess yw_wenjiansj_ywmxp = new YW_WENJIANSJ_YWMXProcess();//业务文件数据业务明晰处理实例
                    int i_wenjianbh = 0;//文件编号
                    string s_wenjianbh;

                    int totalcount = 0;//成功记录个数
                    _spHelper.COMMON_REQUESTID("YW_WENJIANSJ", "I_WENJIANBH", null, 1, out s_wenjianbh, tran);
                    i_wenjianbh = new Utility().ToInt(s_wenjianbh).Value;
                    YW_WENJIANSJ_YWMX yw_wenjiansj_ywmx = new YW_WENJIANSJ_YWMX();//业务文件数据明细_业务明细
                    if (Dtlxsp != null)
                    {
                        for (int i = 1; i <= Dtlxsp.Rows.Count; i++)
                        {
                            yw_wenjiansj_ywmx.ID = 0;
                            yw_wenjiansj_ywmx.I_WENJIANBH = i_wenjianbh;
                            yw_wenjiansj_ywmx.I_MXBH = i;
                            yw_wenjiansj_ywmx.I_FEEID = new Utility().ToInt(Dtlxsp.Rows[i - 1]["I_FEEID"].ToString(), 0).Value;//feeid
                            yw_wenjiansj_ywmx.S_CID = Dtlxsp.Rows[i - 1]["S_CID"].ToString();
                            yw_wenjiansj_ywmx.I_Y = new Utility().ToInt(Dtlxsp.Rows[i - 1]["I_CHAOBIAON"].ToString(), 0).Value;//年
                            yw_wenjiansj_ywmx.I_M = new Utility().ToInt(Dtlxsp.Rows[i - 1]["I_CHAOBIAOY"].ToString(), 0).Value;//月
                            yw_wenjiansj_ywmx.I_CC = new Utility().ToInt(Dtlxsp.Rows[i - 1]["I_CC"].ToString(), 0).Value;//抄次
                            yw_wenjiansj_ywmx.I_KAIZHANGSL = new Utility().ToInt(Dtlxsp.Rows[i - 1]["I_KAIZHANGSL"].ToString(), 0);//开账水量
                            yw_wenjiansj_ywmx.N_KAIZHANGJE = new Utility().ToDecimal(Dtlxsp.Rows[i - 1]["N_KAIZHANGJE"].ToString(), 0);//开账金额
                            yw_wenjiansj_ywmx.N_JE = new Utility().ToDecimal(Dtlxsp.Rows[i - 1]["N_JE"].ToString(), 0);//金额
                            yw_wenjiansj_ywmx.I_KAIHUYH = new Utility().ToInt(Dtlxsp.Rows[i - 1]["I_KAIHUYH"].ToString(), 0);//开户银行
                            yw_wenjiansj_ywmx.S_KAIHUHM = Dtlxsp.Rows[i - 1]["S_KAIHUHM"].ToString();//开户户名
                            yw_wenjiansj_ywmx.S_YINHANGZH = Dtlxsp.Rows[i - 1]["S_KAIHUZH"].ToString();//银行账号
                            yw_wenjiansj_ywmx.S_CAOZUOR = LoginInfo.CurrentUser.Account;//操作人
                            yw_wenjiansj_ywmx.D_CAOZUOSJ = v_date;//操作时间
                            yw_wenjiansj_ywmx.S_DZ = Dtlxsp.Rows[i - 1]["S_DZ"].ToString();//用水地址
                            yw_wenjiansj_ywmx.S_KEHUID = Dtlxsp.Rows[i - 1]["S_KEHUID"].ToString();//客户编号
                            yw_wenjiansj_ywmx.S_ST = Dtlxsp.Rows[i - 1]["S_ST"].ToString();//站点
                            yw_wenjiansj_ywmx.I_CENEIXH = new Utility().ToInt(Dtlxsp.Rows[i - 1]["I_CENEIXH"].ToString()).Value;//册内序号
                            yw_wenjiansj_ywmx.I_SFFS = new Utility().ToInt(Dtlxsp.Rows[i - 1]["I_SFFS"].ToString()).Value;//收费方式
                            yw_wenjiansj_ywmx.S_KUAIHAO = Dtlxsp.Rows[i - 1]["S_KUAIHAO"].ToString();//块号
                            yw_wenjiansj_ywmx.S_JH = Dtlxsp.Rows[i - 1]["S_JH"].ToString();//简号
                            yw_wenjiansj_ywmx.S_HM = Dtlxsp.Rows[i - 1]["S_HM"].ToString();//户名
                            yw_wenjiansj_ywmx.I_ZHANGWUNY = new Utility().ToInt(Dtlxsp.Rows[i - 1]["I_ZHANGWUNY"].ToString()).Value;//账务年月
                            yw_wenjiansj_ywmx.S_SHUIBIAOTXM = Dtlxsp.Rows[i - 1]["S_SHUIBIAOTXM"].ToString();//水表条形码
                            yw_wenjiansj_ywmx.S_TUOSHOUHTH = Dtlxsp.Rows[i - 1]["S_TUOSHOUHTH"].ToString();//托收合同号
                            if (yw_wenjiansj_ywmxp.InsertOrUpdate(yw_wenjiansj_ywmx, tran))
                            {
                                totalcount += 1;
                            }

                        }
                    }
                    int? v_count;
                    _spHelper.JIEKOU_SPCAOZUO(v_splx, i_wenjianbh, 0, i_wenjiangsbh, v_account, v_date, _curBankID, parameterlist.ToString(),s_spyinhangzh, out v_count, tran);
                    if (v_count > 0)
                    {
                        // 生成文件内容
                        sError = BuildFile(i_wenjianbh, tran);
                        if (string.IsNullOrEmpty(sError))
                        {
                            tran.Commit();
                            return i_wenjianbh;
                        }
                        else
                        {
                            tran.Rollback();
                            return 0;
                        }
                    }
                    else
                    {
                        sError = "130311";
                        tran.Rollback();
                        return 0;
                    }
                }
                catch(Exception ex)
                {
                    sError = "130312" + ex.ToString();
                    tran.Rollback();
                    return 0;
                }

            }
        }

posted on 2010-11-26 13:56  lijinchang  阅读(337)  评论(0编辑  收藏  举报