示例#1
0
        public int Insert(List <ROLEDC> objROLEs)
        {
            int          insertedCount = 0;
            DBConnection objConnection = new DBConnection();
            ROLEDA       objROLEDA     = new ROLEDA();

            try
            {
                objConnection.Open(true);
                foreach (ROLEDC objROLE in objROLEs)
                {
                    insertedCount = objROLEDA.Insert(objConnection, objROLE);
                    if (objROLE.ROLE_ID == -111)
                    {
                        throw new Exception("Role Name '" + objROLE.ROLE_NAME + "' already exists.All other changes saved successfully.");
                    }
                }
                objConnection.Commit();
            }
            catch (Exception ex)
            {
                objConnection.Rollback();
                throw ex;
            }
            finally
            {
                objConnection.Close();
            }
            return(insertedCount);
        }