public int insertVolunteer(string VOLUNTEERUUID, string DOCUEMENTTYPE, string DOCUMENTNUMBER, string UnitUUID, ref string VOLUNTEERSERIALNO) { OrganizationBLL ob = new OrganizationBLL(); riTA = new REGIONINFOTableAdapter(); REGIONVOLUNTEERTableAdapter rvTA = new REGIONVOLUNTEERTableAdapter(); int rtn = 0; vbiTA.Connection.Open(); rvTA.Connection.Open(); riTA.Connection.Open(); vbiTA.Transaction = vbiTA.Connection.BeginTransaction(); rvTA.Transaction = rvTA.Connection.BeginTransaction(); riTA.Transaction = riTA.Connection.BeginTransaction(); try { string tob = Convert.ToString(riTA.GetCurrentSerialNo(UnitUUID)); if (!string.IsNullOrEmpty(tob)) { VOLUNTEERSERIALNO = tob; } else { VOLUNTEERSERIALNO = ob.GetRegionInfoByUnitID(UnitUUID)[0].REGPIX.PadRight(13, '0'); } VOLUNTEERSERIALNO = VOLUNTEERSERIALNO.Substring(0, 10) + volNoProcess(VOLUNTEERSERIALNO.Substring(10, 3)); if (VOLUNTEERSERIALNO.Length < 13) { throw new NullReferenceException(); } if (riTA.UpdataCurrentSerialNo(VOLUNTEERSERIALNO, UnitUUID) < 1) { throw new NullReferenceException(); } if (vbiTA.InsertQueryNoData( VOLUNTEERUUID, DOCUEMENTTYPE, DOCUMENTNUMBER, VOLUNTEERSERIALNO, -1, DateTime.Now, DateTime.Now ) < 1) { throw new NullReferenceException(); } if (rvTA.InsertQuery(UnitUUID, VOLUNTEERUUID, DateTime.Now, null, null, null, null, null) < 1) { throw new NullReferenceException(); } vbiTA.Transaction.Commit(); rvTA.Transaction.Commit(); riTA.Transaction.Commit(); rtn = 1; } catch { vbiTA.Transaction.Rollback(); rvTA.Transaction.Rollback(); riTA.Transaction.Rollback(); } finally { vbiTA.Connection.Close(); rvTA.Connection.Close(); riTA.Connection.Close(); } return rtn; }